profile fixes

This commit is contained in:
Emil Tin 2014-08-12 19:31:31 +02:00 committed by Emil Tin
parent 7a2d214cc4
commit 6e1ab9fe3a
3 changed files with 34 additions and 21 deletions

View File

@ -149,3 +149,29 @@ Feature: Bike - Mode flag
| d | b | cd,bc | head,right,destination | 1,2 |
| a | c | ab,bc | head,right,destination | 1,2 |
| b | d | bc,cd | head,left,destination | 2,1 |
Scenario: Bicycle - Modes when starting on forward oneway
Given the node map
| a | b |
And the ways
| nodes | oneway |
| ab | yes |
When I route I should get
| from | to | route | modes |
| a | b | ab | 2 |
| b | a | | |
Scenario: Bicycle - Modes when starting on reverse oneway
Given the node map
| a | b |
And the ways
| nodes | oneway |
| ab | -1 |
When I route I should get
| from | to | route | modes |
| a | b | | |
| b | a | ab | 2 |

View File

@ -200,6 +200,7 @@ function way_function (way)
local area = way.tags:Find("area")
local foot = way.tags:Find("foot")
local surface = way.tags:Find("surface")
local bicycle = way.tags:Find("bicycle")
-- name
if "" ~= ref and "" ~= name then
@ -223,6 +224,7 @@ function way_function (way)
if route_speeds[route] then
-- ferries (doesn't cover routes tagged using relations)
way.mode = mode_ferry
way.backward_mode = mode_ferry
way.direction = Way.bidirectional
way.ignore_in_grid = true
if durationIsValid(duration) then
@ -241,6 +243,7 @@ function way_function (way)
way.backward_speed = platform_speeds[public_transport]
elseif railway and railway_speeds[railway] then
way.mode = mode_train
way.backward_mode = mode_train
-- railways
if access and access_tag_whitelist[access] then
way.speed = railway_speeds[railway]
@ -372,18 +375,6 @@ function way_function (way)
-- maxspeed
MaxSpeed.limit( way, maxspeed, maxspeed_forward, maxspeed_backward )
-- Override speed settings if explicit forward/backward maxspeeds are given
if way.speed > 0 and maxspeed_forward ~= nil and maxspeed_forward > 0 then
if Way.bidirectional == way.direction then
way.backward_speed = way.speed
end
way.speed = maxspeed_forward
end
if maxspeed_backward ~= nil and maxspeed_backward > 0 then
way.backward_speed = maxspeed_backward
end
way.type = 1
return 1
end

View File

@ -104,19 +104,15 @@ function way_function (way)
end
way.speed = speed_forw
if speed_back ~= way_forw then
way.backward_speed = speed_back
end
end
if oneway == "no" or oneway == "0" or oneway == "false" then
way.direction = Way.bidirectional
-- nothing to do
elseif oneway == "-1" then
way.direction = Way.opposite
way.mode = 0
elseif oneway == "yes" or oneway == "1" or oneway == "true" or junction == "roundabout" then
way.direction = Way.oneway
else
way.direction = Way.bidirectional
way.backward_mode = 0
end
if junction == 'roundabout' then