diff --git a/include/engine/api/route_api.hpp b/include/engine/api/route_api.hpp index d4a9cdd5e..9210a36f9 100644 --- a/include/engine/api/route_api.hpp +++ b/include/engine/api/route_api.hpp @@ -93,8 +93,7 @@ class RouteAPI : public BaseAPI auto leg_geometry = guidance::assembleGeometry( BaseAPI::facade, path_data, phantoms.source_phantom, phantoms.target_phantom); auto leg = guidance::assembleLeg(BaseAPI::facade, path_data, leg_geometry, - phantoms.source_phantom, phantoms.target_phantom, - reversed_source, reversed_target); + phantoms.target_phantom, reversed_target); if (parameters.steps) { diff --git a/include/engine/guidance/assemble_leg.hpp b/include/engine/guidance/assemble_leg.hpp index a41ec217c..6f0b168c0 100644 --- a/include/engine/guidance/assemble_leg.hpp +++ b/include/engine/guidance/assemble_leg.hpp @@ -96,18 +96,12 @@ template RouteLeg assembleLeg(const DataFacadeT &facade, const std::vector &route_data, const LegGeometry &leg_geometry, - const PhantomNode &source_node, const PhantomNode &target_node, - const bool source_traversed_in_reverse, const bool target_traversed_in_reverse) { - const auto source_duration = - (source_traversed_in_reverse ? source_node.GetReverseWeightPlusOffset() - : source_node.GetForwardWeightPlusOffset()) / - 10.; const auto target_duration = - (target_traversed_in_reverse ? target_node.GetReverseWeightPlusOffset() - : target_node.GetForwardWeightPlusOffset()) / + (target_traversed_in_reverse ? target_node.reverse_weight + : target_node.forward_weight) / 10.; auto distance = std::accumulate(leg_geometry.segment_distances.begin(), @@ -136,13 +130,9 @@ RouteLeg assembleLeg(const DataFacadeT &facade, // The phantom node of t will contain: // `forward_weight`: duration of (d,t) // `forward_offset`: duration of (c, d) - // - // TODO discuss, this should not be the case after danpats fixes - // The PathData will contain entries of b, c and d. But only c will contain - // a duration value since its the only point associated with a turn. - // As such we want to slice of the duration for (a,s) and add the duration for - // (c,d,t) - duration = duration - source_duration + target_duration; + // path_data will have entries for (s,b), (b, c), (c, d) but (d, t) is only + // caputed by the phantom node. So we need to add the target duration here. + duration = duration + target_duration; auto summary_array = detail::summarizeRoute(route_data); BOOST_ASSERT(detail::MAX_USED_SEGMENTS > 0); diff --git a/include/engine/guidance/assemble_steps.hpp b/include/engine/guidance/assemble_steps.hpp index 874efeaaa..488c4a3e6 100644 --- a/include/engine/guidance/assemble_steps.hpp +++ b/include/engine/guidance/assemble_steps.hpp @@ -41,12 +41,12 @@ std::vector assembleSteps(const DataFacadeT &facade, const bool target_traversed_in_reverse) { const EdgeWeight source_duration = - source_traversed_in_reverse ? source_node.forward_weight : source_node.reverse_weight; + source_traversed_in_reverse ? source_node.reverse_weight : source_node.forward_weight; const auto source_mode = source_traversed_in_reverse ? source_node.backward_travel_mode : source_node.forward_travel_mode; const EdgeWeight target_duration = - target_traversed_in_reverse ? target_node.forward_weight : target_node.reverse_weight; + target_traversed_in_reverse ? target_node.reverse_weight : target_node.forward_weight; const auto target_mode = target_traversed_in_reverse ? target_node.backward_travel_mode : target_node.forward_travel_mode; diff --git a/include/engine/routing_algorithms/routing_base.hpp b/include/engine/routing_algorithms/routing_base.hpp index 1d3164c9d..92bbf1f60 100644 --- a/include/engine/routing_algorithms/routing_base.hpp +++ b/include/engine/routing_algorithms/routing_base.hpp @@ -299,8 +299,7 @@ template class BasicRoutingInterface weight_vector); BOOST_ASSERT(weight_vector.size() > 0); - auto total_weight = - std::accumulate(weight_vector.begin(), weight_vector.end(), 0); + auto total_weight = std::accumulate(weight_vector.begin(), weight_vector.end(), 0); BOOST_ASSERT(weight_vector.size() == id_vector.size()); // ed.distance should be total_weight + penalties (turn, stop, etc) @@ -330,6 +329,9 @@ template class BasicRoutingInterface if (is_first_segment) { + auto source_weight = start_traversed_in_reverse + ? phantom_node_pair.source_phantom.reverse_weight + : phantom_node_pair.source_phantom.forward_weight; // Given this geometry: // U---v---w---x---Z // s @@ -337,12 +339,8 @@ template class BasicRoutingInterface // However the first segment duration needs to be adjusted to the fact that the // source phantom is in the middle of the segment. // We do this by subtracting v--s from the duration. - BOOST_ASSERT(unpacked_path.front().duration_until_turn >= - phantom_node_pair.source_phantom.forward_weight); - unpacked_path.front().duration_until_turn -= - start_traversed_in_reverse - ? phantom_node_pair.source_phantom.forward_weight - : phantom_node_pair.source_phantom.reverse_weight; + BOOST_ASSERT(unpacked_path.front().duration_until_turn >= source_weight); + unpacked_path.front().duration_until_turn -= source_weight; } } } @@ -388,7 +386,7 @@ template class BasicRoutingInterface // s: fwd_segment 0 // t: fwd_segment 3 // -> (U, v), (v, w), (w, x) - // note that (x, t) is _not_ included but needs to + // note that (x, t) is _not_ included but needs to be added later. for (std::size_t i = start_index; i != end_index; (start_index < end_index ? ++i : --i)) { BOOST_ASSERT(i < id_vector.size()); @@ -403,14 +401,15 @@ template class BasicRoutingInterface if (is_local_path && unpacked_path.size() > 0) { + auto source_weight = start_traversed_in_reverse + ? phantom_node_pair.source_phantom.reverse_weight + : phantom_node_pair.source_phantom.forward_weight; // The above code will create segments for (v, w), (w,x), (x, y) and (y, Z). // However the first segment duration needs to be adjusted to the fact that the source - // phantom - // is in the middle of the segment. We do this by subtracting v--s from the duration. - BOOST_ASSERT(unpacked_path.front().duration_until_turn >= - phantom_node_pair.source_phantom.forward_weight); - unpacked_path.front().duration_until_turn -= - phantom_node_pair.source_phantom.forward_weight; + // phantom is in the middle of the segment. We do this by subtracting v--s from the + // duration. + BOOST_ASSERT(unpacked_path.front().duration_until_turn >= source_weight); + unpacked_path.front().duration_until_turn -= source_weight; } // there is no equivalent to a node-based node in an edge-expanded graph.