diff options
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/models_common.py | 39 | 
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): | 
