Support trunk access for some countries
This commit is contained in:
+19
-48
@@ -27,6 +27,7 @@ function setup()
|
||||
mode_change_penalty = 30,
|
||||
},
|
||||
|
||||
profile = 'bicycle',
|
||||
default_mode = mode.cycling,
|
||||
default_speed = default_speed,
|
||||
walking_speed = walking_speed,
|
||||
@@ -35,10 +36,6 @@ function setup()
|
||||
turn_bias = 1.4,
|
||||
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 {
|
||||
mode.cycling,
|
||||
mode.pushing_bike
|
||||
@@ -140,6 +137,11 @@ function setup()
|
||||
path = 13
|
||||
},
|
||||
|
||||
trunk_speeds = {
|
||||
trunk = default_speed,
|
||||
trunk_link = default_speed,
|
||||
},
|
||||
|
||||
pedestrian_speeds = {
|
||||
footway = walking_speed,
|
||||
pedestrian = walking_speed,
|
||||
@@ -220,9 +222,15 @@ function setup()
|
||||
|
||||
avoid = Set {
|
||||
'impassable',
|
||||
'motorroad',
|
||||
'construction',
|
||||
'proposed'
|
||||
},
|
||||
|
||||
uselocationtags = Set {
|
||||
-- 'trunk'
|
||||
}
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
@@ -247,27 +255,6 @@ function process_node(profile, node, result)
|
||||
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
|
||||
result.traffic_lights = TrafficSignal.get_value(node)
|
||||
end
|
||||
@@ -324,8 +311,6 @@ function handle_bicycle_tags(profile,way,result,data)
|
||||
|
||||
bike_push_handler(profile,way,result,data)
|
||||
|
||||
-- width should be after bike_push
|
||||
width_handler(profile,way,result,data)
|
||||
|
||||
-- maxspeed
|
||||
limit( result, data.maxspeed, data.maxspeed_forward, data.maxspeed_backward )
|
||||
@@ -391,9 +376,16 @@ function speed_handler(profile,way,result,data)
|
||||
data.way_type_allows_pushing = true
|
||||
elseif profile.bicycle_speeds[data.highway] then
|
||||
-- regular ways
|
||||
-- check trunk
|
||||
result.forward_speed = profile.bicycle_speeds[data.highway]
|
||||
result.backward_speed = profile.bicycle_speeds[data.highway]
|
||||
data.way_type_allows_pushing = true
|
||||
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
|
||||
result.forward_speed = profile.trunk_speeds[data.highway]
|
||||
result.backward_speed = profile.trunk_speeds[data.highway]
|
||||
data.way_type_allows_pushing = true
|
||||
end
|
||||
elseif data.access and profile.access_tag_whitelist[data.access] then
|
||||
-- unknown way, but valid access tag
|
||||
result.forward_speed = profile.default_speed
|
||||
@@ -480,27 +472,6 @@ function cycleway_handler(profile,way,result,data)
|
||||
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)
|
||||
-- pushing bikes - if no other mode found
|
||||
if result.forward_mode == mode.inaccessible or result.backward_mode == mode.inaccessible or
|
||||
|
||||
+12
-2
@@ -20,6 +20,7 @@ function setup()
|
||||
use_turn_restrictions = false,
|
||||
},
|
||||
|
||||
profile = 'foot',
|
||||
default_mode = mode.walking,
|
||||
default_speed = walking_speed,
|
||||
oneway_handling = 'specific', -- respect 'oneway:foot' but not 'oneway'
|
||||
@@ -70,9 +71,15 @@ function setup()
|
||||
|
||||
avoid = Set {
|
||||
'impassable',
|
||||
'proposed'
|
||||
'proposed',
|
||||
'motorroad'
|
||||
},
|
||||
|
||||
trunk_speeds = {
|
||||
trunk = walking_speed,
|
||||
trunk_link = walking_speed
|
||||
},
|
||||
|
||||
speeds = Sequence {
|
||||
highway = {
|
||||
primary = walking_speed,
|
||||
@@ -132,6 +139,10 @@ function setup()
|
||||
},
|
||||
|
||||
smoothness_speeds = {
|
||||
},
|
||||
|
||||
uselocationtags = Set {
|
||||
-- 'trunk'
|
||||
}
|
||||
}
|
||||
end
|
||||
@@ -190,7 +201,6 @@ function process_way(profile, way, result)
|
||||
amenity = way:get_value_by_key('amenity'),
|
||||
public_transport = way:get_value_by_key('public_transport')
|
||||
}
|
||||
|
||||
-- perform an quick initial check and abort if the way is
|
||||
-- obviously not routable. here we require at least one
|
||||
-- of the prefetched tags to be present, ie. the data table
|
||||
|
||||
@@ -276,6 +276,16 @@ function WayHandlers.speed(profile,way,result,data)
|
||||
|
||||
local key,value,speed = Tags.get_constant_by_key_value(way,profile.speeds)
|
||||
|
||||
-- if the highway is trunk or trunk_link and locationtag disables it
|
||||
-- then noroute available
|
||||
|
||||
if not speed and data.highway and profile.uselocationtags and profile.uselocationtags.trunk then
|
||||
if profile.trunk_speeds[data.highway] and
|
||||
(not way:get_location_tag(data.highway) or way:get_location_tag(data.highway) ~= "no") then
|
||||
speed = profile.trunk_speeds[data.highway]
|
||||
end
|
||||
end
|
||||
|
||||
if speed then
|
||||
-- set speed by way type
|
||||
result.forward_speed = speed
|
||||
@@ -634,6 +644,11 @@ function WayHandlers.blocked_ways(profile,way,result,data)
|
||||
return false
|
||||
end
|
||||
|
||||
-- motorroad
|
||||
if profile.avoid.motorroad and way:get_value_by_key("motorroad") == "yes" then
|
||||
return false
|
||||
end
|
||||
|
||||
-- In addition to the highway=construction tag above handle the construction=* tag
|
||||
-- http://wiki.openstreetmap.org/wiki/Key:construction
|
||||
-- https://taginfo.openstreetmap.org/keys/construction#values
|
||||
|
||||
Reference in New Issue
Block a user