From 6cfe4f7ded681c4f355cf1cfac5dca2eed6ac790 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Mon, 29 Apr 2013 19:03:24 +0200 Subject: [PATCH] mode in each direction when speeds are the same --- Extractor/ExtractorCallbacks.cpp | 7 +++++-- features/step_definitions/routing.rb | 10 +++++----- features/testbot/mode.feature | 30 ++++++++++++++++++++++++++++ profiles/testbot.lua | 8 ++++++++ 4 files changed, 48 insertions(+), 7 deletions(-) diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index 09885f824..1ddcdfda2 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -93,10 +93,13 @@ void ExtractorCallbacks::wayFunction(ExtractionWay &parsed_way) { if(ExtractionWay::opposite == parsed_way.direction) { std::reverse( parsed_way.path.begin(), parsed_way.path.end() ); parsed_way.direction = ExtractionWay::oneway; + std::swap( parsed_way.forward_mode, parsed_way.backward_mode ); } - const bool split_bidirectional_edge = (parsed_way.backward_speed > 0) && (parsed_way.speed != parsed_way.backward_speed); - + bool split_bidirectional_edge = + ((parsed_way.backward_speed > 0) && (parsed_way.speed != parsed_way.backward_speed)) || + ((ExtractionWay::bidirectional == parsed_way.direction) && (parsed_way.forward_mode != parsed_way.backward_mode)); + for(std::vector< NodeID >::size_type n = 0; n < parsed_way.path.size()-1; ++n) { externalMemory->allEdges.push_back( InternalExtractorEdge(parsed_way.path[n], diff --git a/features/step_definitions/routing.rb b/features/step_definitions/routing.rb index 13c8b6a04..581bb39c4 100644 --- a/features/step_definitions/routing.rb +++ b/features/step_definitions/routing.rb @@ -64,20 +64,20 @@ When /^I route I should get$/ do |table| got['distance'] = instructions ? "#{json['route_summary']['total_distance'].to_s}m" : '' end if table.headers.include?('time') - raise "*** Time must be specied in seconds. (ex: 60s)" unless row['time'] =~ /\d+s/ + raise "*** Time must be specied in seconds. (ex: 60s)" unless row['time']=='' || row['time'] =~ /\d+s/ got['time'] = instructions ? "#{json['route_summary']['total_time'].to_s}s" : '' end if table.headers.include? 'bearing' - got['bearing'] = bearings + got['bearing'] = instructions ? bearings : '' end if table.headers.include? 'compass' - got['compass'] = compasses + got['compass'] = instructions ? compasses : '' end if table.headers.include? 'turns' - got['turns'] = turns + got['turns'] = instructions ? turns : '' end if table.headers.include? 'modes' - got['modes'] = modes + got['modes'] = instructions ? modes : '' end if table.headers.include? '#' # comment column got['#'] = row['#'] # copy value so it always match diff --git a/features/testbot/mode.feature b/features/testbot/mode.feature index 4d6132b2e..eb6af1d96 100644 --- a/features/testbot/mode.feature +++ b/features/testbot/mode.feature @@ -6,6 +6,8 @@ Feature: Testbot - Mode flag # 2 route # 3 river downstream # 4 river upstream +# 5 steps down +# 6 steps up Background: Given the profile "testbot" @@ -80,3 +82,31 @@ Feature: Testbot - Mode flag | from | to | route | modes | | 0 | 1 | ab | 3 | | 1 | 0 | ab | 4 | + + Scenario: Testbot - Modes in each direction (same speed in both direction) + Given the node map + | | 0 | 1 | | + | a | | | b | + + And the ways + | nodes | highway | + | ab | steps | + + When I route I should get + | from | to | route | modes | time | + | 0 | 1 | ab | 5 | 60s +-1 | + | 1 | 0 | ab | 6 | 60s +-1 | + + Scenario: Testbot - Modes for opposite direction + Given the node map + | | 0 | 1 | | + | a | | | b | + + And the ways + | nodes | highway | oneway | + | ab | steps | -1 | + + When I route I should get + | from | to | route | modes | + | 0 | 1 | | | + | 1 | 0 | ab | 6 | diff --git a/profiles/testbot.lua b/profiles/testbot.lua index df1d8481b..1dcc60d92 100644 --- a/profiles/testbot.lua +++ b/profiles/testbot.lua @@ -11,11 +11,14 @@ -- 2: route -- 3: river downstream -- 4: river upstream +-- 5: steps down +-- 6: steps up speed_profile = { ["primary"] = 36, ["secondary"] = 18, ["tertiary"] = 12, + ["steps"] = 6, ["default"] = 24 } @@ -90,6 +93,11 @@ function way_function (way) way.backward_mode = 4 end + if highway == "steps" then + way.forward_mode = 5 + way.backward_mode = 6 + end + if maxspeed_forward ~= nil and maxspeed_forward > 0 then speed_forw = maxspeed_forward else