diff options
-rw-r--r-- | UPGRADE-V4.md (renamed from UPGRADE_V4.md) | 0 | ||||
-rw-r--r-- | ishtar_common/management/commands/migrate_to_geo_v4.py | 1 | ||||
-rw-r--r-- | ishtar_common/models_common.py | 22 |
3 files changed, 5 insertions, 18 deletions
diff --git a/UPGRADE_V4.md b/UPGRADE-V4.md index f69dbb9ec..f69dbb9ec 100644 --- a/UPGRADE_V4.md +++ b/UPGRADE-V4.md diff --git a/ishtar_common/management/commands/migrate_to_geo_v4.py b/ishtar_common/management/commands/migrate_to_geo_v4.py index d904b279a..188365c45 100644 --- a/ishtar_common/management/commands/migrate_to_geo_v4.py +++ b/ishtar_common/management/commands/migrate_to_geo_v4.py @@ -195,6 +195,7 @@ def _process_main(obj): "x": obj.x, "y": obj.y, "z": obj.z, + "spatial_reference_system": obj.spatial_reference_system } data = models_common.GeoVectorData.objects.create(**attrs) obj.main_geodata = data diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index b13517f25..2fb0d40f6 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2266,6 +2266,8 @@ class GeoVectorData(Imported, OwnPerms): args["z"] = self.z point = Point(**args).transform(srid, clone=True) coordinates = [point.x, point.y] + if srid == 4326: + coordinates = list(reversed(coordinates)) if dim == 3: coordinates.append(point.z) else: @@ -3470,25 +3472,9 @@ class GeoItem(GeographicItem): @property def display_coordinates(self, rounded=True): - if not self.point_2d: + if not self.main_geodata: return "" - profile = get_current_profile() - if ( - not profile.display_srs - or not profile.display_srs.srid - or ( - profile.display_srs == self.spatial_reference_system - and self.x - and self.y - ) - ): - x, y = self.x, self.y - else: - point = self.point_2d.transform(profile.display_srs.srid, clone=True) - x, y = point.x, point.y - if rounded: - return round(x, 5), round(y, 5) - return x, y + return self.main_geodata.display_coordinates(rounded=rounded) @property def display_spatial_reference_system(self): |