@@ -36,6 +36,10 @@ function setup()
3636 turn_bias = 1.4 ,
3737 use_public_transport = true ,
3838
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+
3943 allowed_start_modes = Set {
4044 mode .cycling ,
4145 mode .pushing_bike
@@ -230,7 +234,6 @@ function setup()
230234 uselocationtags = Set {
231235 -- 'trunk'
232236 }
233-
234237 }
235238end
236239
@@ -255,6 +258,27 @@ function process_node(profile, node, result)
255258 end
256259 end
257260
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+
258282 -- check if node is a traffic light
259283 result .traffic_lights = TrafficSignal .get_value (node )
260284end
@@ -311,6 +335,8 @@ function handle_bicycle_tags(profile,way,result,data)
311335
312336 bike_push_handler (profile ,way ,result ,data )
313337
338+ -- width should be after bike_push
339+ width_handler (profile ,way ,result ,data )
314340
315341 -- maxspeed
316342 limit ( result , data .maxspeed , data .maxspeed_forward , data .maxspeed_backward )
@@ -376,10 +402,10 @@ function speed_handler(profile,way,result,data)
376402 data .way_type_allows_pushing = true
377403 elseif profile .bicycle_speeds [data .highway ] then
378404 -- regular ways
379- -- check trunk
380405 result .forward_speed = profile .bicycle_speeds [data .highway ]
381406 result .backward_speed = profile .bicycle_speeds [data .highway ]
382407 data .way_type_allows_pushing = true
408+ -- check trunk
383409 elseif profile .trunk_speeds [data .highway ] and profile .uselocationtags and profile .uselocationtags .trunk then
384410 if not way :get_location_tag (data .highway ) or way :get_location_tag (data .highway ) ~= " no" then
385411 result .forward_speed = profile .trunk_speeds [data .highway ]
@@ -472,6 +498,27 @@ function cycleway_handler(profile,way,result,data)
472498 end
473499end
474500
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+
475522function bike_push_handler (profile ,way ,result ,data )
476523 -- pushing bikes - if no other mode found
477524 if result .forward_mode == mode .inaccessible or result .backward_mode == mode .inaccessible or
0 commit comments