From 45250b6652c4558dd63eefdbb1f6f569f28b27e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sat, 16 Mar 2019 21:52:27 +0100 Subject: [PATCH] railway-gauge: check illegal values --- railway-gauge.json | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/railway-gauge.json b/railway-gauge.json index 090a5d02..da217cb0 100644 --- a/railway-gauge.json +++ b/railway-gauge.json @@ -24,38 +24,43 @@ "styles": "{% if gauges|length < 2 %}default{% else %}{% for i, v in gauges %}{% if i != 0 %},{% endif %}gauge{{ i }}{% endfor %}{% endif %}", "style": { "width": "3", - "color": "{% if tags.gauge %}{{ colorInterpolate([ '#00ff00', '#0000ff' ], gauges[0] / 2000) }}{% else %}#404040{% endif %}" + "color": "{% if tags.gauge %}{% if not tags.gauge|matches('^\\d+$') %}#ff0000{% else %}{{ colorInterpolate([ '#00ff00', '#0000ff' ], tags.gauge / 2000) }}{% endif %}{% else %}#404040{% endif %}" }, "style:gauge0": { "width": "3", "lineCap": "butt", - "color": "{{ colorInterpolate([ '#00ff00', '#0000ff' ], gauges[0] / 2000) }}", + "color": "{% if not gauges[0]|matches('^[0-9]+$') %}#ff0000{% else %}{{ colorInterpolate([ '#00ff00', '#0000ff' ], gauges[0] / 2000) }}{% endif %}", "dashArray": "5,{{ (gauges|length - 1) * 5 }}" }, "style:gauge1": { "width": "3", "lineCap": "butt", - "color": "{{ colorInterpolate([ '#00ff00', '#0000ff' ], gauges[1] / 2000) }}", + "color": "{% if not gauges[1]|matches('^[0-9]+$') %}#ff0000{% else %}{{ colorInterpolate([ '#00ff00', '#0000ff' ], gauges[1] / 2000) }}{% endif %}", "dashArray": "5,{{ (gauges|length - 1) * 5 }}", "dashOffset": "5" }, "style:gauge2": { "width": "3", "lineCap": "butt", - "color": "{{ colorInterpolate([ '#00ff00', '#0000ff' ], gauges[2] / 2000) }}", + "color": "{% if not gauges[2]|matches('^\\d+$') %}#ff0000{% else %}{{ colorInterpolate([ '#00ff00', '#0000ff' ], gauges[2] / 2000) }}{% endif %}", "dashArray": "5,{{ (gauges|length - 1) * 5 }}", "dashOffset": "10" }, "style:gauge3": { "width": "3", "lineCap": "butt", - "color": "{{ colorInterpolate([ '#00ff00', '#0000ff' ], gauges[3] / 2000) }}", + "color": "{% if not gauges[3]|matches('^\\d+$') %}#ff0000{% else %}{{ colorInterpolate([ '#00ff00', '#0000ff' ], gauges[3] / 2000) }}{% endif %}", "dashArray": "5,{{ (gauges|length - 1) * 5 }}", "dashOffset": "15" } }, "info": [ "", + " {% set color = '#ff0000' %}", + " ", + " ", + " ", + " ", " {% set color = '#404040' %}", " ", " ",
{{ markerLine({ 'width': 3, 'color': color })|raw }}{{ trans('illegal value') }}
{{ markerLine({ 'width': 3, 'color': color })|raw }}