diff --git a/www/maposmatic/templates/maposmatic/map-full.html b/www/maposmatic/templates/maposmatic/map-full.html
index 1322cfac..625d9e9d 100644
--- a/www/maposmatic/templates/maposmatic/map-full.html
+++ b/www/maposmatic/templates/maposmatic/map-full.html
@@ -180,8 +180,13 @@
{{ map.administrative_city }} ({{ map.administrative_osmid }}) |
{% else %}
{% trans "Bounding box" %} |
- ({{ map.lat_upper_left }}, {{ map.lon_upper_left }}) →
- ({{ map.lat_bottom_right }}, {{ map.lon_bottom_right }}) |
+
+ {{ map.lat_upper_left|latitude }}, {{ map.lon_upper_left|longitude }}
+ →
+ {{ map.lat_bottom_right|latitude }}, {{ map.lon_bottom_right|longitude }}
+ ({{ map|bbox_km }})
+ |
+
{% endif %}
{% trans "Layout" %} |
{{ map.layout }} |
diff --git a/www/maposmatic/templates/maposmatic/maps.html b/www/maposmatic/templates/maposmatic/maps.html
index 4aa6f666..07aad7a8 100644
--- a/www/maposmatic/templates/maposmatic/maps.html
+++ b/www/maposmatic/templates/maposmatic/maps.html
@@ -54,8 +54,12 @@
{{ map.administrative_city }} ({{ map.administrative_osmid }}) |
{% else %}
{% trans "Bounding Box" %} |
- ({{ map.lat_upper_left|floatformat:3 }}, {{ map.lon_upper_left|floatformat:3 }}) →
- ({{ map.lat_bottom_right|floatformat:3 }}, {{ map.lon_bottom_right|floatformat:3 }}) |
+
+ {{ map.lat_upper_left|latitude }}, {{ map.lon_upper_left|longitude }}
+ →
+ {{ map.lat_bottom_right|latitude }}, {{ map.lon_bottom_right|longitude }}
+ ({{ map|bbox_km }})
+ |
{% endif %}
{% if map.get_thumbnail %}
diff --git a/www/maposmatic/templatetags/extratags.py b/www/maposmatic/templatetags/extratags.py
index 72b7d6bb..6af2b632 100644
--- a/www/maposmatic/templatetags/extratags.py
+++ b/www/maposmatic/templatetags/extratags.py
@@ -30,6 +30,8 @@ from django.utils.translation import ugettext_lazy as _
import www.settings
+import ocitysmap
+
register = template.Library()
def job_status_to_str(value, arg, autoescape=None):
@@ -67,9 +69,45 @@ def file_basename(value):
def add_blank_after_comma(value):
return value.replace(",",", ")
+def _dd2dms(value):
+ degrees = abs(int(value))
+ minsec = value - degrees
+ minutes = int(minsec * 60)
+ seconds = (minsec % 60) / float(3600)
+
+ return (degrees, minutes, seconds)
+
+def latitude(value):
+ latitude = float(value)
+ (degrees, minutes, seconds) = _dd2dms(latitude)
+ hemisphere = 'N' if latitude >= 0 else 'S'
+
+ return "%d°%d'%d\"%s" % (degrees, minutes, seconds, hemisphere)
+
+def longitude(value):
+ latitude = float(value)
+ (degrees, minutes, seconds) = _dd2dms(latitude)
+ hemisphere = 'E' if latitude >= 0 else 'W'
+
+ return "%d°%d'%d\"%s" % (degrees, minutes, seconds, hemisphere)
+
+def bbox_km(value):
+ boundingbox = ocitysmap.coords.BoundingBox(
+ value.lat_upper_left,
+ value.lon_upper_left,
+ value.lat_bottom_right,
+ value.lon_bottom_right)
+
+ (height, width) = boundingbox.spheric_sizes()
+
+ return "ca. %d x %d km²" % (width/1000, height/1000)
+
register.filter('job_status_to_str', job_status_to_str)
register.filter('feedparsed', feedparsed)
register.filter('abs', lambda x: abs(x))
register.filter('getitem', lambda d,i: d.get(i,''))
register.filter('file_basename', file_basename)
register.filter('add_blank_after_comma', add_blank_after_comma)
+register.filter('latitude', latitude)
+register.filter('longitude', longitude)
+register.filter('bbox_km', bbox_km)
|