Skip to content

Commit

Permalink
implements a penalty for very narrow road:
Browse files Browse the repository at this point in the history
- implements discussion of #1388
- implements basic test cases
  • Loading branch information
DennisOSRM committed Feb 20, 2015
1 parent e9e12b8 commit 4c4c126
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
20 changes: 20 additions & 0 deletions features/car/maxspeed.feature
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,23 @@ OSRM will use 4/5 of the projected free-flow speed.
| 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 | | | 31 km/h | 31 km/h |
| primary | 60 | | | | 59 km/h | 59 km/h |
| primary | 60 | 3 | | | 29 km/h | 29 km/h |
| primary | | | 60 | | 59 km/h | 63 km/h |
| primary | | 3 | 60 | | 29 km/h | 31 km/h |
| primary | | | | 60 | 63 km/h | 59 km/h |
| primary | | 3 | | 60 | 31 km/h | 29 km/h |
| primary | 15 | | 60 | | 59 km/h | 23 km/h |
| primary | 15 | 3 | 60 | | 29 km/h | 11 km/h |
| primary | 15 | | | 60 | 23 km/h | 59 km/h |
| primary | 15 | 3 | | 60 | 11 km/h | 29 km/h |
| primary | 15 | | 30 | 60 | 34 km/h | 59 km/h |
| primary | 15 | 3 | 30 | 60 | 17 km/h | 29 km/h |

15 changes: 15 additions & 0 deletions profiles/car.lua
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ function way_function (way, result)
return
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*"))
io.write("width: "..width.."\n")
end

-- Check if we are allowed to access the way
local access = find_access_tag(way, access_tags_hierachy)
if access_tag_blacklist[access] then
Expand Down Expand Up @@ -385,12 +392,20 @@ function way_function (way, result)
result.ignore_in_grid = true
end


-- scale speeds to get better avg driving times
if result.forward_speed > 0 then
result.forward_speed = result.forward_speed*speed_reduction + 11;
if width <= 3 then
result.forward_speed = result.forward_speed / 2;
end
end

if result.backward_speed > 0 then
result.backward_speed = result.backward_speed*speed_reduction + 11;
if width <= 3 then
result.backward_speed = result.backward_speed / 2;
end
end
end

Expand Down

0 comments on commit 4c4c126

Please sign in to comment.