Only penaltize bidirectional ways if they have 1 lane

This commit is contained in:
Patrick Niklaus
2015-06-26 14:34:49 +02:00
parent dddde4ddab
commit 8a2652f53d
2 changed files with 12 additions and 2 deletions
+4 -2
View File
@@ -412,11 +412,13 @@ function way_function (way, result)
end
end
local is_bidirectional = result.forward_mode ~= 0 and result.backward_mode ~= 0
-- scale speeds to get better avg driving times
if result.forward_speed > 0 then
local scaled_speed = result.forward_speed*speed_reduction + 11;
local penalized_speed = math.huge
if width <= 3 or lanes <= 1 then
if width <= 3 or (lanes <= 1 and is_bidirectional) then
penalized_speed = result.forward_speed / 2;
end
result.forward_speed = math.min(penalized_speed, scaled_speed)
@@ -425,7 +427,7 @@ function way_function (way, result)
if result.backward_speed > 0 then
local scaled_speed = result.backward_speed*speed_reduction + 11;
local penalized_speed = math.huge
if width <= 3 or lanes <= 1 then
if width <= 3 or (lanes <= 1 and is_bidirectional) then
penalized_speed = result.backward_speed / 2;
end
result.backward_speed = math.min(penalized_speed, scaled_speed)