diff options
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/forms_common.py | 15 | ||||
| -rw-r--r-- | ishtar_common/models_common.py | 4 | 
2 files changed, 15 insertions, 4 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... diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index b72251f02..37ddd11df 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2277,7 +2277,7 @@ class GeoVectorData(Imported, OwnPerms):              if dim == 3:                  coordinates.append(self.cached_z)          else: -            if self.x or self.y or self.z:  # user input +            if self.x or self.y:  # user input                  if not srid or not self.spatial_reference_system or \                          srid == self.spatial_reference_system.srid:                      coordinates = [self.x, self.y] @@ -2315,7 +2315,7 @@ class GeoVectorData(Imported, OwnPerms):                  else:                      if dim == 2:                          return [None, None] -                    return [None, None, None] +                    return [None, None, self.z or None]                  point = geom                  if not srid or srid != geom.srid: | 
