@@ -36,6 +36,10 @@ function setup()
36
36
turn_bias = 1.4 ,
37
37
use_public_transport = true ,
38
38
39
+ -- Exclude narrow ways, in particular to route with cargo bike
40
+ width = nil , -- Cargo bike could 0.5 width, in meters
41
+ exclude_cargo_bike = false ,
42
+
39
43
allowed_start_modes = Set {
40
44
mode .cycling ,
41
45
mode .pushing_bike
@@ -230,7 +234,6 @@ function setup()
230
234
uselocationtags = Set {
231
235
-- 'trunk'
232
236
}
233
-
234
237
}
235
238
end
236
239
@@ -255,6 +258,27 @@ function process_node(profile, node, result)
255
258
end
256
259
end
257
260
261
+ if profile .exclude_cargo_bike then
262
+ local cargo_bike = node :get_value_by_key (" cargo_bike" )
263
+ if cargo_bike and cargo_bike == " no" then
264
+ result .barrier = true
265
+ end
266
+ end
267
+
268
+ -- width
269
+ if profile .width then
270
+ -- From barrier=cycle_barrier or other barriers
271
+ local maxwidth_physical = node :get_value_by_key (" maxwidth:physical" )
272
+ local maxwidth_physical_meter = maxwidth_physical and Measure .parse_value_meters (maxwidth_physical ) or 99
273
+ local opening = node :get_value_by_key (" opening" )
274
+ local opening_meter = opening and Measure .parse_value_meters (opening ) or 99
275
+ local width_meter = math.min (maxwidth_physical_meter , opening_meter )
276
+
277
+ if width_meter and width_meter < profile .width then
278
+ result .barrier = true
279
+ end
280
+ end
281
+
258
282
-- check if node is a traffic light
259
283
result .traffic_lights = TrafficSignal .get_value (node )
260
284
end
@@ -311,6 +335,8 @@ function handle_bicycle_tags(profile,way,result,data)
311
335
312
336
bike_push_handler (profile ,way ,result ,data )
313
337
338
+ -- width should be after bike_push
339
+ width_handler (profile ,way ,result ,data )
314
340
315
341
-- maxspeed
316
342
limit ( result , data .maxspeed , data .maxspeed_forward , data .maxspeed_backward )
@@ -376,10 +402,10 @@ function speed_handler(profile,way,result,data)
376
402
data .way_type_allows_pushing = true
377
403
elseif profile .bicycle_speeds [data .highway ] then
378
404
-- regular ways
379
- -- check trunk
380
405
result .forward_speed = profile .bicycle_speeds [data .highway ]
381
406
result .backward_speed = profile .bicycle_speeds [data .highway ]
382
407
data .way_type_allows_pushing = true
408
+ -- check trunk
383
409
elseif profile .trunk_speeds [data .highway ] and profile .uselocationtags and profile .uselocationtags .trunk then
384
410
if not way :get_location_tag (data .highway ) or way :get_location_tag (data .highway ) ~= " no" then
385
411
result .forward_speed = profile .trunk_speeds [data .highway ]
@@ -472,6 +498,27 @@ function cycleway_handler(profile,way,result,data)
472
498
end
473
499
end
474
500
501
+ function width_handler (profile ,way ,result ,data )
502
+ if profile .exclude_cargo_bike then
503
+ local cargo_bike = way :get_value_by_key (" cargo_bike" )
504
+ if cargo_bike and cargo_bike == " no" then
505
+ result .forward_mode = mode .inaccessible
506
+ result .backward_mode = mode .inaccessible
507
+ end
508
+ end
509
+
510
+ if profile .width then
511
+ local width = way :get_value_by_key (" width" )
512
+ if width then
513
+ local width_meter = Measure .parse_value_meters (width )
514
+ if width_meter and width_meter < profile .width then
515
+ result .forward_mode = mode .inaccessible
516
+ result .backward_mode = mode .inaccessible
517
+ end
518
+ end
519
+ end
520
+ end
521
+
475
522
function bike_push_handler (profile ,way ,result ,data )
476
523
-- pushing bikes - if no other mode found
477
524
if result .forward_mode == mode .inaccessible or result .backward_mode == mode .inaccessible or
0 commit comments