Format with clang-format 3.8
This commit is contained in:
@@ -130,16 +130,22 @@ class AlternativeRouting final
|
||||
{
|
||||
if (0 < forward_heap1.Size())
|
||||
{
|
||||
AlternativeRoutingStep<true>(forward_heap1, reverse_heap1, &middle_node,
|
||||
AlternativeRoutingStep<true>(forward_heap1,
|
||||
reverse_heap1,
|
||||
&middle_node,
|
||||
&upper_bound_to_shortest_path_distance,
|
||||
via_node_candidate_list, forward_search_space,
|
||||
via_node_candidate_list,
|
||||
forward_search_space,
|
||||
min_edge_offset);
|
||||
}
|
||||
if (0 < reverse_heap1.Size())
|
||||
{
|
||||
AlternativeRoutingStep<false>(forward_heap1, reverse_heap1, &middle_node,
|
||||
AlternativeRoutingStep<false>(forward_heap1,
|
||||
reverse_heap1,
|
||||
&middle_node,
|
||||
&upper_bound_to_shortest_path_distance,
|
||||
via_node_candidate_list, reverse_search_space,
|
||||
via_node_candidate_list,
|
||||
reverse_search_space,
|
||||
min_edge_offset);
|
||||
}
|
||||
}
|
||||
@@ -168,10 +174,10 @@ class AlternativeRouting final
|
||||
else
|
||||
{
|
||||
|
||||
super::RetrievePackedPathFromSingleHeap(forward_heap1, middle_node,
|
||||
packed_forward_path);
|
||||
super::RetrievePackedPathFromSingleHeap(reverse_heap1, middle_node,
|
||||
packed_reverse_path);
|
||||
super::RetrievePackedPathFromSingleHeap(
|
||||
forward_heap1, middle_node, packed_forward_path);
|
||||
super::RetrievePackedPathFromSingleHeap(
|
||||
reverse_heap1, middle_node, packed_reverse_path);
|
||||
}
|
||||
|
||||
// this set is is used as an indicator if a node is on the shortest path
|
||||
@@ -271,8 +277,8 @@ class AlternativeRouting final
|
||||
{
|
||||
std::reverse(packed_shortest_path.begin(), packed_shortest_path.end());
|
||||
packed_shortest_path.emplace_back(middle_node);
|
||||
packed_shortest_path.insert(packed_shortest_path.end(), packed_reverse_path.begin(),
|
||||
packed_reverse_path.end());
|
||||
packed_shortest_path.insert(
|
||||
packed_shortest_path.end(), packed_reverse_path.begin(), packed_reverse_path.end());
|
||||
}
|
||||
std::vector<RankedCandidateNode> ranked_candidates_list;
|
||||
|
||||
@@ -280,8 +286,11 @@ class AlternativeRouting final
|
||||
for (const NodeID node : preselected_node_list)
|
||||
{
|
||||
int length_of_via_path = 0, sharing_of_via_path = 0;
|
||||
ComputeLengthAndSharingOfViaPath(node, &length_of_via_path, &sharing_of_via_path,
|
||||
packed_shortest_path, min_edge_offset);
|
||||
ComputeLengthAndSharingOfViaPath(node,
|
||||
&length_of_via_path,
|
||||
&sharing_of_via_path,
|
||||
packed_shortest_path,
|
||||
min_edge_offset);
|
||||
const int maximum_allowed_sharing =
|
||||
static_cast<int>(upper_bound_to_shortest_path_distance * VIAPATH_GAMMA);
|
||||
if (sharing_of_via_path <= maximum_allowed_sharing &&
|
||||
@@ -297,10 +306,16 @@ class AlternativeRouting final
|
||||
NodeID s_v_middle = SPECIAL_NODEID, v_t_middle = SPECIAL_NODEID;
|
||||
for (const RankedCandidateNode &candidate : ranked_candidates_list)
|
||||
{
|
||||
if (ViaNodeCandidatePassesTTest(
|
||||
forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, candidate,
|
||||
upper_bound_to_shortest_path_distance, &length_of_via_path, &s_v_middle,
|
||||
&v_t_middle, min_edge_offset))
|
||||
if (ViaNodeCandidatePassesTTest(forward_heap1,
|
||||
reverse_heap1,
|
||||
forward_heap2,
|
||||
reverse_heap2,
|
||||
candidate,
|
||||
upper_bound_to_shortest_path_distance,
|
||||
&length_of_via_path,
|
||||
&s_v_middle,
|
||||
&v_t_middle,
|
||||
min_edge_offset))
|
||||
{
|
||||
// select first admissable
|
||||
selected_via_node = candidate.node;
|
||||
@@ -322,7 +337,8 @@ class AlternativeRouting final
|
||||
|
||||
super::UnpackPath(
|
||||
// -- packed input
|
||||
packed_shortest_path.begin(), packed_shortest_path.end(),
|
||||
packed_shortest_path.begin(),
|
||||
packed_shortest_path.end(),
|
||||
// -- start of route
|
||||
phantom_node_pair,
|
||||
// -- unpacked output
|
||||
@@ -334,8 +350,13 @@ class AlternativeRouting final
|
||||
{
|
||||
std::vector<NodeID> packed_alternate_path;
|
||||
// retrieve alternate path
|
||||
RetrievePackedAlternatePath(forward_heap1, reverse_heap1, forward_heap2, reverse_heap2,
|
||||
s_v_middle, v_t_middle, packed_alternate_path);
|
||||
RetrievePackedAlternatePath(forward_heap1,
|
||||
reverse_heap1,
|
||||
forward_heap2,
|
||||
reverse_heap2,
|
||||
s_v_middle,
|
||||
v_t_middle,
|
||||
packed_alternate_path);
|
||||
|
||||
raw_route_data.alt_source_traversed_in_reverse.push_back(
|
||||
(packed_alternate_path.front() !=
|
||||
@@ -345,8 +366,10 @@ class AlternativeRouting final
|
||||
phantom_node_pair.target_phantom.forward_segment_id.id));
|
||||
|
||||
// unpack the alternate path
|
||||
super::UnpackPath(packed_alternate_path.begin(), packed_alternate_path.end(),
|
||||
phantom_node_pair, raw_route_data.unpacked_alternative);
|
||||
super::UnpackPath(packed_alternate_path.begin(),
|
||||
packed_alternate_path.end(),
|
||||
phantom_node_pair,
|
||||
raw_route_data.unpacked_alternative);
|
||||
|
||||
raw_route_data.alternative_path_length = length_of_via_path;
|
||||
}
|
||||
@@ -372,8 +395,8 @@ class AlternativeRouting final
|
||||
packed_path.pop_back(); // remove middle node. It's in both half-paths
|
||||
|
||||
// fetch patched path [v,t]
|
||||
super::RetrievePackedPathFromHeap(forward_heap2, reverse_heap1, v_t_middle,
|
||||
packed_v_t_path);
|
||||
super::RetrievePackedPathFromHeap(
|
||||
forward_heap2, reverse_heap1, v_t_middle, packed_v_t_path);
|
||||
|
||||
packed_path.insert(packed_path.end(), packed_v_t_path.begin(), packed_v_t_path.end());
|
||||
}
|
||||
@@ -410,9 +433,15 @@ class AlternativeRouting final
|
||||
const bool constexpr DO_NOT_FORCE_LOOPS = false;
|
||||
while (!new_reverse_heap.Empty())
|
||||
{
|
||||
super::RoutingStep(new_reverse_heap, existing_forward_heap, s_v_middle,
|
||||
upper_bound_s_v_path_length, min_edge_offset, false,
|
||||
STALLING_ENABLED, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS);
|
||||
super::RoutingStep(new_reverse_heap,
|
||||
existing_forward_heap,
|
||||
s_v_middle,
|
||||
upper_bound_s_v_path_length,
|
||||
min_edge_offset,
|
||||
false,
|
||||
STALLING_ENABLED,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS);
|
||||
}
|
||||
// compute path <v,..,t> by reusing backward search from node t
|
||||
NodeID v_t_middle = SPECIAL_NODEID;
|
||||
@@ -420,9 +449,15 @@ class AlternativeRouting final
|
||||
new_forward_heap.Insert(via_node, 0, via_node);
|
||||
while (!new_forward_heap.Empty())
|
||||
{
|
||||
super::RoutingStep(new_forward_heap, existing_reverse_heap, v_t_middle,
|
||||
upper_bound_of_v_t_path_length, min_edge_offset, true,
|
||||
STALLING_ENABLED, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS);
|
||||
super::RoutingStep(new_forward_heap,
|
||||
existing_reverse_heap,
|
||||
v_t_middle,
|
||||
upper_bound_of_v_t_path_length,
|
||||
min_edge_offset,
|
||||
true,
|
||||
STALLING_ENABLED,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS);
|
||||
}
|
||||
*real_length_of_via_path = upper_bound_s_v_path_length + upper_bound_of_v_t_path_length;
|
||||
|
||||
@@ -432,10 +467,10 @@ class AlternativeRouting final
|
||||
}
|
||||
|
||||
// retrieve packed paths
|
||||
super::RetrievePackedPathFromHeap(existing_forward_heap, new_reverse_heap, s_v_middle,
|
||||
packed_s_v_path);
|
||||
super::RetrievePackedPathFromHeap(new_forward_heap, existing_reverse_heap, v_t_middle,
|
||||
packed_v_t_path);
|
||||
super::RetrievePackedPathFromHeap(
|
||||
existing_forward_heap, new_reverse_heap, s_v_middle, packed_s_v_path);
|
||||
super::RetrievePackedPathFromHeap(
|
||||
new_forward_heap, existing_reverse_heap, v_t_middle, packed_v_t_path);
|
||||
|
||||
// partial unpacking, compute sharing
|
||||
// First partially unpack s-->v until paths deviate, note length of common path.
|
||||
@@ -501,7 +536,8 @@ class AlternativeRouting final
|
||||
if (packed_v_t_path[via_path_index] == packed_shortest_path[shortest_path_index])
|
||||
{
|
||||
super::UnpackEdge(packed_v_t_path[via_path_index - 1],
|
||||
packed_v_t_path[via_path_index], partially_unpacked_via_path);
|
||||
packed_v_t_path[via_path_index],
|
||||
partially_unpacked_via_path);
|
||||
super::UnpackEdge(packed_shortest_path[shortest_path_index - 1],
|
||||
packed_shortest_path[shortest_path_index],
|
||||
partially_unpacked_shortest_path);
|
||||
@@ -699,9 +735,15 @@ class AlternativeRouting final
|
||||
const bool constexpr DO_NOT_FORCE_LOOPS = false;
|
||||
while (new_reverse_heap.Size() > 0)
|
||||
{
|
||||
super::RoutingStep(new_reverse_heap, existing_forward_heap, *s_v_middle,
|
||||
upper_bound_s_v_path_length, min_edge_offset, false,
|
||||
STALLING_ENABLED, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS);
|
||||
super::RoutingStep(new_reverse_heap,
|
||||
existing_forward_heap,
|
||||
*s_v_middle,
|
||||
upper_bound_s_v_path_length,
|
||||
min_edge_offset,
|
||||
false,
|
||||
STALLING_ENABLED,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS);
|
||||
}
|
||||
|
||||
if (INVALID_EDGE_WEIGHT == upper_bound_s_v_path_length)
|
||||
@@ -715,9 +757,15 @@ class AlternativeRouting final
|
||||
new_forward_heap.Insert(candidate.node, 0, candidate.node);
|
||||
while (new_forward_heap.Size() > 0)
|
||||
{
|
||||
super::RoutingStep(new_forward_heap, existing_reverse_heap, *v_t_middle,
|
||||
upper_bound_of_v_t_path_length, min_edge_offset, true,
|
||||
STALLING_ENABLED, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS);
|
||||
super::RoutingStep(new_forward_heap,
|
||||
existing_reverse_heap,
|
||||
*v_t_middle,
|
||||
upper_bound_of_v_t_path_length,
|
||||
min_edge_offset,
|
||||
true,
|
||||
STALLING_ENABLED,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS);
|
||||
}
|
||||
|
||||
if (INVALID_EDGE_WEIGHT == upper_bound_of_v_t_path_length)
|
||||
@@ -728,11 +776,11 @@ class AlternativeRouting final
|
||||
*length_of_via_path = upper_bound_s_v_path_length + upper_bound_of_v_t_path_length;
|
||||
|
||||
// retrieve packed paths
|
||||
super::RetrievePackedPathFromHeap(existing_forward_heap, new_reverse_heap, *s_v_middle,
|
||||
packed_s_v_path);
|
||||
super::RetrievePackedPathFromHeap(
|
||||
existing_forward_heap, new_reverse_heap, *s_v_middle, packed_s_v_path);
|
||||
|
||||
super::RetrievePackedPathFromHeap(new_forward_heap, existing_reverse_heap, *v_t_middle,
|
||||
packed_v_t_path);
|
||||
super::RetrievePackedPathFromHeap(
|
||||
new_forward_heap, existing_reverse_heap, *v_t_middle, packed_v_t_path);
|
||||
|
||||
NodeID s_P = *s_v_middle, t_P = *v_t_middle;
|
||||
if (SPECIAL_NODEID == s_P)
|
||||
@@ -812,7 +860,8 @@ class AlternativeRouting final
|
||||
// Traverse path s-->v
|
||||
BOOST_ASSERT(!packed_v_t_path.empty());
|
||||
for (unsigned i = 0, packed_path_length = static_cast<unsigned>(packed_v_t_path.size() - 1);
|
||||
(i < packed_path_length) && unpack_stack.empty(); ++i)
|
||||
(i < packed_path_length) && unpack_stack.empty();
|
||||
++i)
|
||||
{
|
||||
const EdgeID edgeID =
|
||||
facade->FindEdgeInEitherDirection(packed_v_t_path[i], packed_v_t_path[i + 1]);
|
||||
@@ -884,14 +933,26 @@ class AlternativeRouting final
|
||||
{
|
||||
if (!forward_heap3.Empty())
|
||||
{
|
||||
super::RoutingStep(forward_heap3, reverse_heap3, middle, upper_bound,
|
||||
min_edge_offset, true, STALLING_ENABLED, DO_NOT_FORCE_LOOPS,
|
||||
super::RoutingStep(forward_heap3,
|
||||
reverse_heap3,
|
||||
middle,
|
||||
upper_bound,
|
||||
min_edge_offset,
|
||||
true,
|
||||
STALLING_ENABLED,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS);
|
||||
}
|
||||
if (!reverse_heap3.Empty())
|
||||
{
|
||||
super::RoutingStep(reverse_heap3, forward_heap3, middle, upper_bound,
|
||||
min_edge_offset, false, STALLING_ENABLED, DO_NOT_FORCE_LOOPS,
|
||||
super::RoutingStep(reverse_heap3,
|
||||
forward_heap3,
|
||||
middle,
|
||||
upper_bound,
|
||||
min_edge_offset,
|
||||
false,
|
||||
STALLING_ENABLED,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,12 +102,22 @@ class DirectShortestPathRouting final
|
||||
forward_core_heap.Clear();
|
||||
reverse_core_heap.Clear();
|
||||
|
||||
super::SearchWithCore(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap,
|
||||
distance, packed_leg, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS);
|
||||
super::SearchWithCore(forward_heap,
|
||||
reverse_heap,
|
||||
forward_core_heap,
|
||||
reverse_core_heap,
|
||||
distance,
|
||||
packed_leg,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS);
|
||||
}
|
||||
else
|
||||
{
|
||||
super::Search(forward_heap, reverse_heap, distance, packed_leg, DO_NOT_FORCE_LOOPS,
|
||||
super::Search(forward_heap,
|
||||
reverse_heap,
|
||||
distance,
|
||||
packed_leg,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS);
|
||||
}
|
||||
|
||||
@@ -128,7 +138,9 @@ class DirectShortestPathRouting final
|
||||
raw_route_data.target_traversed_in_reverse.push_back(
|
||||
(packed_leg.back() != phantom_node_pair.target_phantom.forward_segment_id.id));
|
||||
|
||||
super::UnpackPath(packed_leg.begin(), packed_leg.end(), phantom_node_pair,
|
||||
super::UnpackPath(packed_leg.begin(),
|
||||
packed_leg.end(),
|
||||
phantom_node_pair,
|
||||
raw_route_data.unpacked_path_segments.front());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -66,8 +66,7 @@ class ManyToManyRouting final
|
||||
SearchSpaceWithBuckets search_space_with_buckets;
|
||||
|
||||
unsigned column_idx = 0;
|
||||
const auto search_target_phantom = [&](const PhantomNode &phantom)
|
||||
{
|
||||
const auto search_target_phantom = [&](const PhantomNode &phantom) {
|
||||
query_heap.Clear();
|
||||
// insert target(s) at distance 0
|
||||
|
||||
@@ -94,8 +93,7 @@ class ManyToManyRouting final
|
||||
|
||||
// for each source do forward search
|
||||
unsigned row_idx = 0;
|
||||
const auto search_source_phantom = [&](const PhantomNode &phantom)
|
||||
{
|
||||
const auto search_source_phantom = [&](const PhantomNode &phantom) {
|
||||
query_heap.Clear();
|
||||
// insert target(s) at distance 0
|
||||
|
||||
@@ -115,8 +113,11 @@ class ManyToManyRouting final
|
||||
// explore search space
|
||||
while (!query_heap.Empty())
|
||||
{
|
||||
ForwardRoutingStep(row_idx, number_of_targets, query_heap,
|
||||
search_space_with_buckets, result_table);
|
||||
ForwardRoutingStep(row_idx,
|
||||
number_of_targets,
|
||||
query_heap,
|
||||
search_space_with_buckets,
|
||||
result_table);
|
||||
}
|
||||
++row_idx;
|
||||
};
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
#include "engine/routing_algorithms/routing_base.hpp"
|
||||
|
||||
#include "engine/map_matching/hidden_markov_model.hpp"
|
||||
#include "engine/map_matching/sub_matching.hpp"
|
||||
#include "engine/map_matching/matching_confidence.hpp"
|
||||
#include "engine/map_matching/sub_matching.hpp"
|
||||
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/json_logger.hpp"
|
||||
#include "util/for_each_pair.hpp"
|
||||
#include "util/json_logger.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
@@ -86,8 +86,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
|
||||
const bool use_timestamps = trace_timestamps.size() > 1;
|
||||
|
||||
const auto median_sample_time = [&]
|
||||
{
|
||||
const auto median_sample_time = [&] {
|
||||
if (use_timestamps)
|
||||
{
|
||||
return std::max(1u, GetMedianSampleTime(trace_timestamps));
|
||||
@@ -98,8 +97,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
}
|
||||
}();
|
||||
const auto max_broken_time = median_sample_time * MAX_BROKEN_STATES;
|
||||
const auto max_distance_delta = [&]
|
||||
{
|
||||
const auto max_distance_delta = [&] {
|
||||
if (use_timestamps)
|
||||
{
|
||||
return median_sample_time * MAX_SPEED;
|
||||
@@ -116,10 +114,10 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
for (auto t = 0UL; t < candidates_list.size(); ++t)
|
||||
{
|
||||
emission_log_probabilities[t].resize(candidates_list[t].size());
|
||||
std::transform(candidates_list[t].begin(), candidates_list[t].end(),
|
||||
std::transform(candidates_list[t].begin(),
|
||||
candidates_list[t].end(),
|
||||
emission_log_probabilities[t].begin(),
|
||||
[this](const PhantomNodeWithDistance &candidate)
|
||||
{
|
||||
[this](const PhantomNodeWithDistance &candidate) {
|
||||
return default_emission_log_probability(candidate.distance);
|
||||
});
|
||||
}
|
||||
@@ -134,19 +132,19 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
map_matching::EmissionLogProbability emission_log_probability(
|
||||
*trace_gps_precision[t]);
|
||||
std::transform(
|
||||
candidates_list[t].begin(), candidates_list[t].end(),
|
||||
candidates_list[t].begin(),
|
||||
candidates_list[t].end(),
|
||||
emission_log_probabilities[t].begin(),
|
||||
[&emission_log_probability](const PhantomNodeWithDistance &candidate)
|
||||
{
|
||||
[&emission_log_probability](const PhantomNodeWithDistance &candidate) {
|
||||
return emission_log_probability(candidate.distance);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
std::transform(candidates_list[t].begin(), candidates_list[t].end(),
|
||||
std::transform(candidates_list[t].begin(),
|
||||
candidates_list[t].end(),
|
||||
emission_log_probabilities[t].begin(),
|
||||
[this](const PhantomNodeWithDistance &candidate)
|
||||
{
|
||||
[this](const PhantomNodeWithDistance &candidate) {
|
||||
return default_emission_log_probability(candidate.distance);
|
||||
});
|
||||
}
|
||||
@@ -269,14 +267,19 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
forward_core_heap.Clear();
|
||||
reverse_core_heap.Clear();
|
||||
network_distance = super::GetNetworkDistanceWithCore(
|
||||
forward_heap, reverse_heap, forward_core_heap, reverse_core_heap,
|
||||
forward_heap,
|
||||
reverse_heap,
|
||||
forward_core_heap,
|
||||
reverse_core_heap,
|
||||
prev_unbroken_timestamps_list[s].phantom_node,
|
||||
current_timestamps_list[s_prime].phantom_node, duration_uppder_bound);
|
||||
current_timestamps_list[s_prime].phantom_node,
|
||||
duration_uppder_bound);
|
||||
}
|
||||
else
|
||||
{
|
||||
network_distance = super::GetNetworkDistance(
|
||||
forward_heap, reverse_heap,
|
||||
forward_heap,
|
||||
reverse_heap,
|
||||
prev_unbroken_timestamps_list[s].phantom_node,
|
||||
current_timestamps_list[s_prime].phantom_node);
|
||||
}
|
||||
@@ -398,10 +401,10 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
matching_distance += model.path_distances[timestamp_index][location_index];
|
||||
}
|
||||
util::for_each_pair(
|
||||
reconstructed_indices, [&trace_distance, &trace_coordinates](
|
||||
const std::pair<std::size_t, std::size_t> &prev,
|
||||
const std::pair<std::size_t, std::size_t> &curr)
|
||||
{
|
||||
reconstructed_indices,
|
||||
[&trace_distance,
|
||||
&trace_coordinates](const std::pair<std::size_t, std::size_t> &prev,
|
||||
const std::pair<std::size_t, std::size_t> &curr) {
|
||||
trace_distance += util::coordinate_calculation::haversineDistance(
|
||||
trace_coordinates[prev.first], trace_coordinates[curr.first]);
|
||||
});
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef ROUTING_BASE_HPP
|
||||
#define ROUTING_BASE_HPP
|
||||
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "engine/internal_route_result.hpp"
|
||||
#include "engine/search_engine_data.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
@@ -228,8 +228,9 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
|
||||
BOOST_ASSERT(*packed_path_begin == phantom_node_pair.source_phantom.forward_segment_id.id ||
|
||||
*packed_path_begin == phantom_node_pair.source_phantom.reverse_segment_id.id);
|
||||
BOOST_ASSERT(*std::prev(packed_path_end) == phantom_node_pair.target_phantom.forward_segment_id.id ||
|
||||
*std::prev(packed_path_end) == phantom_node_pair.target_phantom.reverse_segment_id.id);
|
||||
BOOST_ASSERT(
|
||||
*std::prev(packed_path_end) == phantom_node_pair.target_phantom.forward_segment_id.id ||
|
||||
*std::prev(packed_path_end) == phantom_node_pair.target_phantom.reverse_segment_id.id);
|
||||
|
||||
std::pair<NodeID, NodeID> edge;
|
||||
while (!recursion_stack.empty())
|
||||
@@ -322,8 +323,11 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
for (std::size_t i = start_index; i < end_index; ++i)
|
||||
{
|
||||
unpacked_path.push_back(
|
||||
PathData{id_vector[i], name_index, weight_vector[i],
|
||||
extractor::guidance::TurnInstruction::NO_TURN(), travel_mode,
|
||||
PathData{id_vector[i],
|
||||
name_index,
|
||||
weight_vector[i],
|
||||
extractor::guidance::TurnInstruction::NO_TURN(),
|
||||
travel_mode,
|
||||
INVALID_ENTRY_CLASSID});
|
||||
}
|
||||
BOOST_ASSERT(unpacked_path.size() > 0);
|
||||
@@ -381,7 +385,9 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
BOOST_ASSERT(i < id_vector.size());
|
||||
BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode > 0);
|
||||
unpacked_path.push_back(PathData{
|
||||
id_vector[i], phantom_node_pair.target_phantom.name_id, weight_vector[i],
|
||||
id_vector[i],
|
||||
phantom_node_pair.target_phantom.name_id,
|
||||
weight_vector[i],
|
||||
extractor::guidance::TurnInstruction::NO_TURN(),
|
||||
target_traversed_in_reverse ? phantom_node_pair.target_phantom.backward_travel_mode
|
||||
: phantom_node_pair.target_phantom.forward_travel_mode,
|
||||
@@ -544,13 +550,27 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
{
|
||||
if (!forward_heap.Empty())
|
||||
{
|
||||
RoutingStep(forward_heap, reverse_heap, middle, distance, min_edge_offset, true,
|
||||
STALLING_ENABLED, force_loop_forward, force_loop_reverse);
|
||||
RoutingStep(forward_heap,
|
||||
reverse_heap,
|
||||
middle,
|
||||
distance,
|
||||
min_edge_offset,
|
||||
true,
|
||||
STALLING_ENABLED,
|
||||
force_loop_forward,
|
||||
force_loop_reverse);
|
||||
}
|
||||
if (!reverse_heap.Empty())
|
||||
{
|
||||
RoutingStep(reverse_heap, forward_heap, middle, distance, min_edge_offset, false,
|
||||
STALLING_ENABLED, force_loop_reverse, force_loop_forward);
|
||||
RoutingStep(reverse_heap,
|
||||
forward_heap,
|
||||
middle,
|
||||
distance,
|
||||
min_edge_offset,
|
||||
false,
|
||||
STALLING_ENABLED,
|
||||
force_loop_reverse,
|
||||
force_loop_forward);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,8 +642,15 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
}
|
||||
else
|
||||
{
|
||||
RoutingStep(forward_heap, reverse_heap, middle, distance, min_edge_offset, true,
|
||||
STALLING_ENABLED, force_loop_forward, force_loop_reverse);
|
||||
RoutingStep(forward_heap,
|
||||
reverse_heap,
|
||||
middle,
|
||||
distance,
|
||||
min_edge_offset,
|
||||
true,
|
||||
STALLING_ENABLED,
|
||||
force_loop_forward,
|
||||
force_loop_reverse);
|
||||
}
|
||||
}
|
||||
if (!reverse_heap.Empty())
|
||||
@@ -636,8 +663,15 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
}
|
||||
else
|
||||
{
|
||||
RoutingStep(reverse_heap, forward_heap, middle, distance, min_edge_offset,
|
||||
false, STALLING_ENABLED, force_loop_reverse, force_loop_forward);
|
||||
RoutingStep(reverse_heap,
|
||||
forward_heap,
|
||||
middle,
|
||||
distance,
|
||||
min_edge_offset,
|
||||
false,
|
||||
STALLING_ENABLED,
|
||||
force_loop_reverse,
|
||||
force_loop_forward);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -690,12 +724,24 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
while (0 < forward_core_heap.Size() && 0 < reverse_core_heap.Size() &&
|
||||
distance > (forward_core_heap.MinKey() + reverse_core_heap.MinKey()))
|
||||
{
|
||||
RoutingStep(forward_core_heap, reverse_core_heap, middle, distance,
|
||||
min_core_edge_offset, true, STALLING_DISABLED, force_loop_forward,
|
||||
RoutingStep(forward_core_heap,
|
||||
reverse_core_heap,
|
||||
middle,
|
||||
distance,
|
||||
min_core_edge_offset,
|
||||
true,
|
||||
STALLING_DISABLED,
|
||||
force_loop_forward,
|
||||
force_loop_reverse);
|
||||
|
||||
RoutingStep(reverse_core_heap, forward_core_heap, middle, distance,
|
||||
min_core_edge_offset, false, STALLING_DISABLED, force_loop_reverse,
|
||||
RoutingStep(reverse_core_heap,
|
||||
forward_core_heap,
|
||||
middle,
|
||||
distance,
|
||||
min_core_edge_offset,
|
||||
false,
|
||||
STALLING_DISABLED,
|
||||
force_loop_reverse,
|
||||
force_loop_forward);
|
||||
}
|
||||
|
||||
@@ -724,8 +770,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
else
|
||||
{
|
||||
std::vector<NodeID> packed_core_leg;
|
||||
RetrievePackedPathFromHeap(forward_core_heap, reverse_core_heap, middle,
|
||||
packed_core_leg);
|
||||
RetrievePackedPathFromHeap(
|
||||
forward_core_heap, reverse_core_heap, middle, packed_core_leg);
|
||||
BOOST_ASSERT(packed_core_leg.size() > 0);
|
||||
RetrievePackedPathFromSingleHeap(forward_heap, packed_core_leg.front(), packed_leg);
|
||||
std::reverse(packed_leg.begin(), packed_leg.end());
|
||||
@@ -872,8 +918,15 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
|
||||
int duration = INVALID_EDGE_WEIGHT;
|
||||
std::vector<NodeID> packed_path;
|
||||
SearchWithCore(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap, duration,
|
||||
packed_path, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS, duration_upper_bound);
|
||||
SearchWithCore(forward_heap,
|
||||
reverse_heap,
|
||||
forward_core_heap,
|
||||
reverse_core_heap,
|
||||
duration,
|
||||
packed_path,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
duration_upper_bound);
|
||||
|
||||
double distance = std::numeric_limits<double>::max();
|
||||
if (duration != INVALID_EDGE_WEIGHT)
|
||||
@@ -926,8 +979,13 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
|
||||
int duration = INVALID_EDGE_WEIGHT;
|
||||
std::vector<NodeID> packed_path;
|
||||
Search(forward_heap, reverse_heap, duration, packed_path, DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS, duration_upper_bound);
|
||||
Search(forward_heap,
|
||||
reverse_heap,
|
||||
duration,
|
||||
packed_path,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
DO_NOT_FORCE_LOOPS,
|
||||
duration_upper_bound);
|
||||
|
||||
if (duration == INVALID_EDGE_WEIGHT)
|
||||
{
|
||||
|
||||
@@ -57,13 +57,13 @@ class ShortestPathRouting final
|
||||
if (search_from_forward_node)
|
||||
{
|
||||
forward_heap.Insert(source_phantom.forward_segment_id.id,
|
||||
-source_phantom.GetForwardWeightPlusOffset(),
|
||||
-source_phantom.GetForwardWeightPlusOffset(),
|
||||
source_phantom.forward_segment_id.id);
|
||||
}
|
||||
if (search_from_reverse_node)
|
||||
{
|
||||
forward_heap.Insert(source_phantom.reverse_segment_id.id,
|
||||
-source_phantom.GetReverseWeightPlusOffset(),
|
||||
-source_phantom.GetReverseWeightPlusOffset(),
|
||||
source_phantom.reverse_segment_id.id);
|
||||
}
|
||||
if (search_to_forward_node)
|
||||
@@ -96,16 +96,25 @@ class ShortestPathRouting final
|
||||
reverse_core_heap.Clear();
|
||||
BOOST_ASSERT(forward_core_heap.Size() == 0);
|
||||
BOOST_ASSERT(reverse_core_heap.Size() == 0);
|
||||
super::SearchWithCore(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap,
|
||||
new_total_distance, leg_packed_path, needs_loop_forwad,
|
||||
super::SearchWithCore(forward_heap,
|
||||
reverse_heap,
|
||||
forward_core_heap,
|
||||
reverse_core_heap,
|
||||
new_total_distance,
|
||||
leg_packed_path,
|
||||
needs_loop_forwad,
|
||||
needs_loop_backwards);
|
||||
}
|
||||
else
|
||||
{
|
||||
super::Search(forward_heap, reverse_heap, new_total_distance, leg_packed_path,
|
||||
needs_loop_forwad, needs_loop_backwards);
|
||||
super::Search(forward_heap,
|
||||
reverse_heap,
|
||||
new_total_distance,
|
||||
leg_packed_path,
|
||||
needs_loop_forwad,
|
||||
needs_loop_backwards);
|
||||
}
|
||||
new_total_distance += std::min(total_distance_to_forward,total_distance_to_reverse);
|
||||
new_total_distance += std::min(total_distance_to_forward, total_distance_to_reverse);
|
||||
}
|
||||
|
||||
// searches shortest path between:
|
||||
@@ -159,14 +168,20 @@ class ShortestPathRouting final
|
||||
reverse_core_heap.Clear();
|
||||
BOOST_ASSERT(forward_core_heap.Size() == 0);
|
||||
BOOST_ASSERT(reverse_core_heap.Size() == 0);
|
||||
super::SearchWithCore(
|
||||
forward_heap, reverse_heap, forward_core_heap, reverse_core_heap,
|
||||
new_total_distance_to_forward, leg_packed_path_forward,
|
||||
super::NeedsLoopForward(source_phantom, target_phantom), DO_NOT_FORCE_LOOP);
|
||||
super::SearchWithCore(forward_heap,
|
||||
reverse_heap,
|
||||
forward_core_heap,
|
||||
reverse_core_heap,
|
||||
new_total_distance_to_forward,
|
||||
leg_packed_path_forward,
|
||||
super::NeedsLoopForward(source_phantom, target_phantom),
|
||||
DO_NOT_FORCE_LOOP);
|
||||
}
|
||||
else
|
||||
{
|
||||
super::Search(forward_heap, reverse_heap, new_total_distance_to_forward,
|
||||
super::Search(forward_heap,
|
||||
reverse_heap,
|
||||
new_total_distance_to_forward,
|
||||
leg_packed_path_forward,
|
||||
super::NeedsLoopForward(source_phantom, target_phantom),
|
||||
DO_NOT_FORCE_LOOP);
|
||||
@@ -202,15 +217,22 @@ class ShortestPathRouting final
|
||||
reverse_core_heap.Clear();
|
||||
BOOST_ASSERT(forward_core_heap.Size() == 0);
|
||||
BOOST_ASSERT(reverse_core_heap.Size() == 0);
|
||||
super::SearchWithCore(forward_heap, reverse_heap, forward_core_heap,
|
||||
reverse_core_heap, new_total_distance_to_reverse,
|
||||
leg_packed_path_reverse, DO_NOT_FORCE_LOOP,
|
||||
super::SearchWithCore(forward_heap,
|
||||
reverse_heap,
|
||||
forward_core_heap,
|
||||
reverse_core_heap,
|
||||
new_total_distance_to_reverse,
|
||||
leg_packed_path_reverse,
|
||||
DO_NOT_FORCE_LOOP,
|
||||
super::NeedsLoopBackwards(source_phantom, target_phantom));
|
||||
}
|
||||
else
|
||||
{
|
||||
super::Search(forward_heap, reverse_heap, new_total_distance_to_reverse,
|
||||
leg_packed_path_reverse, DO_NOT_FORCE_LOOP,
|
||||
super::Search(forward_heap,
|
||||
reverse_heap,
|
||||
new_total_distance_to_reverse,
|
||||
leg_packed_path_reverse,
|
||||
DO_NOT_FORCE_LOOP,
|
||||
super::NeedsLoopBackwards(source_phantom, target_phantom));
|
||||
}
|
||||
}
|
||||
@@ -231,7 +253,9 @@ class ShortestPathRouting final
|
||||
auto leg_begin = total_packed_path.begin() + packed_leg_begin[current_leg];
|
||||
auto leg_end = total_packed_path.begin() + packed_leg_begin[current_leg + 1];
|
||||
const auto &unpack_phantom_node_pair = phantom_nodes_vector[current_leg];
|
||||
super::UnpackPath(leg_begin, leg_end, unpack_phantom_node_pair,
|
||||
super::UnpackPath(leg_begin,
|
||||
leg_end,
|
||||
unpack_phantom_node_pair,
|
||||
raw_route_data.unpacked_path_segments[current_leg]);
|
||||
|
||||
raw_route_data.source_traversed_in_reverse.push_back(
|
||||
@@ -247,7 +271,9 @@ class ShortestPathRouting final
|
||||
const boost::optional<bool> continue_straight_at_waypoint,
|
||||
InternalRouteResult &raw_route_data) const
|
||||
{
|
||||
const bool allow_uturn_at_waypoint = !(continue_straight_at_waypoint ? *continue_straight_at_waypoint : super::facade->GetContinueStraightDefault());
|
||||
const bool allow_uturn_at_waypoint =
|
||||
!(continue_straight_at_waypoint ? *continue_straight_at_waypoint
|
||||
: super::facade->GetContinueStraightDefault());
|
||||
|
||||
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
|
||||
super::facade->GetNumberOfNodes());
|
||||
@@ -300,12 +326,20 @@ class ShortestPathRouting final
|
||||
{
|
||||
if (allow_uturn_at_waypoint)
|
||||
{
|
||||
SearchWithUTurn(forward_heap, reverse_heap, forward_core_heap,
|
||||
reverse_core_heap, search_from_forward_node,
|
||||
search_from_reverse_node, search_to_forward_node,
|
||||
search_to_reverse_node, source_phantom, target_phantom,
|
||||
total_distance_to_forward, total_distance_to_reverse,
|
||||
new_total_distance_to_forward, packed_leg_to_forward);
|
||||
SearchWithUTurn(forward_heap,
|
||||
reverse_heap,
|
||||
forward_core_heap,
|
||||
reverse_core_heap,
|
||||
search_from_forward_node,
|
||||
search_from_reverse_node,
|
||||
search_to_forward_node,
|
||||
search_to_reverse_node,
|
||||
source_phantom,
|
||||
target_phantom,
|
||||
total_distance_to_forward,
|
||||
total_distance_to_reverse,
|
||||
new_total_distance_to_forward,
|
||||
packed_leg_to_forward);
|
||||
// if only the reverse node is valid (e.g. when using the match plugin) we
|
||||
// actually need to move
|
||||
if (!target_phantom.forward_segment_id.enabled)
|
||||
@@ -323,12 +357,22 @@ class ShortestPathRouting final
|
||||
}
|
||||
else
|
||||
{
|
||||
Search(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap,
|
||||
search_from_forward_node, search_from_reverse_node,
|
||||
search_to_forward_node, search_to_reverse_node, source_phantom,
|
||||
target_phantom, total_distance_to_forward, total_distance_to_reverse,
|
||||
new_total_distance_to_forward, new_total_distance_to_reverse,
|
||||
packed_leg_to_forward, packed_leg_to_reverse);
|
||||
Search(forward_heap,
|
||||
reverse_heap,
|
||||
forward_core_heap,
|
||||
reverse_core_heap,
|
||||
search_from_forward_node,
|
||||
search_from_reverse_node,
|
||||
search_to_forward_node,
|
||||
search_to_reverse_node,
|
||||
source_phantom,
|
||||
target_phantom,
|
||||
total_distance_to_forward,
|
||||
total_distance_to_reverse,
|
||||
new_total_distance_to_forward,
|
||||
new_total_distance_to_reverse,
|
||||
packed_leg_to_forward,
|
||||
packed_leg_to_reverse);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,8 +485,11 @@ class ShortestPathRouting final
|
||||
packed_leg_to_reverse_begin.push_back(total_packed_path_to_reverse.size());
|
||||
BOOST_ASSERT(packed_leg_to_reverse_begin.size() == phantom_nodes_vector.size() + 1);
|
||||
|
||||
UnpackLegs(phantom_nodes_vector, total_packed_path_to_reverse,
|
||||
packed_leg_to_reverse_begin, total_distance_to_reverse, raw_route_data);
|
||||
UnpackLegs(phantom_nodes_vector,
|
||||
total_packed_path_to_reverse,
|
||||
packed_leg_to_reverse_begin,
|
||||
total_distance_to_reverse,
|
||||
raw_route_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -450,8 +497,11 @@ class ShortestPathRouting final
|
||||
packed_leg_to_forward_begin.push_back(total_packed_path_to_forward.size());
|
||||
BOOST_ASSERT(packed_leg_to_forward_begin.size() == phantom_nodes_vector.size() + 1);
|
||||
|
||||
UnpackLegs(phantom_nodes_vector, total_packed_path_to_forward,
|
||||
packed_leg_to_forward_begin, total_distance_to_forward, raw_route_data);
|
||||
UnpackLegs(phantom_nodes_vector,
|
||||
total_packed_path_to_forward,
|
||||
packed_leg_to_forward_begin,
|
||||
total_distance_to_forward,
|
||||
raw_route_data);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user