Skip to content

Commit

Permalink
Rename {id|edge_id} to turn_id
Browse files Browse the repository at this point in the history
  • Loading branch information
oxidase committed Mar 10, 2017
1 parent ffd6311 commit 0dc155b
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 36 deletions.
6 changes: 3 additions & 3 deletions include/contractor/graph_contractor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions include/contractor/graph_contractor_adaptors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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);
Expand All @@ -45,7 +45,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);
Expand Down
8 changes: 4 additions & 4 deletions include/contractor/query_edge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand All @@ -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;
Expand All @@ -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);
}
};
}
Expand Down
27 changes: 13 additions & 14 deletions include/engine/routing_algorithms/routing_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions include/extractor/edge_based_edge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}
{
}

Expand Down
6 changes: 3 additions & 3 deletions include/partition/edge_based_graph_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ 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,
edge.data.backward);

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,
Expand Down Expand Up @@ -91,7 +91,7 @@ prepareEdgesForUsageInGraph(std::vector<extractor::EdgeBasedEdge> edges)
EdgeBasedGraphEdge 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;
Expand Down
4 changes: 2 additions & 2 deletions src/engine/routing_algorithms/alternative_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/updater/updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,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;
BOOST_ASSERT(geometry_id.id < geometry_indices.size());

const auto &weights = geometry_id.forward ? forward_weight_list : reverse_weight_list;
Expand Down

0 comments on commit 0dc155b

Please sign in to comment.