-
Notifications
You must be signed in to change notification settings - Fork 0
/
bike-child-transporter.brf
387 lines (331 loc) · 12.7 KB
/
bike-child-transporter.brf
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# *** The trekking profile is for slow travel
# *** and avoiding car traffic, but still with
# *** a focus on approaching your destination
# *** efficiently.
---context:global # following code refers to global config
# Use the following switches to change behaviour
# (1=yes, 0=no):
assign consider_elevation = true # set to false to ignore elevation in routing
assign allow_steps = false # set to false to disallow steps
assign allow_ferries = true # set to false to disallow ferries
assign ignore_cycleroutes = false # set to true for better elevation results
assign stick_to_cycleroutes = false # set to true to just follow cycleroutes
assign avoid_unsafe = true # set to true to avoid standard highways
assign lcn_exceptions = true # set to ture to avoid low-quality ways even if they are part of a cycleroute
assign turnInstructionMode = 1 # %turnInstructionMode% | Mode for the generated turn instructions | [0=none, 1=auto-choose, 2=locus-style, 3=osmand-style, 4=comment-style, 5=gpsies-style, 6=oruxmaps-style]
assign turnInstructionCatchingRange = 10
assign validForBikes = true
# the elevation parameters
assign downhillcost = if consider_elevation then 60 else 0
assign downhillcutoff = 1.5
assign uphillcost = if consider_elevation then 60 else 0
assign uphillcutoff = 1.5
# classifier constants
assign classifier_none = 1
assign classifier_ferry = 2
---context:way # following code refers to way-tags
#
# include smoothness= for track analysis
#
assign dummyUsage = smoothness=
#
# pre-calculate some logical expressions
#
assign any_cycleroute =
if route_bicycle_icn=yes then true
else if route_bicycle_ncn=yes then true
else if route_bicycle_rcn=yes then true
else if route_bicycle_lcn=yes then true
else false
assign nodeaccessgranted =
if any_cycleroute then true
else lcn=yes
assign is_ldcr =
if ignore_cycleroutes then false
else any_cycleroute
assign isbike = or or bicycle=permissive bicycle=designated lcn=yes
assign ispaved = surface=paved|asphalt|concrete|paving_stones
assign isunpaved = not or surface= or ispaved surface=fine_gravel|cobblestone
assign probablyGood = or ispaved and isbike not isunpaved
#
# this is the cost (in Meter) for a 90-degree turn
# The actual cost is calculated as turncost*cos(angle)
# (Suppressing turncost while following longdistance-cycleways
# makes them a little bit more magnetic)
#
assign turncost = if is_ldcr then 0
else if junction=roundabout then 0
else 150
#
# for any change in initialclassifier, initialcost is added once
#
assign initialclassifier =
if route=ferry then classifier_ferry
else classifier_none
#
# calculate the initial cost
# this is added to the total cost each time the costfactor
# changed
#
assign initialcost =
if ( equal initialclassifier classifier_ferry ) then 10000
else 0
#
# implicit access here just from the motorroad tag
# (implicit access rules from highway tag handled elsewhere)
#
assign defaultaccess =
if access= then not motorroad=yes
else if access=private|no then false
else true
#
# calculate logical bike access
#
assign bikeaccess =
if any_cycleroute then true
else if bicycle= then
(
if vehicle= then defaultaccess
else not vehicle=private|no
)
else not bicycle=private|no|dismount
#
# calculate logical foot access
#
assign footaccess =
if bikeaccess then true
else if bicycle=dismount then true
else if foot= then defaultaccess
else not foot=private|no
#
# if not bike-, but foot-acess, just a moderate penalty,
# otherwise access is forbidden
#
assign accesspenalty =
if bikeaccess then 0
else if footaccess then 4
else 10000
#
# handle one-ways. On primary roads, wrong-oneways should
# be close to forbidden, while on other ways we just add
# 4 to the costfactor (making it at least 5 - you are allowed
# to push your bike)
#
assign badoneway =
if reversedirection=yes then
if oneway:bicycle=yes then true
else if oneway= then junction=roundabout
else oneway=yes|true|1
else oneway=-1
assign onewaypenalty =
if ( badoneway ) then
(
if ( cycleway=opposite|opposite_lane|opposite_track ) then 0
else if ( oneway:bicycle=no ) then 0
else if ( highway=primary|primary_link ) then 50
else if ( highway=secondary|secondary_link ) then 30
else if ( highway=tertiary|tertiary_link ) then 20
else 4.0
)
else 0.0
assign traffic_penalty =
multiply
0.5
(
if estimated_traffic_class=2 then 1
else if estimated_traffic_class=3 then 2
else if estimated_traffic_class=4 then 3
else if estimated_traffic_class=5 then 4
else if estimated_traffic_class=6 then 5
else if estimated_traffic_class=7 then 6
else 0
)
assign has_cycleway =
if ( or cycleway= or cycleway:left= cycleway:right= ) then
(
if ( cycleway=yes|lane|track|right|left|both|segregated|designated ) then 1
else if ( cycleway:left=yes|lane|track ) then
if reversedirection=yes then 1 else 0
else if ( cycleway:right=yes|lane|track ) then
if ( reversedirection=yes ) then 0 else 1
else 0
)
else 0
assign probably_no_cycleway = not has_cycleway
#
# calculate the cost-factor, which is the factor
# by which the distance of a way-segment is multiplied
# to calculate the cost of that segment. The costfactor
# must be >=1 and it's supposed to be close to 1 for
# the type of way the routing profile is searching for
#
assign costfactor =
#
# exclude rivers, rails etc.
#
if ( and highway= not route=ferry ) then 10000
#
# exclude motorways and proposed roads
#
else if ( highway=motorway|motorway_link ) then 10000
else if ( highway=proposed|abandoned|construction ) then 10000
#
# all other exclusions below (access, steps, ferries,..)
# should not be deleted by the decoder, to be available
# in voice-hint-processing
#
else min 9999
add multiply probably_no_cycleway traffic_penalty
#
# apply oneway-and access-penalties
#
add max onewaypenalty accesspenalty
#
# steps and ferries are special. Note this is handled
# before the cycleroute-switch, to be able
# to really exlude them be setting cost to infinity
#
if ( highway=steps ) then ( if allow_steps then 40 else 10000 )
else if ( route=ferry ) then ( if allow_ferries then 5.67 else 10000 )
#
# handle long-distance cycle-routes.
#
else if ( is_ldcr ) then
if ( lcn_exceptions ) then
(
if ( highway=track|path ) then #exceptions
if ( bicycle=designated ) then 1.0
else
(
if ( tracktype=grade1 ) then 1.0
else if ( tracktype=grade2 ) then ( if probablyGood then 1.2 else 2.5 )
else if ( tracktype=grade3 ) then ( if probablyGood then 1.5 else 4.5 )
else if ( tracktype=grade4 ) then ( if probablyGood then 2.0 else 6.0 )
else if ( tracktype=grade5 ) then ( if probablyGood then 3.0 else 10.0 )
else ( if probablyGood then 1.0 else 10.0 )
)
else
1.0 # ok, accept it
)
else
1.0 # always treated as perfect
else
add ( if stick_to_cycleroutes then 0.5 else 0.05 ) # everything else somewhat up
#
# some other highway types
#
if ( highway=pedestrian ) then 3
else if ( highway=bridleway ) then 5
else if ( highway=cycleway ) then 1
else if ( highway=residential|living_street ) then ( if isunpaved then 1.5 else 1 )
else if ( highway=service ) then ( if isunpaved then 1.6 else 1.3 )
#
# tracks and track-like ways are rated mainly be tracktype/grade
# But note that if no tracktype is given (mainly for road/path/footway)
# it can be o.k. if there's any other hint for quality
#
else if ( highway=track|road|path|footway ) then
if ( bicycle=designated ) then 1.0
else
(
if ( tracktype=grade1 ) then ( if probablyGood then 1.0 else 1.3 )
else if ( tracktype=grade2 ) then ( if probablyGood then 1.1 else 2.0 )
else if ( tracktype=grade3 ) then ( if probablyGood then 1.5 else 4.5 )
else if ( tracktype=grade4 ) then ( if probablyGood then 2.0 else 6.0 )
else if ( tracktype=grade5 ) then ( if probablyGood then 3.0 else 10.0 )
else ( if probablyGood then 1.0 else 10.0 )
)
#
# When avoiding unsafe ways, avoid highways without a bike hint or cycleway
#
else add ( if ( and avoid_unsafe not or has_cycleway isbike ) then 2 else 0 )
#
# actuals roads are o.k. if we have a bike hint
#
multiply 1.4
if ( highway=trunk|trunk_link ) then ( if ( or has_cycleway isbike ) then 2.5 else 10 )
else if ( highway=primary|primary_link ) then ( if ( or has_cycleway isbike ) then 2 else 5 )
else if ( highway=secondary|secondary_link ) then ( if ( or has_cycleway isbike ) then 1.8 else 3 )
else if ( highway=tertiary|tertiary_link ) then ( if ( or has_cycleway isbike ) then 1.6 else 2.8 )
else if ( highway=unclassified ) then ( if ( or has_cycleway isbike ) then 1.3 else 2.0 )
#
# default for any other highway type not handled above
#
else 10.0
# way priorities used for voice hint generation
assign priorityclassifier =
if ( highway=motorway ) then 30
else if ( highway=motorway_link ) then 29
else if ( highway=trunk ) then 28
else if ( highway=trunk_link ) then 27
else if ( highway=primary ) then 26
else if ( highway=primary_link ) then 25
else if ( highway=secondary ) then 24
else if ( highway=secondary_link ) then 23
else if ( highway=tertiary ) then 22
else if ( highway=tertiary_link ) then 21
else if ( highway=unclassified ) then 20
else if ( highway=residential|living_street ) then 6
else if ( highway=service ) then 6
else if ( highway=cycleway ) then 6
else if ( bicycle=designated ) then 6
else if ( highway=track ) then if tracktype=grade1 then 6 else 4
else if ( highway=bridleway|road|path|footway ) then 4
else if ( highway=steps ) then 2
else if ( highway=pedestrian ) then 2
else 0
# some more classifying bits used for voice hint generation...
assign isbadoneway = not equal onewaypenalty 0
assign isgoodoneway = if reversedirection=yes then oneway=-1
else if oneway= then junction=roundabout else oneway=yes|true|1
assign isroundabout = junction=roundabout
assign islinktype = highway=motorway_link|trunk_link|primary_link|secondary_link|tertiary_link
assign isgoodforcars = if greater priorityclassifier 6 then true
else if highway=residential|living_street|service then true
else if ( and highway=track tracktype=grade1 ) then true
else false
# ... encoded into a bitmask
assign classifiermask add isbadoneway
add multiply isgoodoneway 2
add multiply isroundabout 4
add multiply islinktype 8
multiply isgoodforcars 16
---context:node # following code refers to node tags
assign defaultaccess =
if access=
then
(
if barrier= then true
else
barrier=bollard|bump_gate|cycle_barrier|entrance|sump_buster
)
else
(
if access=private|no
then false
else true
)
assign bikeaccess =
or nodeaccessgranted=yes
if bicycle=
then
(
if vehicle= then defaultaccess
else
(
if vehicle=private|no then false
else true
)
)
else
(
if bicycle=private|no|dismount then false
else true
)
#assign footaccess =
# if bicycle=dismount then true
# else if foot= then defaultaccess
# else not foot=private|no
assign initialcost =
if bikeaccess then 0
else 1000000