expose data about turning onto restricted roads to turn function
This commit is contained in:
committed by
Patrick Niklaus
parent
a0e7bab598
commit
c2727f2029
@@ -65,6 +65,8 @@ local profile = {
|
||||
'delivery'
|
||||
},
|
||||
|
||||
restricted_access_tag_list = Set { },
|
||||
|
||||
access_tags_hierarchy = Sequence {
|
||||
'bicycle',
|
||||
'vehicle',
|
||||
@@ -521,4 +523,10 @@ function turn_function(turn)
|
||||
if turn.has_traffic_light then
|
||||
turn.duration = turn.duration + profile.traffic_light_penalty
|
||||
end
|
||||
if properties.weight_name == 'cyclability' then
|
||||
-- penalize turns from non-local access only segments onto local access only tags
|
||||
if not turn.source_restricted and turn.target_restricted then
|
||||
turn.weight = turn.weight + 3000
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+18
-6
@@ -34,6 +34,9 @@ local profile = {
|
||||
speed_reduction = 0.8,
|
||||
traffic_light_penalty = 2,
|
||||
u_turn_penalty = 20,
|
||||
restricted_penalty = 3000,
|
||||
-- Note^: abstract value but in seconds correlates approximately to 50 min
|
||||
-- meaning that a route through a local access way is > 50 min faster than around
|
||||
|
||||
-- Note: this biases right-side driving.
|
||||
-- Should be inverted for left-driving countries.
|
||||
@@ -63,18 +66,21 @@ local profile = {
|
||||
'vehicle',
|
||||
'permissive',
|
||||
'designated',
|
||||
'destination',
|
||||
'hov' -- we might filter hov out later depending on the avoid settings or add penalties
|
||||
'hov'
|
||||
},
|
||||
|
||||
access_tag_blacklist = Set {
|
||||
'no',
|
||||
'private',
|
||||
'agricultural',
|
||||
'forestry',
|
||||
'emergency',
|
||||
'psv',
|
||||
'delivery'
|
||||
'psv'
|
||||
},
|
||||
|
||||
restricted_access_tag_list = Set {
|
||||
'private',
|
||||
'delivery',
|
||||
'destination'
|
||||
},
|
||||
|
||||
access_tags_hierarchy = Sequence {
|
||||
@@ -331,7 +337,7 @@ function way_function(way, result)
|
||||
-- handle service road restrictions
|
||||
'handle_service',
|
||||
|
||||
-- check high occupancy vehicle restrictions
|
||||
-- handle hov
|
||||
'handle_hov',
|
||||
|
||||
-- compute speed taking into account way type, maxspeed tags, etc.
|
||||
@@ -386,5 +392,11 @@ function turn_function (turn)
|
||||
else
|
||||
turn.weight = turn.duration
|
||||
end
|
||||
if properties.weight_name == 'routability' then
|
||||
-- penalize turns from non-local access only segments onto local access only tags
|
||||
if not turn.source_restricted and turn.target_restricted then
|
||||
turn.weight = turn.weight + profile.restricted_penalty
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+11
-2
@@ -12,6 +12,7 @@ properties.max_speed_for_map_matching = 40/3.6 -- kmph -> m/s
|
||||
properties.use_turn_restrictions = false
|
||||
properties.continue_straight_at_waypoint = false
|
||||
properties.weight_name = 'duration'
|
||||
--properties.weight_name = 'routability'
|
||||
|
||||
local walking_speed = 5
|
||||
|
||||
@@ -44,12 +45,14 @@ local profile = {
|
||||
|
||||
access_tag_blacklist = Set {
|
||||
'no',
|
||||
'private',
|
||||
'agricultural',
|
||||
'forestry',
|
||||
'delivery'
|
||||
'private',
|
||||
'delivery',
|
||||
},
|
||||
|
||||
restricted_access_tag_list = Set { },
|
||||
|
||||
access_tags_hierarchy = Sequence {
|
||||
'foot',
|
||||
'access'
|
||||
@@ -244,4 +247,10 @@ function turn_function (turn)
|
||||
if turn.has_traffic_light then
|
||||
turn.duration = profile.traffic_light_penalty
|
||||
end
|
||||
if properties.weight_name == 'routability' then
|
||||
-- penalize turns from non-local access only segments onto local access only tags
|
||||
if not turn.source_restricted and turn.target_restricted then
|
||||
turn.weight = turn.weight + 3000
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+31
-29
@@ -177,25 +177,37 @@ function Handlers.handle_hov(way,result,data,profile)
|
||||
return
|
||||
end
|
||||
|
||||
-- in this case we will use penalties instead of filtering out
|
||||
local hov = way:get_value_by_key("hov")
|
||||
if "designated" == hov then
|
||||
result.forward_restricted = true
|
||||
result.backward_restricted = true
|
||||
end
|
||||
|
||||
data.hov_lanes_forward, data.hov_lanes_backward = Tags.get_forward_backward_by_key(way,data,'hov:lanes')
|
||||
local all_hov_forward = Handlers.has_all_designated_hov_lanes(data.hov_lanes_forward)
|
||||
local all_hov_backward = Handlers.has_all_designated_hov_lanes(data.hov_lanes_backward)
|
||||
|
||||
-- in this case we will use turn penalties instead of filtering out
|
||||
if properties.weight_name == 'routability' then
|
||||
if (all_hov_forward) then
|
||||
result.forward_restricted = true
|
||||
end
|
||||
if (all_hov_backward) then
|
||||
result.backward_restricted = true
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
-- check if all lanes are hov only
|
||||
data.hov_lanes_forward, data.hov_lanes_backward = Tags.get_forward_backward_by_key(way,data,'hov:lanes')
|
||||
local inaccessible_forward = Handlers.has_all_designated_hov_lanes(data.hov_lanes_forward)
|
||||
local inaccessible_backward = Handlers.has_all_designated_hov_lanes(data.hov_lanes_backward)
|
||||
|
||||
if inaccessible_forward then
|
||||
-- filter out ways where all lanes are hov only
|
||||
if all_hov_forward then
|
||||
result.forward_mode = mode.inaccessible
|
||||
end
|
||||
if inaccessible_backward then
|
||||
if all_hov_backward then
|
||||
result.backward_mode = mode.inaccessible
|
||||
end
|
||||
end
|
||||
|
||||
-- check accessibility by traversing our acces tag hierarchy
|
||||
-- check accessibility by traversing our access tag hierarchy
|
||||
function Handlers.handle_access(way,result,data,profile)
|
||||
data.forward_access, data.backward_access =
|
||||
Tags.get_forward_backward_by_set(way,data,profile.access_tags_hierarchy)
|
||||
@@ -211,6 +223,14 @@ function Handlers.handle_access(way,result,data,profile)
|
||||
if result.forward_mode == mode.inaccessible and result.backward_mode == mode.inaccessible then
|
||||
return false
|
||||
end
|
||||
|
||||
if profile.restricted_access_tag_list[data.forward_access] then
|
||||
result.forward_restricted = true
|
||||
end
|
||||
|
||||
if profile.restricted_access_tag_list[data.backward_access] then
|
||||
result.backward_restricted = true
|
||||
end
|
||||
end
|
||||
|
||||
-- handle speed (excluding maxspeed)
|
||||
@@ -273,24 +293,6 @@ end
|
||||
function Handlers.handle_penalties(way,result,data,profile)
|
||||
-- heavily penalize a way tagged with all HOV lanes
|
||||
-- in order to only route over them if there is no other option
|
||||
local forward_hov_penalty = 1.0
|
||||
local backward_hov_penalty = 1.0
|
||||
if profile.avoid.hov_lanes then
|
||||
local hov = way:get_value_by_key("hov")
|
||||
if "designated" == hov then
|
||||
forward_hov_penalty = 0.1
|
||||
backward_hov_penalty = 0.1
|
||||
else
|
||||
data.hov_lanes_forward, data.hov_lanes_backward = Tags.get_forward_backward_by_key(way,data,'hov:lanes')
|
||||
if Handlers.has_all_designated_hov_lanes(data.hov_lanes_forward) then
|
||||
forward_hov_penalty = 0.1
|
||||
end
|
||||
if Handlers.has_all_designated_hov_lanes(data.hov_lanes_backward) then
|
||||
backward_hov_penalty = 0.1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local service_penalty = 1.0
|
||||
local service = way:get_value_by_key("service")
|
||||
if service and profile.service_penalties[service] then
|
||||
@@ -330,8 +332,8 @@ function Handlers.handle_penalties(way,result,data,profile)
|
||||
sideroad_penalty = profile.side_road_multiplier
|
||||
end
|
||||
|
||||
local forward_penalty = math.min(service_penalty, width_penalty, alternating_penalty, sideroad_penalty, forward_hov_penalty)
|
||||
local backward_penalty = math.min(service_penalty, width_penalty, alternating_penalty, sideroad_penalty, backward_hov_penalty)
|
||||
local forward_penalty = math.min(service_penalty, width_penalty, alternating_penalty, sideroad_penalty)
|
||||
local backward_penalty = math.min(service_penalty, width_penalty, alternating_penalty, sideroad_penalty)
|
||||
|
||||
if properties.weight_name == 'routability' then
|
||||
if result.forward_speed > 0 then
|
||||
|
||||
Reference in New Issue
Block a user