From 9895cd630032b96ce5132cb338c826bbe1e362fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 14 Dec 2017 13:28:08 +0100 Subject: [PATCH] car_maxspeed: Improvements: better colors, map key --- car_maxspeed.json | 61 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/car_maxspeed.json b/car_maxspeed.json index 9e31a5f..871a5fe 100644 --- a/car_maxspeed.json +++ b/car_maxspeed.json @@ -36,19 +36,76 @@ "{% if not maxspeedKmh %}", "{% set color = \"#404040\" %}", "{% else %}", - "{% set color = colorInterpolate([ 'green', 'orange', 'red' ], maxspeedKmh / 150) %}", + "{% set color = colorInterpolate(const.colorMap, (maxspeedKmh - const.offsetColorSpeed) / const.highestColorSpeed) %}", "{% endif %}" ], "description": [ "{% if maxspeed %}", "{{ maxspeed }} {{ unit }}", + "{% elseif tags.maxspeed %}", + "{{ tags.maxspeed }}", "{% else %}", "{{ trans('unknown') }}", "{% endif %}" ], "markerSign": null, + "listMarkerSymbol": "line", "style": { + "weight": "3", "color": "{{ color }}" } - } + }, + "const": { + "colorMap": [ + "#00af00", + "#ff7f00", + "#ff0000", + "#af00af" + ], + "highestColorSpeed": 150, + "offsetColorSpeed": 10 + }, + "info": [ + "
", + "", + " ", + " ", + " ", + " ", + "{% for i in range(10, 140, 20) %}", + " ", + " ", + " ", + " ", + "{% endfor %}", + " ", + " ", + " ", + " ", + "
{{ markerLine(evaluate({}))|raw }}{{ trans('unknown') }}
{{ markerLine(evaluate({ \"maxspeed\": i }))|raw }}{{ i }}km/h
{{ markerLine(evaluate({ \"maxspeed\": 150 }))|raw }}≥150km/h
", + "
", + "", + "
", + "", + " ", + " ", + " ", + " ", + "{% for i in range(10, 60, 10) %}", + " ", + " ", + " ", + " ", + "{% endfor %}", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "
{{ markerLine(evaluate({}))|raw }}{{ trans('unknown') }}
{{ markerLine(evaluate({ \"maxspeed\": (i * 1.60934)|round }))|raw }}{{ i }}mph
{{ markerLine(evaluate({ \"maxspeed\": (75 * 1.60934)|round }))|raw }}75mph
{{ markerLine(evaluate({ \"maxspeed\": (95 * 1.60934)|round }))|raw }}≥95mph
", + "
" + ] }