From e4ad01f1ce3408e295e1110191f273dd2ba96326 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= <skunk@xover.mud.at>
Date: Fri, 3 Aug 2018 21:04:56 +0200
Subject: [PATCH] railway-routes: color routes by operator

---
 railway-routes.json | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/railway-routes.json b/railway-routes.json
index 881d2d2..c3e928f 100644
--- a/railway-routes.json
+++ b/railway-routes.json
@@ -8,16 +8,22 @@
     },
     "members": true,
     "feature": {
-        "listMarkerSymbol": "{{ markerLine({ 'width': 4, 'color': '#ff0000' })|raw }}",
+        "pre": "{% set color = '#' ~ tags.operator|default('')|md5|slice(0, 6) %}",
+        "listMarkerSymbol": "{{ markerLine({ 'width': 4, 'color': color })|raw }}",
         "description": "{{ tags.operator }}",
         "title": "{% if tags.ref and tags.name %}{{ tags.ref }} - {{ tags.name }}{% elseif tags.ref %}{{ tags.ref }}{% elseif tags.name %}{{ tags.name }}{% else %}{{ trans('unnamed') }}{% endif %}",
-        "styles": ""
+        "styles": "",
+        "markerSymbol": ""
     },
     "memberFeature": {
         "pre": [
             "{% set refs = [] %}",
+            "{% set color = '#d41d8c' %}",
             "",
             "{% for master in masters %}",
+            "  {% if master.tags.operator %}",
+            "    {% set color = '#' ~ master.tags.operator|md5|slice(0, 6) %}",
+            "  {% endif %}",
             "  {% if master.tags.ref %}",
             "    {% set refs = refs|merge([ master.tags.ref ]) %}",
             "  {% endif %}",
@@ -28,13 +34,14 @@
             "<h4>Routes</h4>",
             "<ul>",
             "{% for master in masters %}",
-            "  <li data-object=\"{{ master.id }}\"><b>{{ master.tags.name|default(master.tags.ref) }}</b>{% if master.tags.network %} <i>{{ tagTrans('network', master.tags.network) }}</i>{% endif %}</li>",
+            "  {% set _color = '#' ~ master.tags.operator|default('')|md5|slice(0, 6) %}",
+            "  <li data-object=\"{{ master.id }}\" style='list-style: none;'>{{ markerLine({ width: 4, color: _color })|raw }}<b>{{ master.tags.name|default(master.tags.ref) }}</b>{% if master.tags.network %} <i>{{ master.tags.operator }}</i>{% endif %}</li>",
             "{% endfor %}",
             "</ul>"
         ],
         "listExclude": "1",
         "style": {
-            "color": "#ff0000",
+            "color": "{{ color }}",
             "width": 4,
             "opacity": 1,
             "text": "{{ refs|join('  ') }}             ",