Fix bug in refactor

This commit is contained in:
Patrick Niklaus 2017-02-28 23:43:11 +00:00 committed by Patrick Niklaus
parent 30ff0fa977
commit 0ac1f99f9c
7 changed files with 45 additions and 40 deletions

View File

@ -70,6 +70,8 @@ template <typename AlgorithmT> class RoutingAlgorithms final : public RoutingAlg
{ {
} }
virtual ~RoutingAlgorithms() = default;
InternalRouteResult InternalRouteResult
AlternativePathSearch(const PhantomNodes &phantom_node_pair) const final override AlternativePathSearch(const PhantomNodes &phantom_node_pair) const final override
{ {

View File

@ -128,7 +128,7 @@ we need to add an offset to the termination criterion.
static constexpr bool ENABLE_STALLING = true; static constexpr bool ENABLE_STALLING = true;
static constexpr bool DISABLE_STALLING = false; static constexpr bool DISABLE_STALLING = false;
static constexpr bool DO_NOT_FORCE_LOOPS = false; static constexpr bool DO_NOT_FORCE_LOOPS = false;
template<bool DIRECTION, bool STALLING=ENABLE_STALLING> template <bool DIRECTION, bool STALLING = ENABLE_STALLING>
void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade, void routingStep(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::CH> &facade,
SearchEngineData::QueryHeap &forward_heap, SearchEngineData::QueryHeap &forward_heap,
SearchEngineData::QueryHeap &reverse_heap, SearchEngineData::QueryHeap &reverse_heap,

View File

@ -81,11 +81,11 @@ ViaRoutePlugin::HandleRequest(const datafacade::ContiguousInternalMemoryDataFaca
? *route_parameters.continue_straight ? *route_parameters.continue_straight
: facade.GetContinueStraightDefault(); : facade.GetContinueStraightDefault();
InternalRouteResult raw_route; std::vector<PhantomNodes> start_end_nodes;
auto build_phantom_pairs = [&raw_route, continue_straight_at_waypoint]( auto build_phantom_pairs = [&start_end_nodes, continue_straight_at_waypoint](
const PhantomNode &first_node, const PhantomNode &second_node) { const PhantomNode &first_node, const PhantomNode &second_node) {
raw_route.segment_end_coordinates.push_back(PhantomNodes{first_node, second_node}); start_end_nodes.push_back(PhantomNodes{first_node, second_node});
auto &last_inserted = raw_route.segment_end_coordinates.back(); auto &last_inserted = start_end_nodes.back();
// enable forward direction if possible // enable forward direction if possible
if (last_inserted.source_phantom.forward_segment_id.id != SPECIAL_SEGMENTID) if (last_inserted.source_phantom.forward_segment_id.id != SPECIAL_SEGMENTID)
{ {
@ -101,20 +101,20 @@ ViaRoutePlugin::HandleRequest(const datafacade::ContiguousInternalMemoryDataFaca
}; };
util::for_each_pair(snapped_phantoms, build_phantom_pairs); util::for_each_pair(snapped_phantoms, build_phantom_pairs);
if (1 == raw_route.segment_end_coordinates.size() && algorithms.HasAlternativePathSearch() && InternalRouteResult raw_route;
if (1 == start_end_nodes.size() && algorithms.HasAlternativePathSearch() &&
route_parameters.alternatives) route_parameters.alternatives)
{ {
raw_route = algorithms.AlternativePathSearch(raw_route.segment_end_coordinates.front()); raw_route = algorithms.AlternativePathSearch(start_end_nodes.front());
} }
else if (1 == raw_route.segment_end_coordinates.size() && else if (1 == start_end_nodes.size() && algorithms.HasDirectShortestPathSearch())
algorithms.HasDirectShortestPathSearch())
{ {
raw_route = algorithms.DirectShortestPathSearch(raw_route.segment_end_coordinates.front()); raw_route = algorithms.DirectShortestPathSearch(start_end_nodes.front());
} }
else else
{ {
raw_route = algorithms.ShortestPathSearch(raw_route.segment_end_coordinates, raw_route =
route_parameters.continue_straight); algorithms.ShortestPathSearch(start_end_nodes, route_parameters.continue_straight);
} }
// we can only know this after the fact, different SCC ids still // we can only know this after the fact, different SCC ids still

View File

@ -567,6 +567,7 @@ alternativePathSearch(SearchEngineData &engine_working_data,
const PhantomNodes &phantom_node_pair) const PhantomNodes &phantom_node_pair)
{ {
InternalRouteResult raw_route_data; InternalRouteResult raw_route_data;
raw_route_data.segment_end_coordinates = {phantom_node_pair};
std::vector<NodeID> alternative_path; std::vector<NodeID> alternative_path;
std::vector<NodeID> via_node_candidate_list; std::vector<NodeID> via_node_candidate_list;
std::vector<SearchSpaceEdge> forward_search_space; std::vector<SearchSpaceEdge> forward_search_space;

View File

@ -56,6 +56,7 @@ extractRoute(const datafacade::ContiguousInternalMemoryDataFacade<AlgorithmT> &f
const PhantomNodes &nodes) const PhantomNodes &nodes)
{ {
InternalRouteResult raw_route_data; InternalRouteResult raw_route_data;
raw_route_data.segment_end_coordinates = {nodes};
// No path found for both target nodes? // No path found for both target nodes?
if (INVALID_EDGE_WEIGHT == weight) if (INVALID_EDGE_WEIGHT == weight)
{ {

View File

@ -183,13 +183,13 @@ void search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::Core
else else
{ {
routingStep<FORWARD_DIRECTION>(facade, routingStep<FORWARD_DIRECTION>(facade,
forward_heap, forward_heap,
reverse_heap, reverse_heap,
middle, middle,
weight, weight,
min_edge_offset, min_edge_offset,
force_loop_forward, force_loop_forward,
force_loop_reverse); force_loop_reverse);
} }
} }
if (!reverse_heap.Empty()) if (!reverse_heap.Empty())
@ -203,13 +203,13 @@ void search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::Core
else else
{ {
routingStep<REVERSE_DIRECTION>(facade, routingStep<REVERSE_DIRECTION>(facade,
reverse_heap, reverse_heap,
forward_heap, forward_heap,
middle, middle,
weight, weight,
min_edge_offset, min_edge_offset,
force_loop_reverse, force_loop_reverse,
force_loop_forward); force_loop_forward);
} }
} }
} }
@ -253,22 +253,22 @@ void search(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::Core
weight > (forward_core_heap.MinKey() + reverse_core_heap.MinKey())) weight > (forward_core_heap.MinKey() + reverse_core_heap.MinKey()))
{ {
routingStep<FORWARD_DIRECTION, DISABLE_STALLING>(facade, routingStep<FORWARD_DIRECTION, DISABLE_STALLING>(facade,
forward_core_heap, forward_core_heap,
reverse_core_heap, reverse_core_heap,
middle, middle,
weight, weight,
min_core_edge_offset, min_core_edge_offset,
force_loop_forward, force_loop_forward,
force_loop_reverse); force_loop_reverse);
routingStep<REVERSE_DIRECTION, DISABLE_STALLING>(facade, routingStep<REVERSE_DIRECTION, DISABLE_STALLING>(facade,
reverse_core_heap, reverse_core_heap,
forward_core_heap, forward_core_heap,
middle, middle,
weight, weight,
min_core_edge_offset, min_core_edge_offset,
force_loop_reverse, force_loop_reverse,
force_loop_forward); force_loop_forward);
} }
// No path found for both target nodes? // No path found for both target nodes?

View File

@ -235,6 +235,7 @@ shortestPathSearchImpl(SearchEngineData &engine_working_data,
const boost::optional<bool> continue_straight_at_waypoint) const boost::optional<bool> continue_straight_at_waypoint)
{ {
InternalRouteResult raw_route_data; InternalRouteResult raw_route_data;
raw_route_data.segment_end_coordinates = phantom_nodes_vector;
const bool allow_uturn_at_waypoint = const bool allow_uturn_at_waypoint =
!(continue_straight_at_waypoint ? *continue_straight_at_waypoint !(continue_straight_at_waypoint ? *continue_straight_at_waypoint
: facade.GetContinueStraightDefault()); : facade.GetContinueStraightDefault());