fix travel speeds for cars

This commit is contained in:
Emil Tin 2014-03-27 18:22:04 +01:00
parent 45c96f73c2
commit fd96c7c488
3 changed files with 24 additions and 33 deletions

View File

@ -1,5 +1,6 @@
@routing @maxspeed @car @routing @maxspeed @car
Feature: Car - Max speed restrictions Feature: Car - Max speed restrictions
When a max speed is set, osrm will use 2/3 of that as the actual speed.
Background: Use specific speeds Background: Use specific speeds
Given the profile "car" Given the profile "car"
@ -12,12 +13,12 @@ Feature: Car - Max speed restrictions
And the ways And the ways
| nodes | highway | maxspeed | | nodes | highway | maxspeed |
| ab | trunk | | | ab | trunk | |
| bc | trunk | 10 | | bc | trunk | 60 |
When I route I should get When I route I should get
| from | to | route | time | | from | to | route | speed |
| a | b | ab | 64s ~10% | | a | b | ab | 85 km/h |
| b | c | bc | 545s ~10% | | b | c | bc | 40 km/h |
Scenario: Car - Do not ignore maxspeed when higher than way speed Scenario: Car - Do not ignore maxspeed when higher than way speed
Given the node map Given the node map
@ -26,32 +27,25 @@ Feature: Car - Max speed restrictions
And the ways And the ways
| nodes | highway | maxspeed | | nodes | highway | maxspeed |
| ab | residential | | | ab | residential | |
| bc | residential | 85 | | bc | residential | 90 |
When I route I should get When I route I should get
| from | to | route | time | | from | to | route | speed |
| a | b | ab | 216s ~10% | | a | b | ab | 25 km/h |
| b | c | bc | 64s ~10% | | b | c | bc | 60 km/h |
Scenario: Car - Forward/backward maxspeed Scenario: Car - Forward/backward maxspeed
Given the shortcuts Given a grid size of 100 meters
| key | value |
| car | 17s ~10% |
| run | 109s ~10% |
| walk | 219s ~10% |
| snail | 1080s ~10% |
And a grid size of 100 meters
Then routability should be Then routability should be
| maxspeed | maxspeed:forward | maxspeed:backward | forw | backw | | highway | maxspeed | maxspeed:forward | maxspeed:backward | forw | backw |
| | | | car | car | | primary | | | | 65 km/h | 65 km/h |
| 10 | | | run | run | | primary | 60 | | | 40 km/h | 40 km/h |
| | 10 | | run | car | | primary | | 60 | | 40 km/h | 65 km/h |
| | | 10 | car | run | | primary | | | 60 | 65 km/h | 40 km/h |
| 1 | 10 | | run | snail | | primary | 15 | 60 | | 40 km/h | 10 km/h |
| 1 | | 10 | snail | run | | primary | 15 | | 60 | 10 km/h | 40 km/h |
| 1 | 5 | 10 | walk | run | | primary | 15 | 30 | 60 | 20 km/h | 40 km/h |
Scenario: Car - Maxspeed should not allow routing on unroutable ways Scenario: Car - Maxspeed should not allow routing on unroutable ways
Then routability should be Then routability should be
@ -68,4 +62,4 @@ Feature: Car - Max speed restrictions
| runway | | | | | | | | runway | | | | | | |
| runway | | | 100 | | | | | runway | | | 100 | | | |
| runway | | | | 100 | | | | runway | | | | 100 | | |
| runway | | | | | 100 | | | runway | | | | | 100 | |

View File

@ -5,7 +5,6 @@ Feature: Car - speeds
Given the profile "car" Given the profile "car"
And a grid size of 1000 meters And a grid size of 1000 meters
@bug
Scenario: Car - speed of various way types Scenario: Car - speed of various way types
Then routability should be Then routability should be
| highway | oneway | bothw | | highway | oneway | bothw |

View File

@ -44,6 +44,8 @@ local abs = math.abs
local min = math.min local min = math.min
local max = math.max local max = math.max
local maxspeed_reduction = 0.66
-- End of globals -- End of globals
local function find_access_tag(source,access_tags_hierachy) local function find_access_tag(source,access_tags_hierachy)
for i,v in ipairs(access_tags_hierachy) do for i,v in ipairs(access_tags_hierachy) do
@ -161,7 +163,7 @@ function way_function (way)
if way.speed == -1 then if way.speed == -1 then
local highway_speed = speed_profile[highway] local highway_speed = speed_profile[highway]
local max_speed = parse_maxspeed( way.tags:Find("maxspeed") ) local max_speed = parse_maxspeed( way.tags:Find("maxspeed") )*maxspeed_reduction
-- Set the avg speed on the way if it is accessible by road class -- Set the avg speed on the way if it is accessible by road class
if highway_speed then if highway_speed then
if max_speed > highway_speed then if max_speed > highway_speed then
@ -234,8 +236,8 @@ function way_function (way)
end end
-- Override speed settings if explicit forward/backward maxspeeds are given -- Override speed settings if explicit forward/backward maxspeeds are given
local maxspeed_forward = parse_maxspeed(way.tags:Find( "maxspeed:forward")) local maxspeed_forward = parse_maxspeed(way.tags:Find( "maxspeed:forward"))*maxspeed_reduction
local maxspeed_backward = parse_maxspeed(way.tags:Find( "maxspeed:backward")) local maxspeed_backward = parse_maxspeed(way.tags:Find( "maxspeed:backward"))*maxspeed_reduction
if maxspeed_forward > 0 then if maxspeed_forward > 0 then
if Way.bidirectional == way.direction then if Way.bidirectional == way.direction then
way.backward_speed = way.speed way.backward_speed = way.speed
@ -251,10 +253,6 @@ function way_function (way)
way.ignore_in_grid = true way.ignore_in_grid = true
end end
way.type = 1 way.type = 1
way.speed = abs(way.speed*0.66) -- scaling of travel times.
if(way.backward_speed > 0) then
way.backward_speed = abs(way.backward_speed*0.66) -- scaling of travel times.
end
return return
end end