Fixing test cases to check for different speeds in opposite direction

This commit is contained in:
DennisOSRM 2013-01-27 14:03:51 +01:00
parent aae0547cca
commit 6317b08090
3 changed files with 23 additions and 32 deletions

View File

@ -65,8 +65,8 @@ Feature: Car - Max speed restrictions
| d | e | de | 10s +-1 |
| e | d | de | 20s +-1 |
| e | f | ef | 20s +-1 |
| f | e | ef | 10s +-1 |
| f | g | fg | 10s +-1 |
| f | e | ef | 40s +-1 |
| f | g | fg | 40s +-1 |
| g | f | fg | 20s +-1 |
| g | h | gh | 15s +-1 |
| h | g | gh | 10s +-1 |
| h | g | gh | 20s +-1 |

View File

@ -15,4 +15,4 @@ Feature: Separate settings for forward/backward direction
When I route I should get
| from | to | route | distance | time |
| a | d | abcd | 300 +- 1m | 30s |
| d | a | abcd | 300 +- 1m | 55s |
| d | a | abcd | 300 +- 1m | 68s |

View File

@ -23,19 +23,6 @@ ignore_areas = true -- future feature
traffic_signal_penalty = 7 -- seconds
u_turn_penalty = 20
function limit_speed(speed, limits)
-- don't use ipairs(), since it stops at the first nil value
for i=1, #limits do
limit = limits[i]
if limit ~= nil and limit > 0 then
if limit < speed then
return limit -- stop at first speedlimit that's smaller than speed
end
end
end
return speed
end
function node_function (node)
local traffic_signal = node.tags:Find("highway")
@ -61,12 +48,6 @@ function way_function (way, numberOfNodesInWay)
local maxspeed_forward = tonumber(way.tags:Find( "maxspeed:forward"))
local maxspeed_backward = tonumber(way.tags:Find( "maxspeed:backward"))
print('---')
print(name)
print(tostring(maxspeed))
print(tostring(maxspeed_forward))
print(tostring(maxspeed_backward))
way.name = name
if route ~= nil and durationIsValid(duration) then
@ -78,21 +59,31 @@ function way_function (way, numberOfNodesInWay)
local speed_back = speed_forw
if highway == "river" then
local temp_speed = way.speed;
speed_forw = temp_speed*3/2
speed_back = temp_speed*2/3
end
local temp_speed = speed_forw;
speed_forw = temp_speed*1.5
speed_back = temp_speed/1.5
end
speed_forw = limit_speed( speed_forw, {maxspeed_forward, maxspeed} )
speed_back = limit_speed( speed_back, {maxspeed_backward, maxspeed} )
if maxspeed_forward ~= nil and maxspeed_forward > 0 then
speed_forw = maxspeed_forward
else
if maxspeed ~= nil and maxspeed > 0 and speed_forw > maxspeed then
speed_forw = maxspeed
end
end
if maxspeed_backward ~= nil and maxspeed_backward > 0 then
speed_back = maxspeed_backward
else
if maxspeed ~=nil and maxspeed > 0 and speed_back > maxspeed then
speed_back = maxspeed
end
end
way.speed = speed_forw
if speed_back ~= way_forw then
way.backward_speed = speed_back
end
-- print( 'speed forw: ' .. tostring(way.speed))
-- print( 'speed back: ' .. tostring(way.backward_speed))
end
if oneway == "no" or oneway == "0" or oneway == "false" then