From a56155f033c00e85fa36e4a0baf9952a95e9fccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Fri, 12 Apr 2019 14:31:16 +0200 Subject: [PATCH] railway-electrification: improve colors; set preferences via const --- railway-electrification.json | 45 +++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/railway-electrification.json b/railway-electrification.json index 7e61111..66bb031 100644 --- a/railway-electrification.json +++ b/railway-electrification.json @@ -16,18 +16,18 @@ "pre": [ "{% if tags.electrified and tags.electrified != 'no' %}", " {% if not tags.voltage is defined %}", - " {% set color = '#7f7f7f' %}", + " {% set color = const.colorUnknown %}", " {% elseif not tags.voltage|matches('^[0-9]+$') %}", - " {% set color = '#ff0000' %}", - " {% elseif tags.voltage < 1000 %}", - " {% set color = colorInterpolate([ '#00ff00', 'blue' ], tags.voltage / 1000) %}", + " {% set color = const.colorIllegal %}", + " {% elseif tags.voltage < const.range[1] %}", + " {% set color = colorInterpolate(const.scheme|slice(0, 2), tags.voltage / const.range[1]) %}", " {% else %}", - " {% set color = colorInterpolate([ 'blue', '#af0000' ], (tags.voltage - 1000) / 24000) %}", + " {% set color = colorInterpolate(const.scheme|slice(1, 2), (tags.voltage - const.range[1]) / (const.range[2] - const.range[1])) %}", " {% endif %}", "{% elseif tags.electrified and tags.electrified == 'no' %}", - " {% set color = '#000000' %}", + " {% set color = const.colorNone %}", "{% else %}", - " {% set color = '#7f7f7f' %}", + " {% set color = const.colorUnknown %}", "{% endif %}", "", "{% if tags.service == 'yard' or tags.service == 'siding' or tags.service == 'spur' or tags.service == 'crossover' %}", @@ -35,9 +35,9 @@ " {% else %}", " {% if tags.railway == 'rail' %}", " {% if tags.usage == 'main' or tags.usage == 'branch' %}", - " {% set width=3 %}", + " {% set width=4 %}", " {% else %}", - " {% set width=2.5 %}", + " {% set width=3 %}", " {% endif %}", " {% else %}", " {% set width=2 %}", @@ -84,32 +84,33 @@ "width": "{{ width }}", "color": "white", "opacity": "1", + "lineCap": "butt", "fill": null } }, "info": [ "", - " {% set color = '#000000' %}", " ", - " ", + " ", " ", " ", - "{% for i in range(0, 1000, 200) %}", - " {% set color = colorInterpolate([ '#00ff00', 'blue' ], i / 1000) %}", + "{% for i in range(0, const.range[1], const.infoSteps[0]) %}", + " {% set color = colorInterpolate(const.scheme|slice(0, 2), i / const.range[1]) %}", " ", " ", " ", " ", "{% endfor %}", "", - "{% for i in range(3000, 25000, 2000) %}", - " {% set color = colorInterpolate([ 'blue', '#af0000' ], (i - 1000) / 24000) %}", + "{% for i in range(const.range[1] + const.infoSteps[1], const.range[2], const.infoSteps[1]) %}", + " {% set color = colorInterpolate(const.scheme|slice(1, 2), (i - const.range[1]) / (const.range[2] - const.range[1])) %}", " ", " ", " ", " ", "{% endfor %}", "", + "{% set color = const.scheme[1] %}", " ", " ", " ", @@ -121,14 +122,22 @@ " ", "", " ", - " ", + " ", " ", " ", "", " ", - " ", + " ", " ", " ", "
{{ markerLine({ 'width': 3, 'color': color })|raw }}{{ markerLine({ 'width': 3, 'color': const.colorNone })|raw }}{{ trans('not electrified') }}
{{ markerLine({ 'width': 3, 'color': color })|raw }}{{ i }}V
{{ markerLine({ 'width': 3, 'color': color })|raw }}{{ i }}V
{{ markerLine({ 'width': 3, 'color': color })|raw }}{{ trans('tag:frequency=0') }}
{{ markerLine({ 'width': 3, 'color': '#7f7f7f' })|raw }}{{ markerLine({ 'width': 3, 'color': const.colorUnknown })|raw }}{{ trans('unknown') }}
{{ markerLine({ 'width': 3, 'color': '#ff0000' })|raw }}{{ markerLine({ 'width': 3, 'color': const.colorIllegal })|raw }}{{ trans('illegal value') }}
" - ] + ], + "const": { + "range": [ 0, 1000, 25000 ], + "infoSteps": [ 200, 2000 ], + "scheme": [ "#00ff00", "#003fff", "#af0000" ], + "colorNone": "orange", + "colorUnknown": "#404040", + "colorIllegal": "#ff0000" + } }