-
Notifications
You must be signed in to change notification settings - Fork 11
/
cycleway_width.yaml
266 lines (255 loc) · 9.03 KB
/
cycleway_width.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
query: |
(
way[highway=cycleway];
way[highway=path][bicycle][bicycle!=no];
way["cycleway:width"];
way["cycleway:left"]["cycleway:left"!~"(no|separate)"];
way["cycleway:right"]["cycleway:right"!~"(no|separate)"];
way["cycleway:both"]["cycleway:both"!~"(no|separate)"];
)
feature:
pre: |
{% set driving_side = 'right' %}
{% set type = tags.highway %}
{% if tags.highway == 'path' and tags.bicycle and tags.bicycle != 'no' %}
{% set type = 'cycleway' %}
{% endif %}
{% set width = attribute(tags, 'cycleway:width')|default(tags.width) %}
{% if width matches "/'$/" %}
{% set width = (width|slice(0, -1)) * 0.3048 %}
{% endif %}
{% set leftCycle = attribute(tags, 'cycleway:left')|default(attribute(tags, 'cycleway:both')) %}
{% if leftCycle in ['no', 'separate'] %}
{% set leftCycle = '' %}
{% endif %}
{% set leftOneway = attribute(tags, 'cycleway:left:oneway')|default(attribute(tags, 'cycleway:both:oneway')) %}
{% if not leftOneway or leftOneway in ['yes'] %}
{% set leftOneway = driving_side ? -1 : 1 %}
{% elseif leftOneway in ['no'] %}
{% set leftOneway = 0 %}
{% endif %}
{% set leftWidth = attribute(tags, 'cycleway:left:width')|default(attribute(tags, 'cycleway:both:width')) %}
{% if leftWidth matches "/'$/" %}
{% set leftWidth = (leftWidth|slice(0, -1)) * 0.3048 %}
{% endif %}
{% set rightCycle = attribute(tags, 'cycleway:right')|default(attribute(tags, 'cycleway:both')) %}
{% if rightCycle in ['no', 'separate'] %}
{% set rightCycle = '' %}
{% endif %}
{% set rightOneway = attribute(tags, 'cycleway:right:oneway')|default(attribute(tags, 'cycleway:both:oneway')) %}
{% if not rightOneway or rightOneway in ['yes'] %}
{% set rightOneway = driving_side ? 1 : -1 %}
{% elseif rightOneway in ['no'] %}
{% set rightOneway = 0 %}
{% endif %}
{% set rightWidth = attribute(tags, 'cycleway:right:width')|default(attribute(tags, 'cycleway:both:width')) %}
{% if rightWidth matches "/'$/" %}
{% set rightWidth = (rightWidth|slice(0, -1)) * 0.3048 %}
{% endif %}
styles: default{% if leftCycle %},left{% endif %}{% if rightCycle %},right{% endif %}
style:
width: 4
opacity: |
{{ type == 'cycleway' or attribute(tags, 'cycleway:width') ? 1 : 0 }}
color: |
{% set minWidth = tags.oneway in ['yes', 1, -1] ? const.minWidthOneway : const.minWidthBoth %}
{% set optWidth = tags.oneway in ['yes', 1, -1] ? const.optWidthOneway : const.optWidthBoth %}
{% if width %}
{{ colorInterpolate(const.colorScheme, (width - minWidth) / (optWidth - minWidth)) }}
{% else %}{{ const.unknownColor }}
{% endif %}
lineCap: |
{{ tags.oneway in ['yes', 1, -1] ? 'butt' : 'round' }}
dashArray: |
{{ tags.oneway in ['yes', 1, -1] ? '27,8' : '' }}
dashOffset: |
{{ tags.oneway in [-1] ? 28 : 0 }}
noClip: |
{{ tags.oneway in ['yes', 1, -1] }}
pattern: |
{% if type == 'cycleway' or attribute(tags, 'cycleway:width') %}
{% if tags.oneway in ['yes', 1, -1] %}arrowHead{% endif %}
{% endif %}
pattern-offset: |
{{ tags.oneway in [-1] ? 4 : 30.5 }}
pattern-repeat: 35
pattern-polygon: true
pattern-pixelSize: 9
pattern-angleCorrection: |
{{ tags.oneway in [-1] ? 180 : 0 }}
pattern-path-width: 0
pattern-path-color: |
{% if width %}
{{ colorInterpolate(const.colorScheme, (width - minWidth) / (optWidth - minWidth)) }}
{% else %}{{ const.unknownColor }}
{% endif %}
pattern-path-fillOpacity: 1
style:left:
offset: -5
width: |
{{ leftCycle in ['no', 'separate'] ? 0 : 3 }}
color: |
{% set minWidth = const.minWidthOneway %}
{% set optWidth = const.optWidthOneway %}
{% if leftWidth %}
{{ colorInterpolate(const.colorScheme, (leftWidth - minWidth) / (optWidth - minWidth)) }}
{% else %}{{ const.unknownColor }}
{% endif %}
lineCap: |
{{ leftOneway ? 'butt' : 'round' }}
dashArray: |
{{ leftOneway ? '27,8' : '' }}
dashOffset: |
{{ leftOneway in [-1] ? 28 : 0 }}
noClip: |
{{ leftOneway }}
pattern: |
{% if leftOneway %}arrowHead{% endif %}
pattern-offset: |
{{ leftOneway == -1 ? 4 : 30.5 }}
pattern-lineOffset: -5
pattern-repeat: 35
pattern-polygon: true
pattern-pixelSize: 9
pattern-angleCorrection: |
{{ leftOneway == -1 ? 180 : 0 }}
pattern-path-width: 0
pattern-path-color: |
{% if leftWidth %}
{{ colorInterpolate(const.colorScheme, (leftWidth - minWidth) / (optWidth - minWidth)) }}
{% else %}{{ const.unknownColor }}
{% endif %}
pattern-path-fillOpacity: 1
style:right:
offset: 5
width: |
{{ rightCycle in ['no', 'separate'] ? 0 : 3 }}
color: |
{% set minWidth = const.minWidthOneway %}
{% set optWidth = const.optWidthOneway %}
{% if rightWidth %}
{{ colorInterpolate(const.colorScheme, (rightWidth - minWidth) / (optWidth - minWidth)) }}
{% else %}{{ const.unknownColor }}
{% endif %}
lineCap: |
{{ rightOneway ? 'butt' : 'round' }}
dashArray: |
{{ rightOneway ? '27,8' : '' }}
dashOffset: |
{{ rightOneway in [-1] ? 28 : 0 }}
noClip: |
{{ rightOneway }}
pattern: |
{% if rightOneway %}arrowHead{% endif %}
pattern-offset: |
{{ rightOneway == -1 ? 4 : 30.5 }}
pattern-lineOffset: 5
pattern-repeat: 35
pattern-polygon: true
pattern-pixelSize: 9
pattern-angleCorrection: |
{{ rightOneway == -1 ? 180 : 0 }}
pattern-path-width: 0
pattern-path-color: |
{% if rightWidth %}
{{ colorInterpolate(const.colorScheme, (rightWidth - minWidth) / (optWidth - minWidth)) }}
{% else %}{{ const.unknownColor }}
{% endif %}
pattern-path-fillOpacity: 1
markerSymbol: false
listMarkerSymbol: line
description: |
{{ tagTrans('highway', type) }}
details: |
{% if not attribute(tags, 'cycleway:width') %}
{% elseif attribute(tags, 'cycleway:width') matches "/'$/" %}
{{ attribute(tags, 'cycleway:width') }}
{% else %}
{{ attribute(tags, 'cycleway:width') }}m
{% endif %}
body: |
<ul>
{% if type in ['cycleway'] or attribute(tags, 'cycleway:width') %}
<li>
{{ keyTrans('cycleway:width') }}:
{% if not attribute(tags, 'cycleway:width') %}
{{ trans('unknown') }}
{% elseif attribute(tags, 'cycleway:width') matches "/(m|')$/" %}
{{ attribute(tags, 'cycleway:width') }}
{% else %}
{{ attribute(tags, 'cycleway:width') }}m
{% endif %}
</li>
{% endif %}
{% if leftCycle %}
<li>{{ keyTrans('cycleway:left') }}:<ul>
<li>{{ keyTrans('cycleway') }}: {{ tagTrans('cycleway', attribute(tags, 'cycleway:left')|default(attribute(tags, 'cycleway:both'))) }}</li>
<li>
{{ keyTrans('cycleway:width') }}:
{% if not leftWidth %}
{{ trans('unknown') }}
{% elseif attribute(tags, 'cycleway:left:width')|default(attribute(tags, 'cycleway:both:width')) matches "/(m|')$/" %}
{{ attribute(tags, 'cycleway:left:width')|default(attribute(tags, 'cycleway:both:width')) }}
{% else %}
{{ leftWidth }}m
{% endif %}
</li>
</ul></li>
{% endif %}
{% if rightCycle %}
<li>{{ keyTrans('cycleway:right') }}:<ul>
<li>{{ keyTrans('cycleway') }}: {{ tagTrans('cycleway', attribute(tags, 'cycleway:right')|default(attribute(tags, 'cycleway:both'))) }}</li>
<li>
{{ keyTrans('cycleway:width') }}:
{% if not rightWidth %}
{{ trans('unknown') }}
{% elseif attribute(tags, 'cycleway:right:width')|default(attribute(tags, 'cycleway:both:width')) matches "/(m|')$/" %}
{{ attribute(tags, 'cycleway:right:width')|default(attribute(tags, 'cycleway:both:width')) }}
{% else %}
{{ rightWidth }}m
{% endif %}
</li>
</ul></li>
{% endif %}
</ul>
info: |
<table>
<tr>
<th>Symbol</th>
<th>{{ keyTrans('oneway') }}={{ tagTrans('oneway', 'yes') }}</th>
<th>{{ keyTrans('oneway') }}={{ tagTrans('oneway', 'no') }}</th>
</tr>
<tr>
<td>
{{ markerLine({ width: 4, color: const.unknownColor }) }}
</td>
<td>
{{ trans('unknown') }}
</td>
<td>
{{ trans('unknown') }}
</td>
</tr>
{% for v in range(0, 1, 0.25) %}
<tr>
<td>
{{ markerLine({ width: 4, color: colorInterpolate(const.colorScheme, v) }) }}
</td>
<td>
{% if v == 0 %}<={% elseif v == 1 %}>={% endif %}
{{ (const.minWidthOneway + (v * (const.optWidthOneway - const.minWidthOneway)))|number_format(2) }}m
</td>
<td>
{% if v == 0 %}<={% elseif v == 1 %}>={% endif %}
{{ (const.minWidthBoth + (v * (const.optWidthBoth - const.minWidthBoth)))|number_format(2) }}m
</td>
</tr>
{% endfor %}
</table>
const:
minWidthBoth: 1.5
optWidthBoth: 5
minWidthOneway: 0.75
optWidthOneway: 3
colorScheme: ['#ff0000', '#ff00ff', '#0000ff']
unknownColor: black