diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-06-15 10:22:01 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:21:01 +0100 |
commit | 59f97318687a19a8623261aff0bc875ca99c5c7c (patch) | |
tree | 4a17c15d334249d2ae4f5d53395e608299336d7e /ishtar_common | |
parent | fb3e9bd47dd56385eb2be38b8ea51f6a5535d884 (diff) | |
download | Ishtar-59f97318687a19a8623261aff0bc875ca99c5c7c.tar.bz2 Ishtar-59f97318687a19a8623261aff0bc875ca99c5c7c.zip |
Fix migrations
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/management/commands/migrate_to_geo_v4.py | 1 | ||||
-rw-r--r-- | ishtar_common/models_common.py | 22 |
2 files changed, 5 insertions, 18 deletions
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): |