From 0bfbe5ad165fffbcdd7982b3e3f517e92ba46980 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Thu, 6 Jul 2017 13:57:07 +0200 Subject: [PATCH] handle startpoint in bicycle profile, add tests --- features/bicycle/ferry.feature | 6 +- features/bicycle/startpoint.feature | 53 +++++++++++++++++ features/bicycle/train.feature | 88 ++++++++++++++++++++--------- features/car/startpoint.feature | 37 ++++++++++++ features/foot/startpoint.feature | 37 ++++++++++++ profiles/bicycle.lua | 4 +- 6 files changed, 193 insertions(+), 32 deletions(-) create mode 100644 features/bicycle/startpoint.feature create mode 100644 features/car/startpoint.feature create mode 100644 features/foot/startpoint.feature diff --git a/features/bicycle/ferry.feature b/features/bicycle/ferry.feature index 3b3950c49..8319248b1 100644 --- a/features/bicycle/ferry.feature +++ b/features/bicycle/ferry.feature @@ -64,6 +64,6 @@ Feature: Bike - Handle ferry routes | abcd | | ferry | yes | 1:00 | When I route I should get - | from | to | route | time | - | a | d | abcd,abcd | 3600s | - | d | a | abcd,abcd | 3600s | + | from | to | route | time | + | a | d | abcd,abcd | 3600s +-5 | + | d | a | abcd,abcd | 3600s +-5 | diff --git a/features/bicycle/startpoint.feature b/features/bicycle/startpoint.feature new file mode 100644 index 000000000..eae49668f --- /dev/null +++ b/features/bicycle/startpoint.feature @@ -0,0 +1,53 @@ +@routing @bicycle @startpoint +Feature: Bike - Allowed start/end modes + + Background: + Given the profile "bicycle" + + Scenario: Bike - Don't start/stop on ferries + Given the node map + """ + a 1 b 2 c + """ + + And the ways + | nodes | highway | route | bicycle | + | ab | primary | | | + | bc | | ferry | yes | + + When I route I should get + | from | to | route | modes | + | 1 | 2 | ab,ab | cycling,cycling | + | 2 | 1 | ab,ab | cycling,cycling | + + Scenario: Bike - Don't start/stop on trains + Given the node map + """ + a 1 b 2 c + """ + + And the ways + | nodes | highway | railway | bicycle | + | ab | primary | | | + | bc | | train | yes | + + When I route I should get + | from | to | route | modes | + | 1 | 2 | ab,ab | cycling,cycling | + | 2 | 1 | ab,ab | cycling,cycling | + + Scenario: Bike - OK to start pushing bike + Given the node map + """ + a 1 b 2 c + """ + + And the ways + | nodes | highway | + | ab | primary | + | bc | steps | + + When I route I should get + | from | to | route | modes | + | 1 | 2 | ab,bc,bc | cycling,pushing bike,pushing bike | + | 2 | 1 | bc,ab,ab | pushing bike,cycling,cycling | diff --git a/features/bicycle/train.feature b/features/bicycle/train.feature index c075cbc34..be914492c 100644 --- a/features/bicycle/train.feature +++ b/features/bicycle/train.feature @@ -1,39 +1,71 @@ @routing @bicycle @train Feature: Bike - Handle ferry routes # Bringing bikes on trains and subways +# We cannot currently use a 'routability' type test, since the bike +# profile does not allow starting/stopping on trains, and +# it's not possible to modify the bicycle profile table because it's +# defined as local. Background: Given the profile "bicycle" Scenario: Bike - Bringing bikes on trains - Then routability should be - | highway | railway | bicycle | bothw | - | primary | | | cycling | - | (nil) | train | | | - | (nil) | train | no | | - | (nil) | train | yes | train | - | (nil) | railway | | | - | (nil) | railway | no | | - | (nil) | railway | yes | train | - | (nil) | subway | | | - | (nil) | subway | no | | - | (nil) | subway | yes | train | - | (nil) | tram | | | - | (nil) | tram | no | | - | (nil) | tram | yes | train | - | (nil) | light_rail | | | - | (nil) | light_rail | no | | - | (nil) | light_rail | yes | train | - | (nil) | monorail | | | - | (nil) | monorail | no | | - | (nil) | monorail | yes | train | - | (nil) | some_tag | | | - | (nil) | some_tag | no | | - | (nil) | some_tag | yes | cycling | + Given the node map + """ + a 1 b c 2 d e 3 f g 4 h + """ + + And the ways + | nodes | highway | railway | bicycle | + | ab | primary | | | + | cd | primary | | | + | ef | primary | | | + | gh | primary | | | + | bc | | train | | + | de | | train | yes | + | fg | | train | no | + + When I route I should get + | from | to | route | + | 1 | 2 | | + | 2 | 3 | cd,de,ef,ef | + | 3 | 4 | | + + Scenario: Bike - Bringing bikes on trains, invalid railway tag is accepted if access specified + Given the node map + """ + a 1 b c 2 d e 3 f g 4 h + """ + + And the ways + | nodes | highway | railway | bicycle | + | ab | primary | | | + | cd | primary | | | + | ef | primary | | | + | gh | primary | | | + | bc | | invalid_tag | | + | de | | invalid_tag | yes | + | fg | | invalid_tag | no | + + When I route I should get + | from | to | route | + | 1 | 2 | | + | 2 | 3 | cd,de,ef| + | 3 | 4 | | @construction Scenario: Bike - Don't route on railways under construction - Then routability should be - | highway | railway | bicycle | bothw | - | primary | | | cycling | - | (nil) | construction | yes | | + Given the node map + """ + a 1 b c 2 d + """ + + And the ways + | nodes | highway | railway | bicycle | + | ab | primary | | | + | cd | primary | | | + | bc | | construction | yes | + + When I route I should get + | from | to | route | + | 1 | 2 | | diff --git a/features/car/startpoint.feature b/features/car/startpoint.feature new file mode 100644 index 000000000..965f57d43 --- /dev/null +++ b/features/car/startpoint.feature @@ -0,0 +1,37 @@ +@routing @car @startpoint +Feature: Car - Allowed start/end modes + + Background: + Given the profile "car" + + Scenario: Car - Don't start/stop on ferries + Given the node map + """ + a 1 b 2 c + """ + + And the ways + | nodes | highway | route | bicycle | + | ab | primary | | | + | bc | | ferry | yes | + + When I route I should get + | from | to | route | modes | + | 1 | 2 | ab,ab | driving,driving | + | 2 | 1 | ab,ab | driving,driving | + + Scenario: Car - Don't start/stop on trains + Given the node map + """ + a 1 b 2 c + """ + + And the ways + | nodes | highway | railway | bicycle | + | ab | primary | | | + | bc | | train | yes | + + When I route I should get + | from | to | route | modes | + | 1 | 2 | ab,ab | driving,driving | + | 2 | 1 | ab,ab | driving,driving | diff --git a/features/foot/startpoint.feature b/features/foot/startpoint.feature new file mode 100644 index 000000000..37370915c --- /dev/null +++ b/features/foot/startpoint.feature @@ -0,0 +1,37 @@ +@routing @foot @startpoint +Feature: Foot - Allowed start/end modes + + Background: + Given the profile "foot" + + Scenario: Foot - Don't start/stop on ferries + Given the node map + """ + a 1 b 2 c + """ + + And the ways + | nodes | highway | route | bicycle | + | ab | primary | | | + | bc | | ferry | yes | + + When I route I should get + | from | to | route | modes | + | 1 | 2 | ab,ab | walking,walking | + | 2 | 1 | ab,ab | walking,walking | + + Scenario: Foot - Don't start/stop on trains + Given the node map + """ + a 1 b 2 c + """ + + And the ways + | nodes | highway | railway | bicycle | + | ab | primary | | | + | bc | | train | yes | + + When I route I should get + | from | to | route | modes | + | 1 | 2 | ab,ab | walking,walking | + | 2 | 1 | ab,ab | walking,walking | diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index faa3a3920..a6a2926ef 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -543,7 +543,9 @@ function way_function (way, result) -- handle various other flags 'handle_roundabouts', - --'handle_startpoint', + + -- handle allowed start/end modes + 'handle_startpoint', -- set name, ref and pronunciation 'handle_names'