From 9862c05ae61523cd1b42c7f8c64ee07ddaf4ca30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= <skunk@xover.mud.at>
Date: Sat, 30 May 2020 07:53:16 +0200
Subject: [PATCH] car_maxspeed: maxspeed=none magenta, other values blue

---
 car_maxspeed.json | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/car_maxspeed.json b/car_maxspeed.json
index b5d8102..c3da28d 100644
--- a/car_maxspeed.json
+++ b/car_maxspeed.json
@@ -32,6 +32,8 @@
             "    {% set maxspeedKmh = m[1] * 1.60934 %}",
             "    {% set maxspeed = m[1] %}",
             "    {% set unit = \"mph\" %}",
+            "  {% else %}",
+            "    {% set maxspeed = 'other' %}",
             "  {% endif %}",
             "{% endif %}",
             "",
@@ -48,6 +50,8 @@
             "    {% set maxspeedFKmh = m[1] * 1.60934 %}",
             "    {% set maxspeedF = m[1] %}",
             "    {% set unit = \"mph\" %}",
+            "  {% else %}",
+            "    {% set maxspeedF = 'other' %}",
             "  {% endif %}",
             "{% endif %}",
             "",
@@ -64,6 +68,8 @@
             "    {% set maxspeedBKmh = m[1] * 1.60934 %}",
             "    {% set maxspeedB = m[1] %}",
             "    {% set unit = \"mph\" %}",
+            "  {% else %}",
+            "    {% set maxspeedB = 'other' %}",
             "  {% endif %}",
             "{% endif %}",
             "",
@@ -75,23 +81,23 @@
             "{% set color = colorInterpolate(const.colorMap, (maxspeedKmh - const.offsetColorSpeed) / const.highestColorSpeed) %}",
             "{% endif %}",
             "",
-            "{% if maxspeedF == 'none' %}",
-            "{% set colorF = \"#0000ff\" %}",
+            "{% if const.colorOther[maxspeedF] %}",
+            "{% set colorF = const.colorOther[maxspeedF] %}",
             "{% elseif maxspeedFKmh %}",
             "{% set colorF = colorInterpolate(const.colorMap, (maxspeedFKmh - const.offsetColorSpeed) / const.highestColorSpeed) %}",
             "{% endif %}",
             "",
-            "{% if maxspeedB == 'none' %}",
-            "{% set colorB = \"#0000ff\" %}",
+            "{% if const.colorOther[maxspeedB] %}",
+            "{% set colorB = const.colorOther[maxspeedB] %}",
             "{% elseif maxspeedBKmh %}",
             "{% set colorB = colorInterpolate(const.colorMap, (maxspeedBKmh - const.offsetColorSpeed) / const.highestColorSpeed) %}",
             "{% endif %}"
         ],
         "description": [
             "{% if maxspeedF or maxspeedB %}",
-            "<span style='color: {{ colorB }}'>{{ const.colorOther[maxspeedB] ? tagTrans('maxspeed', maxspeedB) : maxspeedB|default(trans('unknown')) }}</span> / <span style='color: {{ colorF }}'>{{ const.colorOther[maxspeedF] ? tagTrans('maxspeed', maxspeedF) : maxspeedF|default(trans('unknown')) }}</span> {{ unit }}",
-            "{% elseif maxspeed %}",
-            "<span style='color: {{ color }}'>{{ const.colorOther[maxspeed] ? tagTrans('maxspeed', maxspeed) : maxspeed }} {{ unit }}</span>",
+            "<span style='color: {{ colorB }}'>{{ maxspeedB == 'other' ? attribute(tags, 'maxspeed:backward') : const.colorOther[maxspeedB] ? tagTrans('maxspeed', maxspeedB) : maxspeedB|default(trans('unknown')) }}</span> / <span style='color: {{ colorF }}'>{{ maxspeedF == 'other' ? attribute(tags, 'maxspeed:forward') : const.colorOther[maxspeedF] ? tagTrans('maxspeed', maxspeedF) : maxspeedF|default(trans('unknown')) }}</span> {{ unit }}",
+            "{% elseif maxspeed == 'other' %}",
+            "<span style='color: {{ color }}'>{{ maxspeed == 'other' ? tags.maxspeed : const.colorOther[maxspeed] ? tagTrans('maxspeed', maxspeed) : maxspeed }} {{ unit }}</span>",
             "{% elseif tags.maxspeed %}",
             "{{ tags.maxspeed }}",
             "{% else %}",
@@ -106,9 +112,9 @@
             "color": "{{ color }}",
             "text": [
                 "{% if maxspeedB or maxspeedF %}",
-                "  {% if maxspeedB %}🡸 {{ maxspeedB }} {% endif %}|{% if maxspeedF %} {{ maxspeedF }} 🡺{% endif %}       ",
+                "  {% if maxspeedB %}🡸 {{ maxspeedB == 'other' ? attribute(tags, 'maxspeed:backward') : maxspeedB }} {% endif %}|{% if maxspeedF %} {{ maxspeedF == 'other' ? attribute(tags, 'maxspeed:forward') : maxspeedF }} 🡺{% endif %}       ",
                 "{% else %}",
-                "  {{ maxspeed }}         ",
+                "  {{ maxspeed == 'other' ? tags.maxspeed : maxspeed }}         ",
                 "{% endif %}"
             ],
             "textRepeat": "1",
@@ -134,8 +140,9 @@
             "#af00af"
         ],
         "colorOther": {
-            "none": "#0000ff",
-            "walk": "#00afff"
+            "none": "#ff00ff",
+            "walk": "#00afff",
+            "other": "#0000ff"
         },
         "highestColorSpeed": 150,
         "offsetColorSpeed": 10
@@ -154,6 +161,10 @@
         "    <td>{{ markerLine(evaluate({ \"maxspeed\": \"none\" }))|raw }}</td>",
         "    <td>{{ tagTrans('maxspeed', 'none') }}</td>",
         "  </tr>",
+        "  <tr>",
+        "    <td>{{ markerLine(evaluate({ \"maxspeed\": \"other\" }))|raw }}</td>",
+        "    <td>{{ trans('other') }}</td>",
+        "  </tr>",
         "</table>",
         "<div style='display: inline-block; width: 49%;'>",
         "<table>",