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
@@ -23,10 +23,12 @@ namespace guidance
|
||||
|
||||
SliproadHandler::SliproadHandler(const IntersectionGenerator &intersection_generator,
|
||||
const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table)
|
||||
: IntersectionHandler(node_based_graph,
|
||||
node_data_container,
|
||||
coordinates,
|
||||
name_table,
|
||||
street_name_suffix_table,
|
||||
@@ -109,7 +111,7 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto &road_data = node_based_graph.GetEdgeData(road.eid);
|
||||
const auto &road_data = node_based_graph.GetEdgeData(road.eid).flags;
|
||||
|
||||
auto is_roundabout = road_data.roundabout;
|
||||
|
||||
@@ -156,7 +158,8 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
|
||||
|
||||
for (const auto &road : main_road_intersection->intersection)
|
||||
{
|
||||
const auto &target_data = node_based_graph.GetEdgeData(road.eid);
|
||||
const auto target_annotation_id = node_based_graph.GetEdgeData(road.eid).annotation_data;
|
||||
const auto &target_data = node_data_container.GetAnnotation(target_annotation_id);
|
||||
target_road_name_ids.push_back(target_data.name_id);
|
||||
}
|
||||
|
||||
@@ -173,7 +176,7 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
|
||||
continue;
|
||||
|
||||
auto &sliproad = intersection[road_index]; // this is what we're checking and assigning to
|
||||
const auto &sliproad_data = node_based_graph.GetEdgeData(sliproad.eid);
|
||||
const auto &sliproad_edge_data = node_based_graph.GetEdgeData(sliproad.eid);
|
||||
|
||||
// Intersection is orderd: 0 is UTurn, then from sharp right to sharp left.
|
||||
// We already have an obvious index (bc) for going straight-ish.
|
||||
@@ -199,13 +202,13 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
|
||||
}
|
||||
|
||||
// Discard service and other low priority roads - never Sliproad candidate
|
||||
if (sliproad_data.road_classification.IsLowPriorityRoadClass())
|
||||
if (sliproad_edge_data.flags.road_classification.IsLowPriorityRoadClass())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Incoming-only can never be a Sliproad
|
||||
if (sliproad_data.reversed)
|
||||
if (sliproad_edge_data.reversed)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -350,7 +353,7 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto &onto_data = node_based_graph.GetEdgeData(onto.eid);
|
||||
const auto &onto_data = node_based_graph.GetEdgeData(onto.eid).flags;
|
||||
|
||||
if (onto_data.roundabout)
|
||||
{
|
||||
@@ -434,7 +437,8 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
|
||||
|
||||
// Check sliproads with skew main intersections
|
||||
if (deviation_from_straight > 180. - minimal_crossroad_angle_of_intersection &&
|
||||
!node_based_graph.GetEdgeData(sliproad.eid).road_classification.IsLinkClass())
|
||||
!node_based_graph.GetEdgeData(sliproad.eid)
|
||||
.flags.road_classification.IsLinkClass())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -449,9 +453,10 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
|
||||
// ` .
|
||||
// d
|
||||
//
|
||||
const auto area_threshold = std::pow(
|
||||
scaledThresholdByRoadClass(MAX_SLIPROAD_THRESHOLD, sliproad_data.road_classification),
|
||||
2.);
|
||||
const auto area_threshold =
|
||||
std::pow(scaledThresholdByRoadClass(MAX_SLIPROAD_THRESHOLD,
|
||||
sliproad_edge_data.flags.road_classification),
|
||||
2.);
|
||||
|
||||
if (!isValidSliproadArea(area_threshold,
|
||||
intersection_node_id,
|
||||
@@ -464,7 +469,8 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
|
||||
// Check all roads at `d` if one is connected to `c`, is so `bd` is Sliproad.
|
||||
for (const auto &candidate_road : target_intersection)
|
||||
{
|
||||
const auto &candidate_data = node_based_graph.GetEdgeData(candidate_road.eid);
|
||||
const auto &candidate_data = node_data_container.GetAnnotation(
|
||||
node_based_graph.GetEdgeData(candidate_road.eid).annotation_data);
|
||||
|
||||
// Name mismatch: check roads at `c` and `d` for same name
|
||||
const auto name_mismatch = [&](const NameID road_name_id) {
|
||||
@@ -489,15 +495,20 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
|
||||
|
||||
// Check if main road -> sliproad (non-link) -> candidate road requires two name
|
||||
// announcements then don't suppress one announcement via sliproad handler
|
||||
const auto main_road_name_id = node_based_graph.GetEdgeData(main_road.eid).name_id;
|
||||
if (!sliproad_data.road_classification.IsLinkClass() &&
|
||||
sliproad_data.name_id != EMPTY_NAMEID && main_road_name_id != EMPTY_NAMEID &&
|
||||
const auto main_road_name_id =
|
||||
node_data_container
|
||||
.GetAnnotation(node_based_graph.GetEdgeData(main_road.eid).annotation_data)
|
||||
.name_id;
|
||||
const auto &sliproad_annotation =
|
||||
node_data_container.GetAnnotation(sliproad_edge_data.annotation_data);
|
||||
if (!sliproad_edge_data.flags.road_classification.IsLinkClass() &&
|
||||
sliproad_annotation.name_id != EMPTY_NAMEID && main_road_name_id != EMPTY_NAMEID &&
|
||||
candidate_data.name_id != EMPTY_NAMEID &&
|
||||
util::guidance::requiresNameAnnounced(main_road_name_id,
|
||||
sliproad_data.name_id,
|
||||
sliproad_annotation.name_id,
|
||||
name_table,
|
||||
street_name_suffix_table) &&
|
||||
util::guidance::requiresNameAnnounced(sliproad_data.name_id,
|
||||
util::guidance::requiresNameAnnounced(sliproad_annotation.name_id,
|
||||
candidate_data.name_id,
|
||||
name_table,
|
||||
street_name_suffix_table))
|
||||
@@ -553,6 +564,8 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
|
||||
// In those cases the obvious non-Sliproad is now obvious and we discard the Fork turn type.
|
||||
if (sliproad_found && main_road.instruction.type == TurnType::Fork)
|
||||
{
|
||||
const auto &main_data = node_based_graph.GetEdgeData(main_road.eid);
|
||||
const auto &main_annotation = node_data_container.GetAnnotation(main_data.annotation_data);
|
||||
if (isSameName(source_edge_id, main_road.eid))
|
||||
{
|
||||
if (angularDeviation(main_road.angle, STRAIGHT_ANGLE) < 5)
|
||||
@@ -562,7 +575,7 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter
|
||||
intersection[*obvious].instruction.direction_modifier =
|
||||
getTurnDirection(intersection[*obvious].angle);
|
||||
}
|
||||
else if (node_based_graph.GetEdgeData(main_road.eid).name_id != EMPTY_NAMEID)
|
||||
else if (main_annotation.name_id != EMPTY_NAMEID)
|
||||
{
|
||||
intersection[*obvious].instruction.type = TurnType::NewName;
|
||||
intersection[*obvious].instruction.direction_modifier =
|
||||
@@ -644,7 +657,7 @@ bool SliproadHandler::nextIntersectionIsTooFarAway(const NodeID start, const Edg
|
||||
const auto &coordinate_extractor = intersection_generator.GetCoordinateExtractor();
|
||||
|
||||
// Base max distance threshold on the current road class we're on
|
||||
const auto &data = node_based_graph.GetEdgeData(onto);
|
||||
const auto &data = node_based_graph.GetEdgeData(onto).flags;
|
||||
const auto threshold = scaledThresholdByRoadClass(MAX_SLIPROAD_THRESHOLD, // <- scales down
|
||||
data.road_classification);
|
||||
|
||||
@@ -662,13 +675,15 @@ bool SliproadHandler::isThroughStreet(const EdgeID from, const IntersectionView
|
||||
BOOST_ASSERT(from != SPECIAL_EDGEID);
|
||||
BOOST_ASSERT(!intersection.empty());
|
||||
|
||||
const auto &edge_name_id = node_based_graph.GetEdgeData(from).name_id;
|
||||
const auto from_annotation_id = node_based_graph.GetEdgeData(from).annotation_data;
|
||||
const auto &edge_name_id = node_data_container.GetAnnotation(from_annotation_id).name_id;
|
||||
|
||||
auto first = begin(intersection) + 1; // Skip UTurn road
|
||||
auto last = end(intersection);
|
||||
|
||||
auto same_name = [&](const auto &road) {
|
||||
const auto &road_name_id = node_based_graph.GetEdgeData(road.eid).name_id;
|
||||
const auto annotation_id = node_based_graph.GetEdgeData(road.eid).annotation_data;
|
||||
const auto &road_name_id = node_data_container.GetAnnotation(annotation_id).name_id;
|
||||
|
||||
return edge_name_id != EMPTY_NAMEID && //
|
||||
road_name_id != EMPTY_NAMEID && //
|
||||
@@ -683,10 +698,13 @@ bool SliproadHandler::isThroughStreet(const EdgeID from, const IntersectionView
|
||||
|
||||
bool SliproadHandler::roadContinues(const EdgeID current, const EdgeID next) const
|
||||
{
|
||||
const auto ¤t_data = node_based_graph.GetEdgeData(current);
|
||||
const auto &next_data = node_based_graph.GetEdgeData(next);
|
||||
const auto ¤t_data =
|
||||
node_data_container.GetAnnotation(node_based_graph.GetEdgeData(current).annotation_data);
|
||||
const auto &next_data =
|
||||
node_data_container.GetAnnotation(node_based_graph.GetEdgeData(next).annotation_data);
|
||||
|
||||
auto same_road_category = current_data.road_classification == next_data.road_classification;
|
||||
auto same_road_category = node_based_graph.GetEdgeData(current).flags.road_classification ==
|
||||
node_based_graph.GetEdgeData(next).flags.road_classification;
|
||||
auto same_travel_mode = current_data.travel_mode == next_data.travel_mode;
|
||||
|
||||
auto same_name = current_data.name_id != EMPTY_NAMEID && //
|
||||
@@ -730,22 +748,18 @@ bool SliproadHandler::isValidSliproadArea(const double max_area,
|
||||
}
|
||||
|
||||
bool SliproadHandler::isValidSliproadLink(const IntersectionViewData &sliproad,
|
||||
const IntersectionViewData &first,
|
||||
const IntersectionViewData & /*first*/,
|
||||
const IntersectionViewData &second) const
|
||||
{
|
||||
// If the sliproad is not a link we don't care
|
||||
const auto &sliproad_data = node_based_graph.GetEdgeData(sliproad.eid);
|
||||
// If the Sliproad is not a link we don't care
|
||||
const auto &sliproad_data = node_based_graph.GetEdgeData(sliproad.eid).flags;
|
||||
if (!sliproad_data.road_classification.IsLinkClass())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// otherwise the first road leading to the intersection we shortcut
|
||||
// can be a link or a usual road (ignore the check at this place)
|
||||
(void)first;
|
||||
|
||||
// and the second road coming from the intersection we shortcut must be a non-link
|
||||
const auto &second_road_data = node_based_graph.GetEdgeData(second.eid);
|
||||
const auto &second_road_data = node_based_graph.GetEdgeData(second.eid).flags;
|
||||
if (second_road_data.road_classification.IsLinkClass())
|
||||
{
|
||||
return false;
|
||||
@@ -758,10 +772,15 @@ bool SliproadHandler::allSameMode(const EdgeID from,
|
||||
const EdgeID sliproad_candidate,
|
||||
const EdgeID target_road) const
|
||||
{
|
||||
return node_based_graph.GetEdgeData(from).travel_mode ==
|
||||
node_based_graph.GetEdgeData(sliproad_candidate).travel_mode &&
|
||||
node_based_graph.GetEdgeData(sliproad_candidate).travel_mode ==
|
||||
node_based_graph.GetEdgeData(target_road).travel_mode;
|
||||
const auto &from_annotation =
|
||||
node_data_container.GetAnnotation(node_based_graph.GetEdgeData(from).annotation_data);
|
||||
const auto &sliproad_annotation = node_data_container.GetAnnotation(
|
||||
node_based_graph.GetEdgeData(sliproad_candidate).annotation_data);
|
||||
const auto &target_annotation = node_data_container.GetAnnotation(
|
||||
node_based_graph.GetEdgeData(target_road).annotation_data);
|
||||
|
||||
return (from_annotation.travel_mode == sliproad_annotation.travel_mode) &&
|
||||
(target_annotation.travel_mode == sliproad_annotation.travel_mode);
|
||||
}
|
||||
|
||||
bool SliproadHandler::canBeTargetOfSliproad(const IntersectionView &intersection)
|
||||
|
||||
Reference in New Issue
Block a user