From 43a7e8e08ab85e585c2610f59e3b871b8fb88246 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Fri, 10 Mar 2017 10:57:07 +0100 Subject: [PATCH] Rename {id|edge_id} to turn_id --- include/contractor/graph_contractor.hpp | 6 ++--- .../contractor/graph_contractor_adaptors.hpp | 4 +-- include/contractor/query_edge.hpp | 8 +++--- .../routing_algorithms/routing_base.hpp | 27 +++++++++---------- include/extractor/edge_based_edge.hpp | 12 ++++----- include/partition/edge_based_graph_reader.hpp | 6 ++--- .../routing_algorithms/alternative_path.cpp | 4 +-- src/updater/updater.cpp | 16 +++++------ 8 files changed, 41 insertions(+), 42 deletions(-) diff --git a/include/contractor/graph_contractor.hpp b/include/contractor/graph_contractor.hpp index f2a2b12e0..06904af20 100644 --- a/include/contractor/graph_contractor.hpp +++ b/include/contractor/graph_contractor.hpp @@ -139,13 +139,13 @@ class GraphContractor if (!data.is_original_via_node_ID && !orig_node_id_from_new_node_id_map.empty()) { // tranlate the _node id_ of the shortcutted node - new_edge.data.id = orig_node_id_from_new_node_id_map[data.id]; + new_edge.data.turn_id = orig_node_id_from_new_node_id_map[data.id]; } else { - new_edge.data.id = data.id; + new_edge.data.turn_id = data.id; } - BOOST_ASSERT_MSG(new_edge.data.id != INT_MAX, // 2^31 + BOOST_ASSERT_MSG(new_edge.data.turn_id != INT_MAX, // 2^31 "edge id invalid"); new_edge.data.forward = data.forward; new_edge.data.backward = data.backward; diff --git a/include/contractor/graph_contractor_adaptors.hpp b/include/contractor/graph_contractor_adaptors.hpp index 293ef0d78..2bb123e2a 100644 --- a/include/contractor/graph_contractor_adaptors.hpp +++ b/include/contractor/graph_contractor_adaptors.hpp @@ -38,7 +38,7 @@ std::vector adaptToContractorInput(InputEdgeContainer input_edge std::max(input_edge.data.weight, 1), input_edge.data.duration, 1, - input_edge.data.edge_id, + input_edge.data.turn_id, false, input_edge.data.forward ? true : false, input_edge.data.backward ? true : false); @@ -48,7 +48,7 @@ std::vector adaptToContractorInput(InputEdgeContainer input_edge std::max(input_edge.data.weight, 1), input_edge.data.duration, 1, - input_edge.data.edge_id, + input_edge.data.turn_id, false, input_edge.data.backward ? true : false, input_edge.data.forward ? true : false); diff --git a/include/contractor/query_edge.hpp b/include/contractor/query_edge.hpp index f34d0575c..06c1f0fbf 100644 --- a/include/contractor/query_edge.hpp +++ b/include/contractor/query_edge.hpp @@ -17,7 +17,7 @@ struct QueryEdge struct EdgeData { explicit EdgeData() - : id(0), shortcut(false), weight(0), duration(0), forward(false), backward(false) + : turn_id(0), shortcut(false), weight(0), duration(0), forward(false), backward(false) { } @@ -26,14 +26,14 @@ struct QueryEdge weight = other.weight; duration = other.duration; shortcut = other.shortcut; - id = other.id; + turn_id = other.id; forward = other.forward; backward = other.backward; } // this ID is either the middle node of the shortcut, or the ID of the edge based node (node // based edge) storing the appropriate data. If `shortcut` is set to true, we get the middle // node. Otherwise we see the edge based node to access node data. - NodeID id : 31; + NodeID turn_id : 31; bool shortcut : 1; EdgeWeight weight; EdgeWeight duration : 30; @@ -58,7 +58,7 @@ struct QueryEdge return (source == right.source && target == right.target && data.weight == right.data.weight && data.duration == right.data.duration && data.shortcut == right.data.shortcut && data.forward == right.data.forward && - data.backward == right.data.backward && data.id == right.data.id); + data.backward == right.data.backward && data.turn_id == right.data.turn_id); } }; } diff --git a/include/engine/routing_algorithms/routing_base.hpp b/include/engine/routing_algorithms/routing_base.hpp index e1b0a630e..946c506f4 100644 --- a/include/engine/routing_algorithms/routing_base.hpp +++ b/include/engine/routing_algorithms/routing_base.hpp @@ -292,7 +292,7 @@ void unpackPath(const datafacade::ContiguousInternalMemoryDataFacademiddle to get visited before middle->second recursion_stack.emplace(middle_node_id, edge.second); @@ -340,14 +340,15 @@ void unpackPath(const FacadeT &facade, const auto &edge_data) { BOOST_ASSERT_MSG(!edge_data.shortcut, "original edge flagged as shortcut"); - const auto name_index = facade.GetNameIndexFromEdgeID(edge_data.id); - const auto turn_instruction = facade.GetTurnInstructionForEdgeID(edge_data.id); + const auto turn_id = edge_data.turn_id; // edge-based node ID + const auto name_index = facade.GetNameIndexFromEdgeID(turn_id); + const auto turn_instruction = facade.GetTurnInstructionForEdgeID(turn_id); const extractor::TravelMode travel_mode = (unpacked_path.empty() && start_traversed_in_reverse) ? phantom_node_pair.source_phantom.backward_travel_mode - : facade.GetTravelModeForEdgeID(edge_data.id); + : facade.GetTravelModeForEdgeID(turn_id); - const auto geometry_index = facade.GetGeometryIndexForEdgeID(edge_data.id); + const auto geometry_index = facade.GetGeometryIndexForEdgeID(turn_id); std::vector id_vector; std::vector weight_vector; @@ -399,17 +400,15 @@ void unpackPath(const FacadeT &facade, util::guidance::TurnBearing(0)}); } BOOST_ASSERT(unpacked_path.size() > 0); - if (facade.hasLaneData(edge_data.id)) - unpacked_path.back().lane_data = facade.GetLaneData(edge_data.id); + if (facade.hasLaneData(turn_id)) + unpacked_path.back().lane_data = facade.GetLaneData(turn_id); - unpacked_path.back().entry_classid = facade.GetEntryClassID(edge_data.id); + unpacked_path.back().entry_classid = facade.GetEntryClassID(turn_id); unpacked_path.back().turn_instruction = turn_instruction; - unpacked_path.back().duration_until_turn += - facade.GetDurationPenaltyForEdgeID(edge_data.id); - unpacked_path.back().weight_until_turn += - facade.GetWeightPenaltyForEdgeID(edge_data.id); - unpacked_path.back().pre_turn_bearing = facade.PreTurnBearing(edge_data.id); - unpacked_path.back().post_turn_bearing = facade.PostTurnBearing(edge_data.id); + unpacked_path.back().duration_until_turn += facade.GetDurationPenaltyForEdgeID(turn_id); + unpacked_path.back().weight_until_turn += facade.GetWeightPenaltyForEdgeID(turn_id); + unpacked_path.back().pre_turn_bearing = facade.PreTurnBearing(turn_id); + unpacked_path.back().post_turn_bearing = facade.PostTurnBearing(turn_id); }); std::size_t start_index = 0, end_index = 0; diff --git a/include/extractor/edge_based_edge.hpp b/include/extractor/edge_based_edge.hpp index cbc10308d..a0611d3b6 100644 --- a/include/extractor/edge_based_edge.hpp +++ b/include/extractor/edge_based_edge.hpp @@ -32,19 +32,19 @@ struct EdgeBasedEdge struct EdgeData { - EdgeData() : edge_id(0), weight(0), duration(0), forward(false), backward(false) {} + EdgeData() : turn_id(0), weight(0), duration(0), forward(false), backward(false) {} - EdgeData(const NodeID edge_id, + EdgeData(const NodeID turn_id, const EdgeWeight weight, const EdgeWeight duration, const bool forward, const bool backward) - : edge_id(edge_id), weight(weight), duration(duration), forward(forward), + : turn_id(turn_id), weight(weight), duration(duration), forward(forward), backward(backward) { } - NodeID edge_id; + NodeID turn_id; // ID of the edge based node (node based edge) EdgeWeight weight; EdgeWeight duration : 30; std::uint32_t forward : 1; @@ -64,12 +64,12 @@ inline EdgeBasedEdge::EdgeBasedEdge() : source(0), target(0) {} inline EdgeBasedEdge::EdgeBasedEdge(const NodeID source, const NodeID target, - const NodeID edge_id, + const NodeID turn_id, const EdgeWeight weight, const EdgeWeight duration, const bool forward, const bool backward) - : source(source), target(target), data{edge_id, weight, duration, forward, backward} + : source(source), target(target), data{turn_id, weight, duration, forward, backward} { } diff --git a/include/partition/edge_based_graph_reader.hpp b/include/partition/edge_based_graph_reader.hpp index 78e578629..aa544346c 100644 --- a/include/partition/edge_based_graph_reader.hpp +++ b/include/partition/edge_based_graph_reader.hpp @@ -35,7 +35,7 @@ splitBidirectionalEdges(const std::vector &edges) directed.emplace_back(edge.source, edge.target, - edge.data.edge_id, + edge.data.turn_id, std::max(edge.data.weight, 1), edge.data.duration, edge.data.forward, @@ -43,7 +43,7 @@ splitBidirectionalEdges(const std::vector &edges) directed.emplace_back(edge.target, edge.source, - edge.data.edge_id, + edge.data.turn_id, std::max(edge.data.weight, 1), edge.data.duration, edge.data.backward, @@ -77,7 +77,7 @@ std::vector prepareEdgesForUsageInGraph(std::vector edge.data.weight) { - util::Log(logWARNING) << geometry_id.id << " vs " << edge.data.edge_id << ":" + util::Log(logWARNING) << geometry_id.id << " vs " << edge.data.turn_id << ":" << weight << " > " << edge.data.weight; } } @@ -112,7 +112,7 @@ void checkWeightsConsistency( EdgeWeight weight = std::accumulate(range.begin(), range.end(), EdgeWeight{0}); if (weight > edge.data.weight) { - util::Log(logWARNING) << geometry_id.id << " vs " << edge.data.edge_id << ":" + util::Log(logWARNING) << geometry_id.id << " vs " << edge.data.turn_id << ":" << weight << " > " << edge.data.weight; } } @@ -583,7 +583,7 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector &e }); const auto update_edge = [&](extractor::EdgeBasedEdge &edge) { - const auto geometry_id = edge_data[edge.data.edge_id].via_geometry; + const auto geometry_id = edge_data[edge.data.turn_id].via_geometry; auto updated_iter = std::lower_bound(updated_segments.begin(), updated_segments.end(), geometry_id, @@ -619,8 +619,8 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector &e } // Get the turn penalty and update to the new value if required - auto turn_weight_penalty = turn_weight_penalties[edge.data.edge_id]; - auto turn_duration_penalty = turn_duration_penalties[edge.data.edge_id]; + auto turn_weight_penalty = turn_weight_penalties[edge.data.turn_id]; + auto turn_duration_penalty = turn_duration_penalties[edge.data.turn_id]; const auto num_nodes = segment_data.GetForwardGeometry(geometry_id.id).size(); const auto weight_min_value = static_cast(num_nodes); if (turn_weight_penalty + new_weight < weight_min_value) @@ -631,7 +631,7 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector &e << " is too negative: clamping turn weight to " << weight_min_value; turn_weight_penalty = weight_min_value - new_weight; - turn_weight_penalties[edge.data.edge_id] = turn_weight_penalty; + turn_weight_penalties[edge.data.turn_id] = turn_weight_penalty; } else {