summaryrefslogtreecommitdiff
path: root/ishtar_common/forms_common.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2022-09-17 13:33:43 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:23:18 +0100
commit82ff03721678b5f9ea7868ce403167b0e9a54490 (patch)
tree2a69c48df18caaea6ac04c6a9b9ea8e7e09d49de /ishtar_common/forms_common.py
parentc0c6c83e5aa4f225497021fb7860a4dd1895fff6 (diff)
downloadIshtar-82ff03721678b5f9ea7868ce403167b0e9a54490.tar.bz2
Ishtar-82ff03721678b5f9ea7868ce403167b0e9a54490.zip
Geo form: fix point 3D creation and edition
Diffstat (limited to 'ishtar_common/forms_common.py')
-rw-r--r--ishtar_common/forms_common.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index 53cca91d5..2caf6c1af 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -2821,13 +2821,16 @@ class GISForm(forms.ModelForm, CustomForm, ManageOldType):
for geo_fields in self.GEO_FIELDS:
if geo_fields != keys:
for geo_field in geo_fields:
- self.fields.pop(geo_field)
if geo_field == "x":
self.fields.pop("estimated_error_x")
self.fields.pop("y")
self.fields.pop("estimated_error_y")
if geo_field == "z":
+ if geo_keys[0] == "point_3d":
+ geo_keys = list(geo_keys) + ["z"]
+ continue
self.fields.pop("estimated_error_z")
+ self.fields.pop(geo_field)
break
return geo_keys
@@ -2849,7 +2852,15 @@ class GISForm(forms.ModelForm, CustomForm, ManageOldType):
raise forms.ValidationError(
_("If you set a buffer type set a buffer.")
)
-
+ if cleaned_data.get("point_3d"):
+ if "z" not in cleaned_data:
+ raise forms.ValidationError(
+ _("A value is expected for Z.")
+ )
+ value = cleaned_data["point_3d"].ewkt
+ if "POINT Z" not in value:
+ value = value.replace("POINT", "POINT Z")
+ cleaned_data["point_3d"] = f'{value.split(")")[0]} {cleaned_data["z"]})'
if "x" not in self.geo_keys:
# reverse...