Compare commits

..

No commits in common. "b98f821c98be976925ea791d069a51ec62dfe32a" and "5421de4e80307bcc00d5fdc55692a8f8bce73fc8" have entirely different histories.

View File

@ -54,7 +54,7 @@ class SimpleGeomForm(BaseForm):
geom = json.dumps(geojson)
except AttributeError:
# If no geometry exists for this form, we simply set the value to None and zoom to the maximum level
geom = json.dumps({})
geom = ""
self.empty = True
self.initialize_form_field("output", geom)
@ -72,12 +72,20 @@ class SimpleGeomForm(BaseForm):
self.initialize_form_field("output", json.dumps(submitted_data))
# Get geojson from form for validity checking
geom = self.data.get("output", json.dumps({}))
geom = json.loads(geom)
geom = self.data.get("output", None)
geom_is_empty = geom is None or len(geom) == 0
if geom_is_empty:
# If no geometry has been submitted, we create an empty geometry object since
# an empty geometry is a valid geometry
self.cleaned_data["output"] = MultiPolygon(srid=DEFAULT_SRID_RLP).ewkt
return is_valid
# Initialize features list with empty MultiPolygon, so that an empty input will result in a
# proper empty MultiPolygon object
features = []
# Prepare geometry for validity checks (create iterable dict)
geom = json.loads(geom)
features_json = geom.get("features", [])
accepted_ogr_types = [
"Polygon",
@ -133,7 +141,6 @@ class SimpleGeomForm(BaseForm):
if features:
form_geom = MultiPolygon(*features, srid=DEFAULT_SRID_RLP).unary_union
else:
# If no features have been processed, this indicates an empty geometry - so we store an empty geometry
form_geom = MultiPolygon(srid=DEFAULT_SRID_RLP)
# Make sure to convert into a MultiPolygon. Relevant if a single Polygon is provided.