From 6648aac6b7a3f56e921a1911d26b257b6e681e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 28 May 2020 21:14:49 +0200 Subject: [PATCH] car_maxspeed: support maxspeed=none (also forward and backward) --- car_maxspeed.json | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/car_maxspeed.json b/car_maxspeed.json index 6c11f5a..7b9e568 100644 --- a/car_maxspeed.json +++ b/car_maxspeed.json @@ -21,7 +21,9 @@ "{% set unit = null %}", "", "{% if tags.maxspeed is defined %}", - " {% if tags.maxspeed|matches(\"^[0-9]+$\") %}", + " {% if tags.maxspeed == 'none' %}", + " {% set maxspeed = 'none' %}", + " {% elseif tags.maxspeed|matches(\"^[0-9]+$\") %}", " {% set maxspeedKmh = tags.maxspeed %}", " {% set maxspeed = tags.maxspeed %}", " {% set unit = \"km/h\" %}", @@ -34,7 +36,9 @@ "{% endif %}", "", "{% if attribute(tags, 'maxspeed:forward') is defined %}", - " {% if attribute(tags, 'maxspeed:forward')|matches(\"^[0-9]+$\") %}", + " {% if attribute(tags, 'maxspeed:forward') == 'none' %}", + " {% set maxspeedF = 'none' %}", + " {% elseif attribute(tags, 'maxspeed:forward')|matches(\"^[0-9]+$\") %}", " {% set maxspeedFKmh = attribute(tags, 'maxspeed:forward') %}", " {% set maxspeedF = attribute(tags, 'maxspeed:forward') %}", " {% set unit = \"km/h\" %}", @@ -47,7 +51,9 @@ "{% endif %}", "", "{% if attribute(tags, 'maxspeed:backward') is defined %}", - " {% if attribute(tags, 'maxspeed:backward')|matches(\"^[0-9]+$\") %}", + " {% if attribute(tags, 'maxspeed:backward') == 'none' %}", + " {% set maxspeedB = 'none' %}", + " {% elseif attribute(tags, 'maxspeed:backward')|matches(\"^[0-9]+$\") %}", " {% set maxspeedBKmh = attribute(tags, 'maxspeed:backward') %}", " {% set maxspeedB = attribute(tags, 'maxspeed:backward') %}", " {% set unit = \"km/h\" %}", @@ -59,25 +65,31 @@ " {% endif %}", "{% endif %}", "", - "{% if not maxspeedKmh %}", + "{% if maxspeed == 'none' %}", + "{% set color = \"#0000ff\" %}", + "{% elseif not maxspeedKmh %}", "{% set color = \"#404040\" %}", "{% else %}", "{% set color = colorInterpolate(const.colorMap, (maxspeedKmh - const.offsetColorSpeed) / const.highestColorSpeed) %}", "{% endif %}", "", - "{% if maxspeedFKmh %}", + "{% if maxspeedF == 'none' %}", + "{% set colorF = \"#0000ff\" %}", + "{% elseif maxspeedFKmh %}", "{% set colorF = colorInterpolate(const.colorMap, (maxspeedFKmh - const.offsetColorSpeed) / const.highestColorSpeed) %}", "{% endif %}", "", - "{% if maxspeedBKmh %}", + "{% if maxspeedB == 'none' %}", + "{% set colorB = \"#0000ff\" %}", + "{% elseif maxspeedBKmh %}", "{% set colorB = colorInterpolate(const.colorMap, (maxspeedBKmh - const.offsetColorSpeed) / const.highestColorSpeed) %}", "{% endif %}" ], "description": [ "{% if maxspeedF or maxspeedB %}", - "{{ maxspeedB|default(trans('unknown')) }} / {{ maxspeedF|default(trans('unknown')) }} {{ unit }}", + "{{ maxspeedB == 'none' ? tagTrans('maxspeed', 'none') : maxspeedB|default(trans('unknown')) }} / {{ maxspeedF == 'none' ? tagTrans('maxspeed', 'none') : maxspeedF|default(trans('unknown')) }} {{ unit }}", "{% elseif maxspeed %}", - "{{ maxspeed }} {{ unit }}", + "{{ maxspeed == 'none' ? tagTrans('maxspeed', 'none') : maxspeed }} {{ unit }}", "{% elseif tags.maxspeed %}", "{{ tags.maxspeed }}", "{% else %}", @@ -139,6 +151,10 @@ " {{ markerLine(evaluate({ \"maxspeed\": 150 }))|raw }}", " ≥150km/h", " ", + " ", + " {{ markerLine(evaluate({ \"maxspeed\": \"none\" }))|raw }}", + " {{ tagTrans('maxspeed', 'none') }}", + " ", "", "", "", @@ -162,6 +178,10 @@ " {{ markerLine(evaluate({ \"maxspeed\": (95 * 1.60934)|round }))|raw }}", " ≥95mph", " ", + " ", + " {{ markerLine(evaluate({ \"maxspeed\": \"none\" }))|raw }}", + " {{ tagTrans('maxspeed', 'none') }}", + " ", "", "" ]