simplify passing annotation data through OSRM pipeline using the node-based datastore
- separates node-based graph creation and compression from edge-based graph creation - moves usage of edge-based node data-container to pre-processing as well, unifying access to node-based data - single struct instead of separate vectors for annotation data in engine (single place of modification)
This commit is contained in:
committed by
Michael Krasnyk
parent
9b044aaa42
commit
2ddd98ee6d
@@ -27,6 +27,7 @@ void GraphCompressor::Compress(
|
||||
std::vector<TurnRestriction> &turn_restrictions,
|
||||
std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions,
|
||||
util::NodeBasedDynamicGraph &graph,
|
||||
const std::vector<NodeBasedEdgeAnnotation> &node_data_container,
|
||||
CompressedEdgeContainer &geometry_compressor)
|
||||
{
|
||||
const unsigned original_number_of_nodes = graph.GetNumberOfNodes();
|
||||
@@ -104,6 +105,7 @@ void GraphCompressor::Compress(
|
||||
BOOST_ASSERT(forward_e2 >= graph.BeginEdges(node_v) &&
|
||||
forward_e2 < graph.EndEdges(node_v));
|
||||
const EdgeID reverse_e2 = graph.BeginEdges(node_v) + 1 - reverse_edge_order;
|
||||
|
||||
BOOST_ASSERT(SPECIAL_EDGEID != reverse_e2);
|
||||
BOOST_ASSERT(reverse_e2 >= graph.BeginEdges(node_v) &&
|
||||
reverse_e2 < graph.EndEdges(node_v));
|
||||
@@ -127,6 +129,10 @@ void GraphCompressor::Compress(
|
||||
|
||||
const EdgeData &fwd_edge_data1 = graph.GetEdgeData(forward_e1);
|
||||
const EdgeData &rev_edge_data1 = graph.GetEdgeData(reverse_e1);
|
||||
const auto fwd_annotation_data1 = node_data_container[fwd_edge_data1.annotation_data];
|
||||
const auto fwd_annotation_data2 = node_data_container[fwd_edge_data2.annotation_data];
|
||||
const auto rev_annotation_data1 = node_data_container[rev_edge_data1.annotation_data];
|
||||
const auto rev_annotation_data2 = node_data_container[rev_edge_data2.annotation_data];
|
||||
|
||||
if (graph.FindEdgeInEitherDirection(node_u, node_w) != SPECIAL_EDGEID)
|
||||
{
|
||||
@@ -134,20 +140,22 @@ void GraphCompressor::Compress(
|
||||
}
|
||||
|
||||
// this case can happen if two ways with different names overlap
|
||||
if (fwd_edge_data1.name_id != rev_edge_data1.name_id ||
|
||||
fwd_edge_data2.name_id != rev_edge_data2.name_id)
|
||||
if ((fwd_annotation_data1.name_id != rev_annotation_data1.name_id) ||
|
||||
(fwd_annotation_data2.name_id != rev_annotation_data2.name_id))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fwd_edge_data1.CanCombineWith(fwd_edge_data2) &&
|
||||
rev_edge_data1.CanCombineWith(rev_edge_data2))
|
||||
if ((fwd_edge_data1.flags == fwd_edge_data2.flags) &&
|
||||
(rev_edge_data1.flags == rev_edge_data2.flags) &&
|
||||
(fwd_edge_data1.reversed == fwd_edge_data2.reversed) &&
|
||||
(rev_edge_data1.reversed == rev_edge_data2.reversed) &&
|
||||
// annotations need to match, except for the lane-id which can differ
|
||||
fwd_annotation_data1.CanCombineWith(fwd_annotation_data2) &&
|
||||
rev_annotation_data1.CanCombineWith(rev_annotation_data2))
|
||||
{
|
||||
BOOST_ASSERT(graph.GetEdgeData(forward_e1).name_id ==
|
||||
graph.GetEdgeData(reverse_e1).name_id);
|
||||
BOOST_ASSERT(graph.GetEdgeData(forward_e2).name_id ==
|
||||
graph.GetEdgeData(reverse_e2).name_id);
|
||||
|
||||
BOOST_ASSERT(!(graph.GetEdgeData(forward_e1).reversed &&
|
||||
graph.GetEdgeData(reverse_e1).reversed));
|
||||
/*
|
||||
* Remember Lane Data for compressed parts. This handles scenarios where lane-data
|
||||
* is
|
||||
@@ -175,24 +183,26 @@ void GraphCompressor::Compress(
|
||||
* just
|
||||
* like a barrier.
|
||||
*/
|
||||
const auto selectLaneID = [](const LaneDescriptionID front,
|
||||
const LaneDescriptionID back) {
|
||||
const auto selectAnnotation = [&node_data_container](
|
||||
const AnnotationID front_annotation, const AnnotationID back_annotation) {
|
||||
// A lane has tags: u - (front) - v - (back) - w
|
||||
// During contraction, we keep only one of the tags. Usually the one closer to
|
||||
// the
|
||||
// intersection is preferred. If its empty, however, we keep the non-empty one
|
||||
if (back == INVALID_LANE_DESCRIPTIONID)
|
||||
return front;
|
||||
return back;
|
||||
// the intersection is preferred. If its empty, however, we keep the non-empty
|
||||
// one
|
||||
if (node_data_container[back_annotation].lane_description_id ==
|
||||
INVALID_LANE_DESCRIPTIONID)
|
||||
return front_annotation;
|
||||
return back_annotation;
|
||||
};
|
||||
graph.GetEdgeData(forward_e1).lane_description_id = selectLaneID(
|
||||
fwd_edge_data1.lane_description_id, fwd_edge_data2.lane_description_id);
|
||||
graph.GetEdgeData(reverse_e1).lane_description_id = selectLaneID(
|
||||
rev_edge_data1.lane_description_id, rev_edge_data2.lane_description_id);
|
||||
graph.GetEdgeData(forward_e2).lane_description_id = selectLaneID(
|
||||
fwd_edge_data2.lane_description_id, fwd_edge_data1.lane_description_id);
|
||||
graph.GetEdgeData(reverse_e2).lane_description_id = selectLaneID(
|
||||
rev_edge_data2.lane_description_id, rev_edge_data1.lane_description_id);
|
||||
|
||||
graph.GetEdgeData(forward_e1).annotation_data = selectAnnotation(
|
||||
fwd_edge_data1.annotation_data, fwd_edge_data2.annotation_data);
|
||||
graph.GetEdgeData(reverse_e1).annotation_data = selectAnnotation(
|
||||
rev_edge_data1.annotation_data, rev_edge_data2.annotation_data);
|
||||
graph.GetEdgeData(forward_e2).annotation_data = selectAnnotation(
|
||||
fwd_edge_data2.annotation_data, fwd_edge_data1.annotation_data);
|
||||
graph.GetEdgeData(reverse_e2).annotation_data = selectAnnotation(
|
||||
rev_edge_data2.annotation_data, rev_edge_data1.annotation_data);
|
||||
|
||||
/*
|
||||
// Do not compress edge if it crosses a traffic signal.
|
||||
@@ -206,14 +216,15 @@ void GraphCompressor::Compress(
|
||||
if (has_node_penalty)
|
||||
{
|
||||
// we cannot handle this as node penalty, if it depends on turn direction
|
||||
if (fwd_edge_data1.restricted != fwd_edge_data2.restricted)
|
||||
if (fwd_edge_data1.flags.restricted != fwd_edge_data2.flags.restricted)
|
||||
continue;
|
||||
|
||||
// generate an artifical turn for the turn penalty generation
|
||||
ExtractionTurn extraction_turn(true,
|
||||
fwd_edge_data1.restricted,
|
||||
fwd_edge_data2.restricted,
|
||||
fwd_edge_data1.is_left_hand_driving);
|
||||
ExtractionTurn extraction_turn(
|
||||
true,
|
||||
fwd_edge_data1.flags.restricted,
|
||||
fwd_edge_data2.flags.restricted,
|
||||
node_data_container[fwd_edge_data1.annotation_data].is_left_hand_driving);
|
||||
|
||||
scripting_environment.ProcessTurn(extraction_turn);
|
||||
node_duration_penalty = extraction_turn.duration * 10;
|
||||
|
||||
Reference in New Issue
Block a user