test maxspeed forward/backward
This commit is contained in:
parent
3595ac08f7
commit
4f9c422e2f
@ -10,9 +10,9 @@ Feature: Car - Max speed restrictions
|
||||
| a | b | c |
|
||||
|
||||
And the ways
|
||||
| nodes | highway | maxspeed |
|
||||
| ab | trunk | |
|
||||
| bc | trunk | 10 |
|
||||
| nodes | highway | maxspeed |
|
||||
| ab | trunk | |
|
||||
| bc | trunk | 10 |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | time |
|
||||
@ -31,27 +31,4 @@ Feature: Car - Max speed restrictions
|
||||
When I route I should get
|
||||
| from | to | route | time |
|
||||
| a | b | ab | 144s ~10% |
|
||||
| b | c | bc | 144s ~10% |
|
||||
|
||||
@oppposite @todo
|
||||
Scenario: Car - Forward/backward maxspeed
|
||||
Given the node map
|
||||
| a | b | c | d | e |
|
||||
|
||||
And the ways
|
||||
| nodes | highway | maxspeed:forward | maxspeed:backward |
|
||||
| ab | primary | | |
|
||||
| bc | primart | 18 | 9 |
|
||||
| cd | primart | | 9 |
|
||||
| de | primart | 9 | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | time |
|
||||
| a | b | ab | 10s |
|
||||
| b | a | ab | 10s |
|
||||
| b | c | bc | 20s |
|
||||
| c | b | bc | 40s |
|
||||
| c | d | cd | 10s |
|
||||
| d | c | cd | 20s |
|
||||
| d | e | de | 20s |
|
||||
| e | d | de | 10s |
|
||||
| b | c | bc | 144s ~10% |
|
||||
|
70
features/testbot/maxspeed.feature
Normal file
70
features/testbot/maxspeed.feature
Normal file
@ -0,0 +1,70 @@
|
||||
@routing @maxspeed @testbot
|
||||
Feature: Car - Max speed restrictions
|
||||
|
||||
Background: Use specific speeds
|
||||
Given the profile "testbot"
|
||||
|
||||
Scenario: Testbot - Respect maxspeeds when lower that way type speed
|
||||
Given the node map
|
||||
| a | b | c | d |
|
||||
|
||||
And the ways
|
||||
| nodes | maxspeed |
|
||||
| ab | |
|
||||
| bc | 24 |
|
||||
| cd | 18 |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | time |
|
||||
| a | b | ab | 10s +-1 |
|
||||
| b | a | ab | 10s +-1 |
|
||||
| b | c | bc | 15s +-1 |
|
||||
| c | b | bc | 15s +-1 |
|
||||
| c | d | cd | 20s +-1 |
|
||||
| d | c | cd | 20s +-1 |
|
||||
|
||||
Scenario: Testbot - Ignore maxspeed when higher than way speed
|
||||
Given the node map
|
||||
| a | b | c |
|
||||
|
||||
And the ways
|
||||
| nodes | maxspeed |
|
||||
| ab | |
|
||||
| bc | 200 |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | time |
|
||||
| a | b | ab | 20s +-1 |
|
||||
| b | c | bc | 20s +-1 |
|
||||
|
||||
@opposite
|
||||
Scenario: Testbot - Forward/backward maxspeed
|
||||
Given the node map
|
||||
| a | b | c | d | e | f | g | h |
|
||||
|
||||
And the ways
|
||||
| nodes | maxspeed | maxspeed:forward | maxspeed:backward |
|
||||
| ab | | | |
|
||||
| bc | 18 | | |
|
||||
| cd | | 18 | |
|
||||
| de | | | 18 |
|
||||
| ef | 9 | 18 | |
|
||||
| fg | 9 | | 18 |
|
||||
| gh | 9 | 24 | 18 |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | time |
|
||||
| a | b | ab | 10s +-1 |
|
||||
| b | a | ab | 10s +-1 |
|
||||
| b | c | bc | 20s +-1 |
|
||||
| c | b | bc | 20s +-1 |
|
||||
| c | d | cd | 20s +-1 |
|
||||
| d | c | cd | 10s +-1 |
|
||||
| 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 |
|
||||
| g | f | fg | 20s +-1 |
|
||||
| g | h | gh | 15s +-1 |
|
||||
| h | g | gh | 10s +-1 |
|
@ -1,4 +1,4 @@
|
||||
@routing @opposite
|
||||
@routing @testbot @opposite
|
||||
Feature: Separate settings for forward/backward direction
|
||||
|
||||
Background:
|
||||
|
@ -23,6 +23,18 @@ 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")
|
||||
@ -45,6 +57,15 @@ function way_function (way, numberOfNodesInWay)
|
||||
local oneway = way.tags:Find("oneway")
|
||||
local route = way.tags:Find("route")
|
||||
local duration = way.tags:Find("duration")
|
||||
local maxspeed = tonumber(way.tags:Find ( "maxspeed"))
|
||||
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
|
||||
|
||||
@ -54,12 +75,20 @@ function way_function (way, numberOfNodesInWay)
|
||||
way.is_duration_set = true
|
||||
else
|
||||
way.speed = speed_profile[highway] or speed_profile['default']
|
||||
end
|
||||
|
||||
if(highway == "river") then
|
||||
local temp_speed = way.speed;
|
||||
way.speed = temp_speed*3/2
|
||||
way.backward_speed = temp_speed*2/3
|
||||
|
||||
if highway == "river" then
|
||||
local temp_speed = way.speed;
|
||||
way.speed = temp_speed*3/2
|
||||
way.backward_speed = temp_speed*2/3
|
||||
else
|
||||
way.backward_speed = way.speed
|
||||
end
|
||||
|
||||
way.speed = limit_speed( way.speed, {maxspeed_forward, maxspeed} )
|
||||
way.backward_speed = limit_speed( way.backward_speed, {maxspeed_backward, maxspeed} )
|
||||
|
||||
-- print( 'limit forw: ' .. tostring(way.speed))
|
||||
-- print( 'limit back: ' .. tostring(way.backward_speed))
|
||||
end
|
||||
|
||||
if oneway == "no" or oneway == "0" or oneway == "false" then
|
||||
|
Loading…
Reference in New Issue
Block a user