From a1c25cfe7691b973a66e25aca79e3e4933feac1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Fri, 26 Oct 2018 19:27:57 +0200 Subject: [PATCH] railway-maxspeed: new category --- index.json | 3 ++ railway-maxspeed.json | 114 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 railway-maxspeed.json diff --git a/index.json b/index.json index c3eb88e90..3438f798c 100644 --- a/index.json +++ b/index.json @@ -277,6 +277,9 @@ { "id": "railway-electrification" }, + { + "id": "railway-maxspeed" + }, { "id": "railway-routes" } diff --git a/railway-maxspeed.json b/railway-maxspeed.json new file mode 100644 index 000000000..261bdcf5b --- /dev/null +++ b/railway-maxspeed.json @@ -0,0 +1,114 @@ +{ + "type": "overpass", + "name": { + "de": "Höchstgeschwindigkeiten", + "en": "Maxspeed", + "fr": "Limites de vitesse", + "hu": "Sebességkorlátozás", + "pt": "Velocidade máxima", + "pt-br": "Velocidade máxima" + }, + "query": { + "11": "way[railway=rail][railway!~'^(platform|abandoned|disused|station|proposed|subway_entrance)$'][usage~'^(main|branch)$'];", + "14": "way[railway][railway!~'^(platform|abandoned|disused|station|proposed|subway_entrance)$'];" + }, + "feature": { + "pre": [ + "{% if tags.maxspeed is not defined %}", + "{% set maxspeedKmh = null %}", + "{% set maxspeed = null %}", + "{% set unit = null %}", + "{% else %}", + "", + "{% if tags.maxspeed|matches(\"^[0-9]+$\") %}", + "{% set maxspeedKmh = tags.maxspeed %}", + "{% set maxspeed = tags.maxspeed %}", + "{% set unit = \"km/h\" %}", + "{% endif %}", + "", + "", + "{% set m = tags.maxspeed|matches(\"(^[0-9]+) mph$\") %}", + "{% if m %}", + "{% set maxspeedKmh = m[1] * 1.60934 %}", + "{% set maxspeed = m[1] %}", + "{% set unit = \"mph\" %}", + "{% endif %}", + "", + "{% endif %}", + "", + "{% if not maxspeedKmh %}", + "{% set color = \"#404040\" %}", + "{% else %}", + "{% 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 %}" + ], + "markerSymbol": null, + "listMarkerSymbol": "line", + "style": { + "width": "3", + "color": "{{ color }}" + } + }, + "const": { + "colorMap": [ + "#00af00", + "#ff7f00", + "#ff0000", + "#af00af" + ], + "highestColorSpeed": 300, + "offsetColorSpeed": 20 + }, + "info": [ + "
", + "", + " ", + " ", + " ", + " ", + "{% for i in range(25, 280, 25) %}", + " ", + " ", + " ", + " ", + "{% endfor %}", + " ", + " ", + " ", + " ", + "
{{ markerLine(evaluate({}))|raw }}{{ trans('unknown') }}
{{ markerLine(evaluate({ \"maxspeed\": i }))|raw }}{{ i }}km/h
{{ markerLine(evaluate({ \"maxspeed\": 300 }))|raw }}≥300km/h
", + "
", + "", + "
", + "", + " ", + " ", + " ", + " ", + "{% for i in range(15, 150, 15) %}", + " ", + " ", + " ", + " ", + "{% endfor %}", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "
{{ markerLine(evaluate({}))|raw }}{{ trans('unknown') }}
{{ markerLine(evaluate({ \"maxspeed\": (i * 1.60934)|round }))|raw }}{{ i }}mph
{{ markerLine(evaluate({ \"maxspeed\": (175 * 1.60934)|round }))|raw }}175mph
{{ markerLine(evaluate({ \"maxspeed\": (200 * 1.60934)|round }))|raw }}≥200mph
", + "
" + ] +}