Merge pull request '# Bugfix empty feature collection' (#597) from bugfix_empty_geometry_on_form into master
Reviewed-on: #597
This commit was merged in pull request #597.
This commit is contained in:
@@ -277,10 +277,10 @@ class GeoJsonValidator:
|
|||||||
"""
|
"""
|
||||||
features = self._input_geojson.get("features", [])
|
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
|
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
|
# check if _input_geojson is a feature itself
|
||||||
if self.__is_geojson_feature():
|
if self.__is_geojson_feature():
|
||||||
features = [
|
features = [
|
||||||
@@ -288,6 +288,9 @@ class GeoJsonValidator:
|
|||||||
"geometry": self._input_geojson
|
"geometry": self._input_geojson
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
elif self.__is_geojson_featurecollection():
|
||||||
|
# special case if empty featurecollection received
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
self.__add_error("Input does not seem to be geojson")
|
self.__add_error("Input does not seem to be geojson")
|
||||||
return
|
return
|
||||||
@@ -371,4 +374,14 @@ class GeoJsonValidator:
|
|||||||
has_type = self._input_geojson.get("type", None) is not None
|
has_type = self._input_geojson.get("type", None) is not None
|
||||||
has_coordinates = self._input_geojson.get("coordinates", 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
|
has_properties = self._input_geojson.get("properties", None) is not None
|
||||||
return has_type and has_coordinates and has_properties
|
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
|
||||||
Reference in New Issue
Block a user