Rename {id|edge_id} to turn_id

This commit is contained in:
Michael Krasnyk 2017-03-10 10:57:07 +01:00
parent c370ddd89a
commit 43a7e8e08a
No known key found for this signature in database
GPG Key ID: 49C12AD0F43D2108
8 changed files with 41 additions and 42 deletions

View File

@ -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;

View File

@ -38,7 +38,7 @@ std::vector<ContractorEdge> 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<ContractorEdge> 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);

View File

@ -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);
}
};
}

View File

@ -292,7 +292,7 @@ void unpackPath(const datafacade::ContiguousInternalMemoryDataFacade<algorithm::
// If the edge is a shortcut, we need to add the two halfs to the stack.
if (data.shortcut)
{ // unpack
const NodeID middle_node_id = data.id;
const NodeID middle_node_id = data.turn_id;
// Note the order here - we're adding these to a stack, so we
// want the first->middle 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<NodeID> id_vector;
std::vector<EdgeWeight> 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;

View File

@ -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}
{
}

View File

@ -35,7 +35,7 @@ splitBidirectionalEdges(const std::vector<extractor::EdgeBasedEdge> &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<extractor::EdgeBasedEdge> &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<OutputEdgeT> prepareEdgesForUsageInGraph(std::vector<extractor::Edge
OutputEdgeT reverse_edge;
forward_edge.source = reverse_edge.source = source;
forward_edge.target = reverse_edge.target = target;
forward_edge.data.edge_id = reverse_edge.data.edge_id = edges[i].data.edge_id;
forward_edge.data.turn_id = reverse_edge.data.turn_id = edges[i].data.turn_id;
forward_edge.data.weight = reverse_edge.data.weight = INVALID_EDGE_WEIGHT;
forward_edge.data.duration = reverse_edge.data.duration = MAXIMAL_EDGE_DURATION_INT_30;
forward_edge.data.forward = reverse_edge.data.backward = true;

View File

@ -434,7 +434,7 @@ bool viaNodeCandidatePassesTTest(
const bool current_edge_is_shortcut = current_edge_data.shortcut;
if (current_edge_is_shortcut)
{
const NodeID via_path_middle_node_id = current_edge_data.id;
const NodeID via_path_middle_node_id = current_edge_data.turn_id;
const EdgeID second_segment_edge_id =
facade.FindEdgeInEitherDirection(via_path_middle_node_id, via_path_edge.second);
const int second_segment_length = facade.GetEdgeData(second_segment_edge_id).weight;
@ -496,7 +496,7 @@ bool viaNodeCandidatePassesTTest(
const bool IsViaEdgeShortCut = current_edge_data.shortcut;
if (IsViaEdgeShortCut)
{
const NodeID middleOfViaPath = current_edge_data.id;
const NodeID middleOfViaPath = current_edge_data.turn_id;
EdgeID edgeIDOfFirstSegment =
facade.FindEdgeInEitherDirection(via_path_edge.first, middleOfViaPath);
int lengthOfFirstSegment = facade.GetEdgeData(edgeIDOfFirstSegment).weight;

View File

@ -93,8 +93,8 @@ void checkWeightsConsistency(
for (auto &edge : edge_based_edge_list)
{
BOOST_ASSERT(edge.data.edge_id < current_edge_data.size());
auto geometry_id = current_edge_data[edge.data.edge_id].via_geometry;
BOOST_ASSERT(edge.data.turn_id < current_edge_data.size());
auto geometry_id = current_edge_data[edge.data.turn_id].via_geometry;
if (geometry_id.forward)
{
@ -102,7 +102,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;
}
}
@ -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<extractor::EdgeBasedEdge> &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<extractor::EdgeBasedEdge> &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<EdgeWeight>(num_nodes);
if (turn_weight_penalty + new_weight < weight_min_value)
@ -631,7 +631,7 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &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
{