-
Notifications
You must be signed in to change notification settings - Fork 11
/
railway-maxspeed.yaml
164 lines (157 loc) · 5.48 KB
/
railway-maxspeed.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
type: overpass
name:
ca: Velocitat màxima de la via fèrria
cs: Maximální rychlost železnice
de: Eisenbahn Höchstgeschwindigkeiten
en: Railway Maxspeed
es: Velocidad máxima del ferrocarril
fr: Limites de vitesse
gl: Velocidade máxima do ferrocarril
hu: Sebességkorlátozás
it: Velocità ferroviaria massima
ja: 鉄道の最高速度
nb: Jernbane-fartsgrense
nl: Spoorweg snelheidslimiet
oc: Limits de velocitat
pl: Prędkość maksymalna kolei
pt: Velocidade máxima
pt-br: Velocidade máxima
ru: Максимальная скорость
tr: Demiryolu Maksimum Hızı
query:
11: way[railway=rail][railway!~'^(platform|abandoned|disused|station|proposed|subway_entrance)$'][usage~'^(main|branch)$'];
14: way[railway~'^(disused|construction|funicular|light_rail|miniature|monorail|narrow_gauge|preserved|rail|subway|tram)$'];
feature:
pre: |-
{% set maxspeedKmh = null %}
{% set maxspeed = null %}
{% set unit = null %}
{% if tags.maxspeed is defined %}
{% if tags.maxspeed|matches("^[0-9]+$") %}
{% set maxspeedKmh = tags.maxspeed %}
{% set maxspeed = tags.maxspeed %}
{% set unit = "km/h" %}
{% elseif tags.maxspeed|matches( "(^[0-9]+) mph$") %}
{% set m = tags.maxspeed|matches("(^[0-9]+) mph$") %}
{% set maxspeedKmh = m[1] * 1.60934 %}
{% set maxspeed = m[1] %}
{% set unit = "mph" %}
{% endif %}
{% endif %}
{% if attribute(tags, 'maxspeed:forward') is defined %}
{% if attribute(tags, 'maxspeed:forward')|matches("^[0-9]+$") %}
{% set maxspeedFKmh = attribute(tags, 'maxspeed:forward') %}
{% set maxspeedF = attribute(tags, 'maxspeed:forward') %}
{% set unit = "km/h" %}
{% elseif attribute(tags, 'maxspeed:forward')|matches("^[0-9]+ mph$") %}
{% set m = attribute(tags, 'maxspeed:forward')|matches("(^[0-9]+) mph$") %}
{% set maxspeedFKmh = m[1] * 1.60934 %}
{% set maxspeedF = m[1] %}
{% set unit = "mph" %}
{% endif %}
{% endif %}
{% if attribute(tags, 'maxspeed:backward') is defined %}
{% if attribute(tags, 'maxspeed:backward')|matches("^[0-9]+$") %}
{% set maxspeedBKmh = attribute(tags, 'maxspeed:backward') %}
{% set maxspeedB = attribute(tags, 'maxspeed:backward') %}
{% set unit = "km/h" %}
{% elseif attribute(tags, 'maxspeed:backward')|matches("^[0-9]+ mph$") %}
{% set m = attribute(tags, 'maxspeed:backward')|matches("(^[0-9]+) mph$") %}
{% set maxspeedBKmh = m[1] * 1.60934 %}
{% set maxspeedB = 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 %}
{% if maxspeedFKmh %}
{% set colorF = colorInterpolate(const.colorMap, (maxspeedFKmh - const.offsetColorSpeed) / const.highestColorSpeed) %}
{% endif %}
{% if maxspeedBKmh %}
{% set colorB = colorInterpolate(const.colorMap, (maxspeedBKmh - const.offsetColorSpeed) / const.highestColorSpeed) %}
{% endif %}
description: |-
{% if maxspeedF or maxspeedB %}
<span style='color: {{ colorB }}'>{{ maxspeedB|default(trans('unknown')) }}</span> / <span style='color: {{ colorF }}'>{{ maxspeedF|default(trans('unknown')) }}</span> {{ unit }}
{% elseif maxspeed %}
<span style='color: {{ color }}'>{{ maxspeed }} {{ unit }}</span>
{% elseif tags.maxspeed %}
{{ tags.maxspeed }}
{% else %}
{{ trans('unknown') }}
{% endif %}
markerSymbol: null
listMarkerSymbol: line
styles: '{% if maxspeedB or maxspeedF %}left,right,default{% else %}default{% endif %}'
style:
width: '{% if maxspeedB or maxspeedF %}0{% else %}4{% endif %}'
color: '{{ color }}'
text: |-
{% if maxspeedB or maxspeedF %}
{% if maxspeedB %}🡸 {{ maxspeedB }} {% endif %}|{% if maxspeedF %} {{ maxspeedF }} 🡺{% endif %}
{% else %}
{{ maxspeed }}
{% endif %}
textRepeat: '1'
textOffset: '4'
textFontWeight: bold
style:left:
width: '2'
color: '{{ colorB|default(''#404040'') }}'
offset: '-1'
style:right:
width: '2'
color: '{{ colorF|default(''#404040'') }}'
offset: '1'
const:
colorMap:
- '#00af00'
- '#ff7f00'
- '#ff0000'
- '#af00af'
highestColorSpeed: 300
offsetColorSpeed: 20
info: |-
<div style='display: inline-block'>
<table>
<tr>
<td>{{ markerLine(evaluate({}))|raw }}</td>
<td colspan>{{ trans('unknown') }}</td>
</tr>
{% for i in range(25, 280, 25) %}
<tr>
<td>{{ markerLine(evaluate({ "maxspeed": i }))|raw }}</td>
<td>{{ i }}km/h</td>
</tr>
{% endfor %}
<tr>
<td>{{ markerLine(evaluate({ "maxspeed": 300 }))|raw }}</td>
<td>≥300km/h</td>
</tr>
</table>
</div>
<div style='display: inline-block'>
<table>
<tr>
<td>{{ markerLine(evaluate({}))|raw }}</td>
<td colspan>{{ trans('unknown') }}</td>
</tr>
{% for i in range(15, 150, 15) %}
<tr>
<td>{{ markerLine(evaluate({ "maxspeed": (i * 1.60934)|round }))|raw }}</td>
<td>{{ i }}mph</td>
</tr>
{% endfor %}
<tr>
<td>{{ markerLine(evaluate({ "maxspeed": (175 * 1.60934)|round }))|raw }}</td>
<td>175mph</td>
</tr>
<tr>
<td>{{ markerLine(evaluate({ "maxspeed": (200 * 1.60934)|round }))|raw }}</td>
<td>≥200mph</td>
</tr>
</table>
</div>