From 744d1807e4b74f7964917e807f4f34bdd0ecd9ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sat, 16 Mar 2019 21:52:43 +0100 Subject: [PATCH] railway-electrification: check illegal values --- railway-electrification.json | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/railway-electrification.json b/railway-electrification.json index f54ba20..f116ad1 100644 --- a/railway-electrification.json +++ b/railway-electrification.json @@ -15,14 +15,18 @@ "feature": { "pre": [ "{% if tags.electrified and tags.electrified != 'no' %}", - " {% if tags.voltage < 1000 %}", + " {% if not tags.voltage is defined %}", + " {% set color = '#7f7f7f' %}", + " {% elseif not tags.voltage|matches('^[0-9]+$') %}", + " {% set color = '#ff0000' %}", + " {% elseif tags.voltage < 1000 %}", " {% set color = colorInterpolate([ '#00ff00', 'blue' ], tags.voltage / 1000) %}", " {% else %}", - " {% set color = colorInterpolate([ 'blue', 'red' ], (tags.voltage - 1000) / 24000) %}", + " {% set color = colorInterpolate([ 'blue', '#af0000' ], (tags.voltage - 1000) / 24000) %}", " {% endif %}", "{% else %}", - " {% set color='black' %}", - "{%endif %}", + " {% set color = 'black' %}", + "{% endif %}", "", "{% if tags.service == 'yard' or tags.service == 'siding' or tags.service == 'spur' or tags.service == 'crossover' %}", " {% set width=2 %}", @@ -67,7 +71,7 @@ "opacity": "1", "fill": null, "dashArray": [ - "{% if not tags.electrified or tags.electrified == 'no' %}", + "{% if not tags.electrified is defined %}", "{% elseif tags.frequency == 0 %}", "{% else %}", "5,2", @@ -97,7 +101,7 @@ "{% endfor %}", "", "{% for i in range(3000, 25000, 2000) %}", - " {% set color = colorInterpolate([ 'blue', 'red' ], (i - 1000) / 24000) %}", + " {% set color = colorInterpolate([ 'blue', '#af0000' ], (i - 1000) / 24000) %}", " ", " {{ markerLine({ 'width': 3, 'color': color })|raw }}", " {{ i }}V", @@ -113,6 +117,16 @@ " {{ markerLine({ 'styles': [ 'casing', 'default' ], 'style:casing': { 'width': 3, 'color': 'white' }, 'style': { 'width': '3', 'dashArray': '5,2', 'lineCap': 'butt', 'color': color } })|raw }}", " {{ trans('alternating current') }}", " ", + "", + " ", + " {{ markerLine({ 'width': 3, 'color': '#7f7f7f' })|raw }}", + " {{ trans('unknown') }}", + " ", + "", + " ", + " {{ markerLine({ 'width': 3, 'color': '#ff0000' })|raw }}", + " {{ trans('illegal value') }}", + " ", "" ] }