summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2022-07-17 12:34:47 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:23:17 +0100
commit9a33671a0c5f788f85d23c34f880d0994789e675 (patch)
treecdcf9ae5ebc01a0fb92a9262ee498e78ea05adc5 /ishtar_common
parent058a8dd843b08043defeb389513d00ffa5a8734b (diff)
downloadIshtar-9a33671a0c5f788f85d23c34f880d0994789e675.tar.bz2
Ishtar-9a33671a0c5f788f85d23c34f880d0994789e675.zip
Geo - sheet: fix coordinates display
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/models_common.py15
-rw-r--r--ishtar_common/static/js/ishtar-map.js2
-rw-r--r--ishtar_common/templates/ishtar/blocks/sheet_coordinates.html31
3 files changed, 26 insertions, 22 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py
index 66025948a..cea327e13 100644
--- a/ishtar_common/models_common.py
+++ b/ishtar_common/models_common.py
@@ -2234,19 +2234,22 @@ class GeoVectorData(Imported, OwnPerms):
def source_label(self):
return str(self.source)
- def display_coordinates(self, rounded=5, dim=2, srid=4326, cache=True):
+ def display_coordinates(self, rounded=5, dim=2, srid=None, cache=True):
if not srid:
- profile = get_current_profile()
- if profile.display_srs and profile.display_srs.srid:
- srid = profile.display_srs.srid
+ if self.spatial_reference_system and self.spatial_reference_system.srid:
+ srid = self.spatial_reference_system.srid
else:
- srid = 4326
+ profile = get_current_profile()
+ if profile.display_srs and profile.display_srs.srid:
+ srid = profile.display_srs.srid
+ if not srid:
+ srid = 4326
return self.get_coordinates(rounded=rounded, srid=srid, dim=dim, cache=cache)
def get_coordinates(self, rounded=5, srid: int = None, dim=2, cache=False):
if dim not in (2, 3):
raise ValueError(_("Only 2 or 3 dimensions"))
- if cache:
+ if cache and srid == 4326:
coordinates = [self.cached_x, self.cached_y]
if dim == 3:
coordinates.append(self.cached_z)
diff --git a/ishtar_common/static/js/ishtar-map.js b/ishtar_common/static/js/ishtar-map.js
index 8a5ee6071..a3f275720 100644
--- a/ishtar_common/static/js/ishtar-map.js
+++ b/ishtar_common/static/js/ishtar-map.js
@@ -230,7 +230,7 @@ var get_layers = function(layers){
layers = [
{
'type': 'ign',
- 'options': {'title': "IGN (France)", 'visible': false, "type": 'base'}
+ 'options': {'title': "IGN aérien (France)", 'visible': false, "type": 'base'}
},
{
'type': 'osm',
diff --git a/ishtar_common/templates/ishtar/blocks/sheet_coordinates.html b/ishtar_common/templates/ishtar/blocks/sheet_coordinates.html
index dbcecef8c..0093ed31f 100644
--- a/ishtar_common/templates/ishtar/blocks/sheet_coordinates.html
+++ b/ishtar_common/templates/ishtar/blocks/sheet_coordinates.html
@@ -1,27 +1,28 @@
-{% load i18n window_field %}{% if PROFILE.mapping %}
-{% if geo_item.x or geo_item.y or geo_item.z %}
+{% load i18n window_field %}{% if PROFILE.mapping and geo_item.main_geodata %}
+{% with geodata=geo_item.main_geodata %}
+{% if geodata.cached_x or geodata.cached_z %}
<dl class="col-12">
<dt>{% trans "Coordinates" %}</dt>
<dd>
- {% with coordinates=geo_item.display_coordinates %}
+ {% with coordinates=geodata.display_coordinates %}
{% trans "X:"%} {{coordinates.0|default_if_none:"-"}}
- {% if geo_item.estimated_error_x %} ({% trans "error:" %} {{geo_item.estimated_error_x}}){% endif %},
+ {% if geodata.estimated_error_x %} ({% trans "error:" %} {{geodata.estimated_error_x}}){% endif %},
{% trans "Y:"%} {{coordinates.1|default_if_none:"-"}}
- {% if geo_item.estimated_error_y %} ({% trans "error:" %} {{geo_item.estimated_error_y}}){% endif %},
+ {% if geodata.estimated_error_y %} ({% trans "error:" %} {{geodata.estimated_error_y}}){% endif %},
{% endwith %}
- {% trans "Z:"%} {{geo_item.z|default_if_none:"-"}}
- {% if geo_item.estimated_error_z %} ({% trans "error:" %} {{geo_item.estimated_error_z}}){% endif %}
- {% with srs=geo_item.display_spatial_reference_system %}
+ {% trans "Z:"%} {{geodata.z|default_if_none:"-"}}
+ {% if geodata.estimated_error_z %} ({% trans "error:" %} {{geodata.estimated_error_z}}){% endif %}
+ {% with srs=geodata.display_spatial_reference_system %}
{% if srs %} &ndash; {{srs.label}} - {% trans "SRID"%} {{srs.srid}} {% endif %}
{% endwith %}
</dd>
</dl>
-{% if geo_item.most_precise_geo == 'point' %}
-{% trans "Point source" as point_source %}
-{% field_flex_full point_source geo_item.geo_point_source %}
-{% else %}
-{% trans "Polygon source" as polygon_source %}
-{% field_flex_full polygon_source geo_item.geo_polygon_source %}
-{% endif %}
+{% field_flex_full "Data type" geodata.data_type %}
+{% field_flex_full "Source" geodata.source_label %}
+{% field_flex_full "Name" geodata.name %}
+{% field_flex_full "Origin" geodata.origin %}
+{% field_flex_full "Provider" geodata.provider %}
+{% field_flex_full "Comment" geodata.comment %}
{% endif %}
+{% endwith %}
{% endif %}