restore cargo bike exclusion pull/7044
This commit is contained in:
parent
041bb2b608
commit
6c7fb2a1b6
@ -36,6 +36,10 @@ function setup()
|
|||||||
turn_bias = 1.4,
|
turn_bias = 1.4,
|
||||||
use_public_transport = true,
|
use_public_transport = true,
|
||||||
|
|
||||||
|
-- Exclude narrow ways, in particular to route with cargo bike
|
||||||
|
width = nil, -- Cargo bike could 0.5 width, in meters
|
||||||
|
exclude_cargo_bike = false,
|
||||||
|
|
||||||
allowed_start_modes = Set {
|
allowed_start_modes = Set {
|
||||||
mode.cycling,
|
mode.cycling,
|
||||||
mode.pushing_bike
|
mode.pushing_bike
|
||||||
@ -230,7 +234,6 @@ function setup()
|
|||||||
uselocationtags = Set {
|
uselocationtags = Set {
|
||||||
-- 'trunk'
|
-- 'trunk'
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -255,6 +258,27 @@ function process_node(profile, node, result)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if profile.exclude_cargo_bike then
|
||||||
|
local cargo_bike = node:get_value_by_key("cargo_bike")
|
||||||
|
if cargo_bike and cargo_bike == "no" then
|
||||||
|
result.barrier = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- width
|
||||||
|
if profile.width then
|
||||||
|
-- From barrier=cycle_barrier or other barriers
|
||||||
|
local maxwidth_physical = node:get_value_by_key("maxwidth:physical")
|
||||||
|
local maxwidth_physical_meter = maxwidth_physical and Measure.parse_value_meters(maxwidth_physical) or 99
|
||||||
|
local opening = node:get_value_by_key("opening")
|
||||||
|
local opening_meter = opening and Measure.parse_value_meters(opening) or 99
|
||||||
|
local width_meter = math.min(maxwidth_physical_meter, opening_meter)
|
||||||
|
|
||||||
|
if width_meter and width_meter < profile.width then
|
||||||
|
result.barrier = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- check if node is a traffic light
|
-- check if node is a traffic light
|
||||||
result.traffic_lights = TrafficSignal.get_value(node)
|
result.traffic_lights = TrafficSignal.get_value(node)
|
||||||
end
|
end
|
||||||
@ -311,6 +335,8 @@ function handle_bicycle_tags(profile,way,result,data)
|
|||||||
|
|
||||||
bike_push_handler(profile,way,result,data)
|
bike_push_handler(profile,way,result,data)
|
||||||
|
|
||||||
|
-- width should be after bike_push
|
||||||
|
width_handler(profile,way,result,data)
|
||||||
|
|
||||||
-- maxspeed
|
-- maxspeed
|
||||||
limit( result, data.maxspeed, data.maxspeed_forward, data.maxspeed_backward )
|
limit( result, data.maxspeed, data.maxspeed_forward, data.maxspeed_backward )
|
||||||
@ -376,10 +402,10 @@ function speed_handler(profile,way,result,data)
|
|||||||
data.way_type_allows_pushing = true
|
data.way_type_allows_pushing = true
|
||||||
elseif profile.bicycle_speeds[data.highway] then
|
elseif profile.bicycle_speeds[data.highway] then
|
||||||
-- regular ways
|
-- regular ways
|
||||||
-- check trunk
|
|
||||||
result.forward_speed = profile.bicycle_speeds[data.highway]
|
result.forward_speed = profile.bicycle_speeds[data.highway]
|
||||||
result.backward_speed = profile.bicycle_speeds[data.highway]
|
result.backward_speed = profile.bicycle_speeds[data.highway]
|
||||||
data.way_type_allows_pushing = true
|
data.way_type_allows_pushing = true
|
||||||
|
-- check trunk
|
||||||
elseif profile.trunk_speeds[data.highway] and profile.uselocationtags and profile.uselocationtags.trunk then
|
elseif profile.trunk_speeds[data.highway] and profile.uselocationtags and profile.uselocationtags.trunk then
|
||||||
if not way:get_location_tag(data.highway) or way:get_location_tag(data.highway) ~= "no" then
|
if not way:get_location_tag(data.highway) or way:get_location_tag(data.highway) ~= "no" then
|
||||||
result.forward_speed = profile.trunk_speeds[data.highway]
|
result.forward_speed = profile.trunk_speeds[data.highway]
|
||||||
@ -472,6 +498,27 @@ function cycleway_handler(profile,way,result,data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function width_handler(profile,way,result,data)
|
||||||
|
if profile.exclude_cargo_bike then
|
||||||
|
local cargo_bike = way:get_value_by_key("cargo_bike")
|
||||||
|
if cargo_bike and cargo_bike == "no" then
|
||||||
|
result.forward_mode = mode.inaccessible
|
||||||
|
result.backward_mode = mode.inaccessible
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if profile.width then
|
||||||
|
local width = way:get_value_by_key("width")
|
||||||
|
if width then
|
||||||
|
local width_meter = Measure.parse_value_meters(width)
|
||||||
|
if width_meter and width_meter < profile.width then
|
||||||
|
result.forward_mode = mode.inaccessible
|
||||||
|
result.backward_mode = mode.inaccessible
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function bike_push_handler(profile,way,result,data)
|
function bike_push_handler(profile,way,result,data)
|
||||||
-- pushing bikes - if no other mode found
|
-- pushing bikes - if no other mode found
|
||||||
if result.forward_mode == mode.inaccessible or result.backward_mode == mode.inaccessible or
|
if result.forward_mode == mode.inaccessible or result.backward_mode == mode.inaccessible or
|
||||||
|
Loading…
Reference in New Issue
Block a user