summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-05-15 19:37:31 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-05-15 19:37:31 +0200
commit84f5aa42103bed9351ec9a3dc431c25f7118841a (patch)
treef6cca459ea5a5577817e410a16965271a0fe8cdb
parente92e91c2e1738a3dc56ab1afa6b77bf3e7b2b915 (diff)
downloadIshtar-84f5aa42103bed9351ec9a3dc431c25f7118841a.tar.bz2
Ishtar-84f5aa42103bed9351ec9a3dc431c25f7118841a.zip
Geo: fix display of precise polygons
-rw-r--r--ishtar_common/models.py20
-rw-r--r--ishtar_common/templates/ishtar/blocks/sheet_coordinates.html2
-rw-r--r--ishtar_common/templates/ishtar/blocks/sheet_simple_map.html2
3 files changed, 22 insertions, 2 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 4b14d852c..8774ed951 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1742,6 +1742,26 @@ class GeoItem(models.Model):
if self.multi_polygon_source == 'P' and self.multi_polygon:
return self.multi_polygon, self.multi_polygon_source_item
+ def most_precise_geo(self):
+ if self.point_source == 'M':
+ return 'multi_polygon'
+ current_source = unicode(self.__class__._meta.verbose_name)
+ if self.multi_polygon_source_item == current_source \
+ and (self.multi_polygon_source == "P" or
+ self.point_source_item != current_source):
+ return 'multi_polygon'
+ if self.point_source_item == current_source\
+ and self.point_source == 'P':
+ return 'point'
+ if self.multi_polygon_source == 'P':
+ return 'multi_polygon'
+ if self.point_source == 'P':
+ return 'point'
+ if self.multi_polygon:
+ return 'multi_polygon'
+ if self.point_2d:
+ return 'point'
+
def geo_point_source(self):
if not self.point_source:
return ""
diff --git a/ishtar_common/templates/ishtar/blocks/sheet_coordinates.html b/ishtar_common/templates/ishtar/blocks/sheet_coordinates.html
index ff6218f1c..ff0586515 100644
--- a/ishtar_common/templates/ishtar/blocks/sheet_coordinates.html
+++ b/ishtar_common/templates/ishtar/blocks/sheet_coordinates.html
@@ -15,7 +15,7 @@
{% endif %}
</dd>
</dl>
-{% if geo_item.point_source == 'P' or not geo_item.multi_polygon %}
+{% if geo_item.most_precise_geo == 'point' %}
{% trans "Point source" as point_source %}
{% field_flex_full point_source geo_item.geo_point_source %}
{% else %}
diff --git a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html
index ca93d7956..d755fe531 100644
--- a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html
+++ b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html
@@ -8,7 +8,7 @@
<script type="text/javascript">
var html = render_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", false, true);
$("#map-content-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}").html(html);
-{% if geo_item.point_source == 'P' or not geo_item.multi_polygon %}
+{% if geo_item.most_precise_geo == 'point' %}
var {{geo_item.SLUG}}{{geo_item.pk}} = {{geo_item.point_2d_geojson|safe}};
display_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", {{geo_item.SLUG}}{{geo_item.pk}});
{% else %}