From cc0bbc42a220bf8e127e88ec1c15ef97f00f3598 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Mon, 29 Sep 2014 11:37:36 +0200 Subject: [PATCH] add duration to backward speed, fixes #1192 --- Extractor/ExtractorCallbacks.cpp | 6 ++++-- features/car/ferry.feature | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index c2cc693c323..7702f1de84d 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -63,8 +63,8 @@ bool ExtractorCallbacks::ProcessRestriction(const InputRestrictionContainer &res /** warning: caller needs to take care of synchronization! */ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) { - if (((0 >= parsed_way.forward_speed) || - (TRAVEL_MODE_INACCESSIBLE == parsed_way.forward_travel_mode)) && + if (((0 >= parsed_way.forward_speed) || + (TRAVEL_MODE_INACCESSIBLE == parsed_way.forward_travel_mode)) && ((0 >= parsed_way.backward_speed) || (TRAVEL_MODE_INACCESSIBLE == parsed_way.backward_travel_mode)) && (0 >= parsed_way.duration)) @@ -89,6 +89,7 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) // TODO: iterate all way segments and set duration corresponding to the length of each // segment parsed_way.forward_speed = parsed_way.duration / (parsed_way.path.size() - 1); + parsed_way.backward_speed = parsed_way.duration / (parsed_way.path.size() - 1); } if (std::numeric_limits::epsilon() >= std::abs(-1. - parsed_way.forward_speed)) @@ -155,6 +156,7 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) { // Only true if the way should be split BOOST_ASSERT(parsed_way.backward_travel_mode>0); std::reverse(parsed_way.path.begin(), parsed_way.path.end()); + for (std::vector::size_type n = 0; n < parsed_way.path.size() - 1; ++n) { external_memory.all_edges_list.push_back( diff --git a/features/car/ferry.feature b/features/car/ferry.feature index 7d16c2ed200..a599c913659 100644 --- a/features/car/ferry.feature +++ b/features/car/ferry.feature @@ -26,3 +26,20 @@ Feature: Car - Handle ferry routes | c | e | cde | 2 | | c | f | cde,efg | 2,1 | | c | g | cde,efg | 2,1 | + + Scenario: Car - Properly handle durations + Given the node map + | a | b | c | | | + | | | d | | | + | | | e | f | g | + + And the ways + | nodes | highway | route | duration | + | abc | primary | | | + | cde | | ferry | 06:15 | + | efg | primary | | | + + When I route I should get + | from | to | route | modes | speed | + | a | g | abc,cde,efg | 1,2,1 | 6 km/h | + | b | f | abc,cde,efg | 1,2,1 | 6 km/h |