diff options
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 93a099b74..5e7f6e9b3 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1899,12 +1899,22 @@ class GeoItem(models.Model): self.__class__.objects.filter(pk=self.pk), geometry_field=geom_attr, fields=(cached_label_key,)) geojson_dct = json.loads(geojson) + profile = get_current_profile() + precision = profile.point_precision + features = geojson_dct.pop('features') for idx in range(len(features)): feature = features[idx] lbl = feature['properties'].pop(cached_label_key) feature['properties']['name'] = lbl feature['properties']['id'] = self.pk + if precision is not None: + geom_type = feature["geometry"].get("type", None) + if geom_type == "Point": + feature["geometry"]["coordinates"] = [ + round(coord, precision) + for coord in feature["geometry"]["coordinates"] + ] geojson_dct['features'] = features geojson_dct['link_template'] = simple_link_to_window(self).replace( '999999', '<pk>' @@ -2575,6 +2585,13 @@ class IshtarSiteProfile(models.Model, Cached): preservation = models.BooleanField(_("Preservation module"), default=False) mapping = models.BooleanField(_("Mapping module"), default=False) + point_precision = models.IntegerField( + _("Point precision (search and sheets)"), null=True, blank=True, + help_text=_( + "Number of digit to round from the decimal point for coordinates " + "in WGS84 (latitude, longitude). Empty value means no round." + ) + ) locate_warehouses = models.BooleanField( _("Locate warehouse and containers"), default=False, help_text=_( |