From 717cb9e99ce2d290f1193401d08ae7c32332b508 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Sat, 17 Oct 2026 13:03:53 +0200 Subject: [PATCH] # Bugfix empty feature collection * fixes a bug on empty feature collections input of SimpleGeomForm --- konova/utils/geometry/geometry_validator.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/konova/utils/geometry/geometry_validator.py b/konova/utils/geometry/geometry_validator.py index 8cb4e084..cba884e2 100644 --- a/konova/utils/geometry/geometry_validator.py +++ b/konova/utils/geometry/geometry_validator.py @@ -277,10 +277,10 @@ class GeoJsonValidator: """ features = self._input_geojson.get("features", []) - is_input_geojson_empty = len(self._input_geojson) == 0 + is_input_geojson_empty_str = len(self._input_geojson) == 0 no_features_in_input_found = len(features) == 0 - if not is_input_geojson_empty and no_features_in_input_found: + if not is_input_geojson_empty_str and no_features_in_input_found: # check if _input_geojson is a feature itself if self.__is_geojson_feature(): features = [ @@ -288,6 +288,9 @@ class GeoJsonValidator: "geometry": self._input_geojson } ] + elif self.__is_geojson_featurecollection(): + # special case if empty featurecollection received + pass else: self.__add_error("Input does not seem to be geojson") return @@ -371,4 +374,14 @@ class GeoJsonValidator: has_type = self._input_geojson.get("type", None) is not None has_coordinates = self._input_geojson.get("coordinates", None) is not None has_properties = self._input_geojson.get("properties", None) is not None - return has_type and has_coordinates and has_properties \ No newline at end of file + return has_type and has_coordinates and has_properties + + def __is_geojson_featurecollection(self): + """ Checks whether _input_geojson is a geojson featurecollection + + Returns: + + """ + is_fc_type = self._input_geojson.get("type", None) == "FeatureCollection" + has_feature_attribute = isinstance(self._input_geojson.get("features", None), list) + return is_fc_type and has_feature_attribute \ No newline at end of file