From d21a9a514d0399f232347931ccdeff240b857ce4 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Sat, 25 Jun 2016 12:01:50 +0200 Subject: [PATCH] bike: surface should never increase speed --- features/bicycle/surface.feature | 17 +++++++++++++++++ profiles/bicycle.lua | 18 ++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/features/bicycle/surface.feature b/features/bicycle/surface.feature index 8d303aa12..4f95ee6a6 100644 --- a/features/bicycle/surface.feature +++ b/features/bicycle/surface.feature @@ -38,3 +38,20 @@ Feature: Bike - Surfaces | cycleway | | 48s | | nosense | | | | nosense | asphalt | | + + Scenario: Bicycle - Surfaces should not increase speed when pushing bikes + Given the node map + | a | b | + | c | d | + + And the ways + | nodes | highway | oneway | surface | + | ab | primary | yes | asphalt | + | cd | footway | | asphalt | + + When I route I should get + | from | to | route | modes | speed | + | a | b | ab,ab | cycling,cycling | 15 km/h | + | b | a | ab,ab | pushing bike,pushing bike | 6 km/h | + | c | d | cd,cd | pushing bike,pushing bike | 6 km/h | + | d | c | cd,cd | pushing bike,pushing bike | 6 km/h | diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index 7bbc621c8..be97de3d1 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -207,7 +207,6 @@ function way_function (way, result) local foot = way:get_value_by_key("foot") local foot_forward = way:get_value_by_key("foot:forward") local foot_backward = way:get_value_by_key("foot:backward") - local surface = way:get_value_by_key("surface") local bicycle = way:get_value_by_key("bicycle") -- name @@ -385,17 +384,12 @@ function way_function (way, result) result.backward_speed = walking_speed end - -- surfaces - if surface then - surface_speed = surface_speeds[surface] - if surface_speed then - if result.forward_speed > 0 then - result.forward_speed = surface_speed - end - if result.backward_speed > 0 then - result.backward_speed = surface_speed - end - end + -- reduce speed on bad surfaces + local surface = way:get_value_by_key("surface") + + if surface and surface_speeds[surface] then + result.forward_speed = math.min(surface_speeds[surface], result.forward_speed) + result.backward_speed = math.min(surface_speeds[surface], result.backward_speed) end -- maxspeed