From a715d023219ebe6407ae3f3b0dba1a86d95165df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Fri, 1 Feb 2019 19:10:50 +0100 Subject: [PATCH] buildings-height: support height tags with unit (m and ft) --- buildings-height.json | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/buildings-height.json b/buildings-height.json index 6e3851a..dc08cf3 100644 --- a/buildings-height.json +++ b/buildings-height.json @@ -18,6 +18,9 @@ "pre": [ "{% if tags.height is defined %}", "{% set approxHeight = tags.height %}", + "{% set m = tags.height|matches('(.*)\\s*(m|ft)$') %}", + "{% if m and m[2] == 'm' %}{% set approxHeight = m[1] %}{% endif %}", + "{% if m and m[2] == 'ft' %}{% set approxHeight = m[1] / 3.2808 %}{% endif %}", "{% elseif attribute(tags, 'building:levels') is defined %}", "{% set approxHeight = attribute(tags, 'building:levels') * 3.5 %}", "{% endif %}", @@ -32,10 +35,13 @@ ], "description": [ "{% if tags.height is defined %}", - "{{ tags.height }}m", - "{% endif %}", + " {% if tags.height|matches('(m|ft)$') %}{{ tags.height -}}", + " {% else %}{{ tags.height }} m", + " {%- endif -%}", + "{% endif -%}", "", - "{% if attribute(tags, 'building:levels') is defined %}", + "{%- if attribute(tags, 'building:levels') is defined -%}", + "{%- if tags.height is defined %}, {% endif %}", "{{ attribute(tags, 'building:levels') }} {{ keyTrans('building:levels') }}", "{% endif %}" ],