Merge pull request #1390 from Project-OSRM/feature/width_penalty
implements a penalty for very narrow roads
This commit is contained in:
commit
c215c42289
@ -73,3 +73,23 @@ OSRM will use 4/5 of the projected free-flow speed.
|
|||||||
| runway | | | 100 | | | |
|
| runway | | | 100 | | | |
|
||||||
| runway | | | | 100 | | |
|
| runway | | | | 100 | | |
|
||||||
| runway | | | | | 100 | |
|
| runway | | | | | 100 | |
|
||||||
|
|
||||||
|
Scenario: Car - Too narrow streets should be ignored or incur a penalty
|
||||||
|
Then routability should be
|
||||||
|
|
||||||
|
| highway | maxspeed | width | maxspeed:forward | maxspeed:backward | forw | backw |
|
||||||
|
| primary | | | | | 63 km/h | 63 km/h |
|
||||||
|
| primary | | 3 | | | 32 km/h | 32 km/h |
|
||||||
|
| primary | 60 | | | | 59 km/h | 59 km/h |
|
||||||
|
| primary | 60 | 3 | | | 30 km/h | 30 km/h |
|
||||||
|
| primary | | | 60 | | 59 km/h | 63 km/h |
|
||||||
|
| primary | | 3 | 60 | | 30 km/h | 32 km/h |
|
||||||
|
| primary | | | | 60 | 63 km/h | 59 km/h |
|
||||||
|
| primary | | 3 | | 60 | 32 km/h | 30 km/h |
|
||||||
|
| primary | 15 | | 60 | | 59 km/h | 23 km/h |
|
||||||
|
| primary | 15 | 3 | 60 | | 30 km/h | 7 km/h |
|
||||||
|
| primary | 15 | | | 60 | 23 km/h | 59 km/h |
|
||||||
|
| primary | 15 | 3 | | 60 | 7 km/h | 30 km/h |
|
||||||
|
| primary | 15 | | 30 | 60 | 34 km/h | 59 km/h |
|
||||||
|
| primary | 15 | 3 | 30 | 60 | 15 km/h | 30 km/h |
|
||||||
|
|
||||||
|
@ -248,6 +248,12 @@ 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
|
||||||
@ -385,12 +391,24 @@ function way_function (way, result)
|
|||||||
result.ignore_in_grid = true
|
result.ignore_in_grid = true
|
||||||
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
|
||||||
result.forward_speed = result.forward_speed*speed_reduction + 11;
|
local scaled_speed = result.forward_speed*speed_reduction + 11;
|
||||||
|
local penalized_speed = math.huge
|
||||||
|
if width <= 3 then
|
||||||
|
penalized_speed = result.forward_speed / 2;
|
||||||
|
end
|
||||||
|
result.forward_speed = math.min(penalized_speed, scaled_speed)
|
||||||
end
|
end
|
||||||
|
|
||||||
if result.backward_speed > 0 then
|
if result.backward_speed > 0 then
|
||||||
result.backward_speed = result.backward_speed*speed_reduction + 11;
|
local scaled_speed = result.backward_speed*speed_reduction + 11;
|
||||||
|
local penalized_speed = math.huge
|
||||||
|
if width <= 3 then
|
||||||
|
penalized_speed = result.backward_speed / 2;
|
||||||
|
end
|
||||||
|
result.backward_speed = math.min(penalized_speed, scaled_speed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user