summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-01-12 10:08:57 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:23 +0100
commit7c47f59e0ca4cbadf2b0c92d49d28da032bd88ec (patch)
tree0ac8b3ad6c1293a4a163d40546a656bcbd67d871
parentb7771450c2c821f339fcfaf078de701d2120691b (diff)
downloadIshtar-7c47f59e0ca4cbadf2b0c92d49d28da032bd88ec.tar.bz2
Ishtar-7c47f59e0ca4cbadf2b0c92d49d28da032bd88ec.zip
X, Y fields to export in the default SRS
-rw-r--r--ishtar_common/models_common.py39
1 files changed, 31 insertions, 8 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py
index 3bd97e192..6d8db23e0 100644
--- a/ishtar_common/models_common.py
+++ b/ishtar_common/models_common.py
@@ -2526,9 +2526,9 @@ class GeoItem(models.Model):
)
# gis
- x = models.FloatField(_(u'X'), blank=True, null=True)
- y = models.FloatField(_(u'Y'), blank=True, null=True)
- z = models.FloatField(_(u'Z'), blank=True, null=True)
+ x = models.FloatField(_('X'), blank=True, null=True)
+ y = models.FloatField(_('Y'), blank=True, null=True)
+ z = models.FloatField(_('Z'), blank=True, null=True)
estimated_error_x = models.FloatField(_(u'Estimated error for X'),
blank=True, null=True)
estimated_error_y = models.FloatField(_(u'Estimated error for Y'),
@@ -2565,14 +2565,37 @@ class GeoItem(models.Model):
raise NotImplementedError
@property
- def display_coordinates(self):
+ def X(self):
+ """x coordinates using the default SRS"""
+ coord = self.display_coordinates
+ if not coord:
+ return
+ return coord[0]
+
+ @property
+ def Y(self):
+ """y coordinates using the default SRS"""
+ coord = self.display_coordinates
+ if not coord:
+ return
+ return coord[1]
+
+ @property
+ def display_coordinates(self, rounded=True):
if not self.point_2d:
return ""
profile = get_current_profile()
- if not profile.display_srs or not profile.display_srs.srid:
- return self.x, self.y
- point = self.point_2d.transform(profile.display_srs.srid, clone=True)
- return round(point.x, 5), round(point.y, 5)
+ 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
@property
def display_spatial_reference_system(self):