@@ -35,6 +35,10 @@ function setup()
35
35
turn_bias = 1.4 ,
36
36
use_public_transport = true ,
37
37
38
+ -- Exclude narrow ways, in particular to route with cargo bike
39
+ width = nil , -- Cargo bike could 0.5 width, in meters
40
+ exclude_cargo_bike = false ,
41
+
38
42
allowed_start_modes = Set {
39
43
mode .cycling ,
40
44
mode .pushing_bike
@@ -243,6 +247,27 @@ function process_node(profile, node, result)
243
247
end
244
248
end
245
249
250
+ if profile .exclude_cargo_bike then
251
+ local cargo_bike = node :get_value_by_key (" cargo_bike" )
252
+ if cargo_bike and cargo_bike == " no" then
253
+ result .barrier = true
254
+ end
255
+ end
256
+
257
+ -- width
258
+ if profile .width then
259
+ -- From barrier=cycle_barrier or other barriers
260
+ local maxwidth_physical = node :get_value_by_key (" maxwidth:physical" )
261
+ local maxwidth_physical_meter = maxwidth_physical and Measure .parse_value_meters (maxwidth_physical ) or 99
262
+ local opening = node :get_value_by_key (" opening" )
263
+ local opening_meter = opening and Measure .parse_value_meters (opening ) or 99
264
+ local width_meter = math.min (maxwidth_physical_meter , opening_meter )
265
+
266
+ if width_meter and width_meter < profile .width then
267
+ result .barrier = true
268
+ end
269
+ end
270
+
246
271
-- check if node is a traffic light
247
272
result .traffic_lights = TrafficSignal .get_value (node )
248
273
end
@@ -299,6 +324,8 @@ function handle_bicycle_tags(profile,way,result,data)
299
324
300
325
bike_push_handler (profile ,way ,result ,data )
301
326
327
+ -- width should be after bike_push
328
+ width_handler (profile ,way ,result ,data )
302
329
303
330
-- maxspeed
304
331
limit ( result , data .maxspeed , data .maxspeed_forward , data .maxspeed_backward )
@@ -453,6 +480,27 @@ function cycleway_handler(profile,way,result,data)
453
480
end
454
481
end
455
482
483
+ function width_handler (profile ,way ,result ,data )
484
+ if profile .exclude_cargo_bike then
485
+ local cargo_bike = way :get_value_by_key (" cargo_bike" )
486
+ if cargo_bike and cargo_bike == " no" then
487
+ result .forward_mode = mode .inaccessible
488
+ result .backward_mode = mode .inaccessible
489
+ end
490
+ end
491
+
492
+ if profile .width then
493
+ local width = way :get_value_by_key (" width" )
494
+ if width then
495
+ local width_meter = Measure .parse_value_meters (width )
496
+ if width_meter and width_meter < profile .width then
497
+ result .forward_mode = mode .inaccessible
498
+ result .backward_mode = mode .inaccessible
499
+ end
500
+ end
501
+ end
502
+ end
503
+
456
504
function bike_push_handler (profile ,way ,result ,data )
457
505
-- pushing bikes - if no other mode found
458
506
if result .forward_mode == mode .inaccessible or result .backward_mode == mode .inaccessible or
0 commit comments