From 6e1ab9fe3a340379368195fb476d6a699ca26e39 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 12 Aug 2014 19:31:31 +0200 Subject: [PATCH] profile fixes --- features/bicycle/mode.feature | 28 +++++++++++++++++++++++++++- profiles/bicycle.lua | 15 +++------------ profiles/testbot.lua | 12 ++++-------- 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/features/bicycle/mode.feature b/features/bicycle/mode.feature index 9c3305904..37e51fb77 100644 --- a/features/bicycle/mode.feature +++ b/features/bicycle/mode.feature @@ -148,4 +148,30 @@ Feature: Bike - Mode flag | c | a | bc,ab | head,left,destination | 2,1 | | 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 | \ No newline at end of file + | 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 | diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index c10cd580a..9f6a64062 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -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 diff --git a/profiles/testbot.lua b/profiles/testbot.lua index fb32ca642..2e83c8d69 100644 --- a/profiles/testbot.lua +++ b/profiles/testbot.lua @@ -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 + way.backward_speed = speed_back 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