hov_penalty, use min penalty rather than aggregate
This commit is contained in:
parent
25ab51f4f0
commit
24fe881d03
@ -6,7 +6,7 @@ OSRM will use 4/5 of the projected free-flow speed.
|
||||
Given the profile "car"
|
||||
Given a grid size of 1000 meters
|
||||
|
||||
Scenario: Car - Respect maxspeeds when lower that way type speed
|
||||
Scenario: Car - Respect maxspeeds when lower than way type speed
|
||||
Given the node map
|
||||
"""
|
||||
a b c d e f g
|
||||
@ -23,7 +23,7 @@ OSRM will use 4/5 of the projected free-flow speed.
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | speed |
|
||||
| a | b | ab,ab | 68 km/h |
|
||||
| a | b | ab,ab | 85 km/h |
|
||||
| b | c | bc,bc | 48 km/h |
|
||||
| c | d | cd,cd | 40 km/h |
|
||||
| d | e | de,de | 64 km/h |
|
||||
|
@ -80,6 +80,12 @@ Feature: Traffic - turn penalties
|
||||
8,11,12,23
|
||||
1,4,5,-0.2
|
||||
"""
|
||||
# ifg right turn
|
||||
# imn left turn
|
||||
# hdc left turn
|
||||
# lkh right turn
|
||||
# hkl left turn
|
||||
# ade left turn
|
||||
And the contract extra arguments "--turn-penalty-file {penalties_file}"
|
||||
When I route I should get
|
||||
| from | to | route | speed | time |
|
||||
|
@ -117,7 +117,7 @@ local profile = {
|
||||
unclassified = 25,
|
||||
residential = 25,
|
||||
living_street = 10,
|
||||
service = 15,
|
||||
service = 15
|
||||
}
|
||||
},
|
||||
|
||||
@ -126,7 +126,8 @@ local profile = {
|
||||
parking = 0.5,
|
||||
parking_aisle = 0.5,
|
||||
driveway = 0.5,
|
||||
["drive-through"] = 0.5
|
||||
["drive-through"] = 0.5,
|
||||
["drive-thru"] = 0.5
|
||||
},
|
||||
|
||||
route_speeds = {
|
||||
|
@ -170,20 +170,14 @@ end
|
||||
-- handle high occupancy vehicle tags
|
||||
function Handlers.handle_hov(way,result,data,profile)
|
||||
-- respect user-preference for HOV
|
||||
if not profile.avoid.hov_lanes then
|
||||
if not profile.avoid.hov_lanes or properties.weight_name ~= 'routability' then
|
||||
return
|
||||
end
|
||||
|
||||
-- check if way is hov only
|
||||
local hov = way:get_value_by_key("hov")
|
||||
if "designated" == hov then
|
||||
return false
|
||||
end
|
||||
|
||||
-- check if all lanes are hov only
|
||||
local hov_lanes_forward, hov_lanes_backward = Tags.get_forward_backward_by_key(way,data,'hov:lanes')
|
||||
local inaccessible_forward = Handlers.has_all_designated_hov_lanes(hov_lanes_forward)
|
||||
local inaccessible_backward = Handlers.has_all_designated_hov_lanes(hov_lanes_backward)
|
||||
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
|
||||
result.forward_mode = mode.inaccessible
|
||||
@ -269,10 +263,21 @@ end
|
||||
|
||||
-- scale speeds to get better average driving times
|
||||
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 hov_penalty = 0.1
|
||||
if profile.avoid.hov_lanes then
|
||||
local hov = way:get_value_by_key("hov")
|
||||
local all_lanes_designated = Handlers.has_all_designated_hov_lanes(data.hov_lanes_forward)
|
||||
if "designated" == hov or all_lanes_designated then
|
||||
hov_penalty = 0.1
|
||||
end
|
||||
end
|
||||
|
||||
local service_penalty = 1.0
|
||||
local service = way:get_value_by_key("service")
|
||||
if service and service_penalties[service] then
|
||||
service_penalty = service_penalties[service]
|
||||
if service and profile.service_penalties[service] then
|
||||
service_penalty = profile.service_penalties[service]
|
||||
end
|
||||
|
||||
local width_penalty = 1.0
|
||||
@ -308,7 +313,7 @@ function Handlers.handle_penalties(way,result,data,profile)
|
||||
sideroad_penalty = side_road_multiplier;
|
||||
end
|
||||
|
||||
local penalty = service_penalty * width_penalty * alternating_penalty * sideroad_penalty
|
||||
local penalty = math.min(service_penalty, width_penalty, alternating_penalty, sideroad_penalty, hov_penalty)
|
||||
|
||||
if properties.weight_name == 'routability' then
|
||||
if result.forward_speed > 0 then
|
||||
|
Loading…
Reference in New Issue
Block a user