Add penalty if there is only one lane for both directions
This commit is contained in:
parent
cf294c938e
commit
86df55f5cc
@ -241,12 +241,6 @@ function way_function (way, result)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local width = math.huge
|
|
||||||
local width_string = way:get_value_by_key("width")
|
|
||||||
if width_string and tonumber(width_string:match("%d*")) then
|
|
||||||
width = tonumber(width_string:match("%d*"))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Check if we are allowed to access the way
|
-- Check if we are allowed to access the way
|
||||||
local access = find_access_tag(way, access_tags_hierachy)
|
local access = find_access_tag(way, access_tags_hierachy)
|
||||||
if access_tag_blacklist[access] then
|
if access_tag_blacklist[access] then
|
||||||
@ -404,12 +398,25 @@ function way_function (way, result)
|
|||||||
result.ignore_in_grid = true
|
result.ignore_in_grid = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local width = math.huge
|
||||||
|
local lanes = math.huge
|
||||||
|
if result.forward_speed > 0 or result.backward_speed > 0 then
|
||||||
|
local width_string = way:get_value_by_key("width")
|
||||||
|
if width_string and tonumber(width_string:match("%d*")) then
|
||||||
|
width = tonumber(width_string:match("%d*"))
|
||||||
|
end
|
||||||
|
|
||||||
|
local lanes_string = way:get_value_by_key("lanes")
|
||||||
|
if lanes_string and tonumber(lanes_string:match("%d*")) then
|
||||||
|
lanes = tonumber(lanes_string:match("%d*"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- scale speeds to get better avg driving times
|
-- scale speeds to get better avg driving times
|
||||||
if result.forward_speed > 0 then
|
if result.forward_speed > 0 then
|
||||||
local scaled_speed = result.forward_speed*speed_reduction + 11;
|
local scaled_speed = result.forward_speed*speed_reduction + 11;
|
||||||
local penalized_speed = math.huge
|
local penalized_speed = math.huge
|
||||||
if width <= 3 then
|
if width <= 3 or lanes <= 1 then
|
||||||
penalized_speed = result.forward_speed / 2;
|
penalized_speed = result.forward_speed / 2;
|
||||||
end
|
end
|
||||||
result.forward_speed = math.min(penalized_speed, scaled_speed)
|
result.forward_speed = math.min(penalized_speed, scaled_speed)
|
||||||
@ -418,7 +425,7 @@ function way_function (way, result)
|
|||||||
if result.backward_speed > 0 then
|
if result.backward_speed > 0 then
|
||||||
local scaled_speed = result.backward_speed*speed_reduction + 11;
|
local scaled_speed = result.backward_speed*speed_reduction + 11;
|
||||||
local penalized_speed = math.huge
|
local penalized_speed = math.huge
|
||||||
if width <= 3 then
|
if width <= 3 or lanes <= 1 then
|
||||||
penalized_speed = result.backward_speed / 2;
|
penalized_speed = result.backward_speed / 2;
|
||||||
end
|
end
|
||||||
result.backward_speed = math.min(penalized_speed, scaled_speed)
|
result.backward_speed = math.min(penalized_speed, scaled_speed)
|
||||||
|
Loading…
Reference in New Issue
Block a user