Apply clang-format

This commit is contained in:
Patrick Niklaus
2016-01-05 12:04:04 +01:00
parent 552cdbfe20
commit 028ca5c9d9
84 changed files with 988 additions and 903 deletions
@@ -40,10 +40,11 @@ class DirectShortestPathRouting final
// Get distance to next pair of target nodes.
BOOST_ASSERT_MSG(1 == phantom_nodes_vector.size(),
"Direct Shortest Path Query only accepts a single source and target pair. Multiple ones have been specified.");
const auto& phantom_node_pair = phantom_nodes_vector.front();
const auto& source_phantom = phantom_node_pair.source_phantom;
const auto& target_phantom = phantom_node_pair.target_phantom;
"Direct Shortest Path Query only accepts a single source and target pair. "
"Multiple ones have been specified.");
const auto &phantom_node_pair = phantom_nodes_vector.front();
const auto &source_phantom = phantom_node_pair.source_phantom;
const auto &target_phantom = phantom_node_pair.target_phantom;
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
super::facade->GetNumberOfNodes());
@@ -94,7 +95,6 @@ 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);
}
@@ -120,8 +120,8 @@ class DirectShortestPathRouting final
raw_route_data.target_traversed_in_reverse.push_back(
(packed_leg.back() != phantom_node_pair.target_phantom.forward_node_id));
super::UnpackPath(packed_leg.begin(), packed_leg.end(), phantom_node_pair, raw_route_data.unpacked_path_segments.front());
super::UnpackPath(packed_leg.begin(), packed_leg.end(), phantom_node_pair,
raw_route_data.unpacked_path_segments.front());
}
};
@@ -40,7 +40,8 @@ class ManyToManyRouting final
~ManyToManyRouting() {}
std::shared_ptr<std::vector<EdgeWeight>>
operator()(const std::vector<PhantomNode> &phantom_sources_array, const std::vector<PhantomNode> &phantom_targets_array) const
operator()(const std::vector<PhantomNode> &phantom_sources_array,
const std::vector<PhantomNode> &phantom_targets_array) const
{
const auto number_of_sources = phantom_sources_array.size();
const auto number_of_targets = phantom_targets_array.size();
@@ -63,14 +64,12 @@ class ManyToManyRouting final
if (SPECIAL_NODEID != phantom.forward_node_id)
{
query_heap.Insert(phantom.forward_node_id,
phantom.GetForwardWeightPlusOffset(),
query_heap.Insert(phantom.forward_node_id, phantom.GetForwardWeightPlusOffset(),
phantom.forward_node_id);
}
if (SPECIAL_NODEID != phantom.reverse_node_id)
{
query_heap.Insert(phantom.reverse_node_id,
phantom.GetReverseWeightPlusOffset(),
query_heap.Insert(phantom.reverse_node_id, phantom.GetReverseWeightPlusOffset(),
phantom.reverse_node_id);
}
@@ -91,14 +90,12 @@ class ManyToManyRouting final
if (SPECIAL_NODEID != phantom.forward_node_id)
{
query_heap.Insert(phantom.forward_node_id,
-phantom.GetForwardWeightPlusOffset(),
query_heap.Insert(phantom.forward_node_id, -phantom.GetForwardWeightPlusOffset(),
phantom.forward_node_id);
}
if (SPECIAL_NODEID != phantom.reverse_node_id)
{
query_heap.Insert(phantom.reverse_node_id,
-phantom.GetReverseWeightPlusOffset(),
query_heap.Insert(phantom.reverse_node_id, -phantom.GetReverseWeightPlusOffset(),
phantom.reverse_node_id);
}
@@ -50,7 +50,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
using QueryHeap = SearchEngineData::QueryHeap;
SearchEngineData &engine_working_data;
unsigned GetMedianSampleTime(const std::vector<unsigned>& timestamps) const
unsigned GetMedianSampleTime(const std::vector<unsigned> &timestamps) const
{
BOOST_ASSERT(timestamps.size() > 1);
@@ -60,7 +60,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
// don't use first element of sample_times -> will not be a difference.
auto first_elem = std::next(sample_times.begin());
auto median = first_elem + std::distance(first_elem, sample_times.end())/2;
auto median = first_elem + std::distance(first_elem, sample_times.end()) / 2;
std::nth_element(first_elem, median, sample_times.end());
return *median;
}
@@ -83,7 +83,8 @@ 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));
@@ -94,7 +95,8 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
}
}();
const auto max_broken_time = median_sample_time * osrm::matching::MAX_BROKEN_STATES;
const auto max_distance_delta = [&]() {
const auto max_distance_delta = [&]()
{
if (use_timestamps)
{
return median_sample_time * osrm::matching::MAX_SPEED;
@@ -193,7 +195,8 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
const auto &current_timestamps_list = candidates_list[t];
const auto &current_coordinate = trace_coordinates[t];
const auto haversine_distance = coordinate_calculation::haversine_distance(prev_coordinate, current_coordinate);
const auto haversine_distance =
coordinate_calculation::haversine_distance(prev_coordinate, current_coordinate);
// compute d_t for this timestamp and the next one
for (const auto s : osrm::irange<std::size_t>(0u, prev_viterbi.size()))
@@ -244,7 +247,8 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
current_parents[s_prime] = std::make_pair(prev_unbroken_timestamp, s);
current_lengths[s_prime] = network_distance;
current_pruned[s_prime] = false;
current_suspicious[s_prime] = d_t > osrm::matching::SUSPICIOUS_DISTANCE_DELTA;
current_suspicious[s_prime] =
d_t > osrm::matching::SUSPICIOUS_DISTANCE_DELTA;
model.breakage[t] = false;
}
}
@@ -286,8 +290,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
{
--parent_timestamp_index;
}
while (sub_matching_begin < sub_matching_end &&
model.breakage[sub_matching_begin])
while (sub_matching_begin < sub_matching_end && model.breakage[sub_matching_begin])
{
++sub_matching_begin;
}
@@ -295,12 +295,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.emplace_back(
PathData{id_vector[i],
phantom_node_pair.target_phantom.name_id,
TurnInstruction::NoTurn,
0,
phantom_node_pair.target_phantom.forward_travel_mode});
unpacked_path.emplace_back(PathData{
id_vector[i], phantom_node_pair.target_phantom.name_id, TurnInstruction::NoTurn,
0, phantom_node_pair.target_phantom.forward_travel_mode});
}
}
@@ -498,8 +495,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
// TODO check if unordered_set might be faster
// sort by id and increasing by distance
auto entry_point_comparator =
[](const std::pair<NodeID, EdgeWeight> &lhs, const std::pair<NodeID, EdgeWeight> &rhs)
auto entry_point_comparator = [](const std::pair<NodeID, EdgeWeight> &lhs,
const std::pair<NodeID, EdgeWeight> &rhs)
{
return lhs.first < rhs.first || (lhs.first == rhs.first && lhs.second < rhs.second);
};
@@ -86,17 +86,17 @@ class ShortestPathRouting final
// | ^target
// ------^
void SearchLoop(QueryHeap &forward_heap,
QueryHeap &reverse_heap,
const bool search_forward_node,
const bool search_reverse_node,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
const int total_distance_to_forward,
const int total_distance_to_reverse,
int &new_total_distance_to_forward,
int &new_total_distance_to_reverse,
std::vector<NodeID> &leg_packed_path_forward,
std::vector<NodeID> &leg_packed_path_reverse) const
QueryHeap &reverse_heap,
const bool search_forward_node,
const bool search_reverse_node,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
const int total_distance_to_forward,
const int total_distance_to_reverse,
int &new_total_distance_to_forward,
int &new_total_distance_to_reverse,
std::vector<NodeID> &leg_packed_path_forward,
std::vector<NodeID> &leg_packed_path_reverse) const
{
BOOST_ASSERT(source_phantom.forward_node_id == target_phantom.forward_node_id);
BOOST_ASSERT(source_phantom.reverse_node_id == target_phantom.reverse_node_id);
@@ -110,11 +110,12 @@ class ShortestPathRouting final
for (const auto edge : super::facade->GetAdjacentEdgeRange(node_id))
{
const auto& data = super::facade->GetEdgeData(edge);
const auto &data = super::facade->GetEdgeData(edge);
if (data.forward)
{
auto target = super::facade->GetTarget(edge);
auto offset = total_distance_to_forward + data.distance - source_phantom.GetForwardWeightPlusOffset();
auto offset = total_distance_to_forward + data.distance -
source_phantom.GetForwardWeightPlusOffset();
forward_heap.Insert(target, offset, target);
}
@@ -147,11 +148,12 @@ class ShortestPathRouting final
for (const auto edge : super::facade->GetAdjacentEdgeRange(node_id))
{
const auto& data = super::facade->GetEdgeData(edge);
const auto &data = super::facade->GetEdgeData(edge);
if (data.forward)
{
auto target = super::facade->GetTarget(edge);
auto offset = total_distance_to_reverse + data.distance - source_phantom.GetReverseWeightPlusOffset();
auto offset = total_distance_to_reverse + data.distance -
source_phantom.GetReverseWeightPlusOffset();
forward_heap.Insert(target, offset, target);
}
@@ -174,7 +176,6 @@ class ShortestPathRouting final
leg_packed_path_reverse.push_back(node_id);
std::reverse(leg_packed_path_reverse.begin(), leg_packed_path_reverse.end());
}
}
// searches shortest path between:
@@ -290,8 +291,10 @@ class ShortestPathRouting final
int total_distance_to_forward = 0;
int total_distance_to_reverse = 0;
bool search_from_forward_node = phantom_nodes_vector.front().source_phantom.forward_node_id != SPECIAL_NODEID;
bool search_from_reverse_node = phantom_nodes_vector.front().source_phantom.reverse_node_id != SPECIAL_NODEID;
bool search_from_forward_node =
phantom_nodes_vector.front().source_phantom.forward_node_id != SPECIAL_NODEID;
bool search_from_reverse_node =
phantom_nodes_vector.front().source_phantom.reverse_node_id != SPECIAL_NODEID;
std::vector<NodeID> prev_packed_leg_to_forward;
std::vector<NodeID> prev_packed_leg_to_reverse;
@@ -315,30 +318,33 @@ class ShortestPathRouting final
const auto &source_phantom = phantom_node_pair.source_phantom;
const auto &target_phantom = phantom_node_pair.target_phantom;
BOOST_ASSERT(current_leg + 1 < uturn_indicators.size());
const bool allow_u_turn_at_via = uturn_indicators[current_leg + 1];
bool search_to_forward_node = target_phantom.forward_node_id != SPECIAL_NODEID;
bool search_to_reverse_node = target_phantom.reverse_node_id != SPECIAL_NODEID;
BOOST_ASSERT(!search_from_forward_node || source_phantom.forward_node_id != SPECIAL_NODEID);
BOOST_ASSERT(!search_from_reverse_node || source_phantom.reverse_node_id != SPECIAL_NODEID);
BOOST_ASSERT(!search_from_forward_node ||
source_phantom.forward_node_id != SPECIAL_NODEID);
BOOST_ASSERT(!search_from_reverse_node ||
source_phantom.reverse_node_id != SPECIAL_NODEID);
if (source_phantom.forward_node_id == target_phantom.forward_node_id &&
source_phantom.GetForwardWeightPlusOffset() > target_phantom.GetForwardWeightPlusOffset())
source_phantom.GetForwardWeightPlusOffset() >
target_phantom.GetForwardWeightPlusOffset())
{
search_to_forward_node = search_from_reverse_node;
}
if (source_phantom.reverse_node_id == target_phantom.reverse_node_id &&
source_phantom.GetReverseWeightPlusOffset() > target_phantom.GetReverseWeightPlusOffset())
source_phantom.GetReverseWeightPlusOffset() >
target_phantom.GetReverseWeightPlusOffset())
{
search_to_reverse_node = search_from_forward_node;
}
BOOST_ASSERT(search_from_forward_node || search_from_reverse_node);
if(search_to_reverse_node || search_to_forward_node)
if (search_to_reverse_node || search_to_forward_node)
{
if (allow_u_turn_at_via)
{
@@ -347,7 +353,8 @@ class ShortestPathRouting final
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 only the reverse node is valid (e.g. when using the match plugin) we
// actually need to move
if (target_phantom.forward_node_id == SPECIAL_NODEID)
{
BOOST_ASSERT(target_phantom.reverse_node_id != SPECIAL_NODEID);
@@ -367,7 +374,8 @@ class ShortestPathRouting final
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);
new_total_distance_to_reverse, packed_leg_to_forward,
packed_leg_to_reverse);
}
}
else
@@ -377,9 +385,10 @@ class ShortestPathRouting final
BOOST_ASSERT(search_from_reverse_node == search_to_reverse_node);
BOOST_ASSERT(search_from_forward_node == search_to_forward_node);
SearchLoop(forward_heap, reverse_heap, search_from_forward_node,
search_from_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_from_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);
}
// No path found for both target nodes?