diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-07-03 12:46:51 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-07-03 12:46:51 +0200 |
commit | 508f7a717d0d1b71c48e761922ceab7887132a89 (patch) | |
tree | 16205f1739d6fabf45fd9ea41e221e0a8dc1d6af /ishtar_common/models.py | |
parent | d448b3a3675acf21c07fe8876b2dde0272645f93 (diff) | |
download | Ishtar-508f7a717d0d1b71c48e761922ceab7887132a89.tar.bz2 Ishtar-508f7a717d0d1b71c48e761922ceab7887132a89.zip |
Geo search and sheets: add a point precision for display
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=_( |