@@ -35,6 +35,10 @@ function setup()
3535 turn_bias = 1.4 ,
3636 use_public_transport = true ,
3737
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+
3842 allowed_start_modes = Set {
3943 mode .cycling ,
4044 mode .pushing_bike
@@ -243,6 +247,27 @@ function process_node(profile, node, result)
243247 end
244248 end
245249
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+
246271 -- check if node is a traffic light
247272 result .traffic_lights = TrafficSignal .get_value (node )
248273end
@@ -299,6 +324,8 @@ function handle_bicycle_tags(profile,way,result,data)
299324
300325 bike_push_handler (profile ,way ,result ,data )
301326
327+ -- width should be after bike_push
328+ width_handler (profile ,way ,result ,data )
302329
303330 -- maxspeed
304331 limit ( result , data .maxspeed , data .maxspeed_forward , data .maxspeed_backward )
@@ -453,6 +480,27 @@ function cycleway_handler(profile,way,result,data)
453480 end
454481end
455482
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+
456504function bike_push_handler (profile ,way ,result ,data )
457505 -- pushing bikes - if no other mode found
458506 if result .forward_mode == mode .inaccessible or result .backward_mode == mode .inaccessible or
0 commit comments