From d9d873903feacf4c96d057f04e7be71bcb163fd3 Mon Sep 17 00:00:00 2001 From: themylogin Date: Sun, 16 Dec 2018 17:49:13 +0100 Subject: [PATCH] Account merged edges when processing turn legs --- .../intersection/intersection_analysis.hpp | 9 ++++ src/extractor/edge_based_graph_factory.cpp | 16 +++---- .../intersection/intersection_analysis.cpp | 45 ++++++++++++++----- 3 files changed, 51 insertions(+), 19 deletions(-) diff --git a/include/extractor/intersection/intersection_analysis.hpp b/include/extractor/intersection/intersection_analysis.hpp index 6dafcb7bc26..df5f51992ee 100644 --- a/include/extractor/intersection/intersection_analysis.hpp +++ b/include/extractor/intersection/intersection_analysis.hpp @@ -70,6 +70,15 @@ IntersectionView getConnectedRoads(const util::NodeBasedDynamicGraph &graph, const TurnLanesIndexedArray &turn_lanes_data, const IntersectionEdge &incoming_edge); +IntersectionView getConnectedRoadsForEdgeGeometries(const util::NodeBasedDynamicGraph &graph, + const EdgeBasedNodeDataContainer &node_data_container, + const RestrictionMap &node_restriction_map, + const std::unordered_set &barrier_nodes, + const TurnLanesIndexedArray &turn_lanes_data, + const IntersectionEdge &incoming_edge, + const IntersectionEdgeGeometries &edge_geometries, + const std::unordered_set &merged_edge_ids); + // Graph Compression cannot compress every setting. For example any barrier/traffic light cannot // be compressed. As a result, a simple road of the form `a ----- b` might end up as having an // intermediate intersection, if there is a traffic light in between. If we want to look farther diff --git a/src/extractor/edge_based_graph_factory.cpp b/src/extractor/edge_based_graph_factory.cpp index 4a73d1d3df3..06a1ce15f7d 100644 --- a/src/extractor/edge_based_graph_factory.cpp +++ b/src/extractor/edge_based_graph_factory.cpp @@ -715,14 +715,14 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges( ++node_based_edge_counter; const auto connected_roads = - extractor::intersection::getConnectedRoads(m_node_based_graph, - m_edge_based_node_container, - m_coordinates, - m_compressed_edge_container, - unconditional_node_restriction_map, - m_barrier_nodes, - turn_lanes_data, - incoming_edge); + extractor::intersection::getConnectedRoadsForEdgeGeometries(m_node_based_graph, + m_edge_based_node_container, + unconditional_node_restriction_map, + m_barrier_nodes, + turn_lanes_data, + incoming_edge, + edge_geometries, + merged_edge_ids); // check if this edge is part of a restriction via-way const auto is_restriction_via_edge = diff --git a/src/extractor/intersection/intersection_analysis.cpp b/src/extractor/intersection/intersection_analysis.cpp index e96a814fb14..ded594ac6f7 100644 --- a/src/extractor/intersection/intersection_analysis.cpp +++ b/src/extractor/intersection/intersection_analysis.cpp @@ -741,36 +741,59 @@ IntersectionView getConnectedRoads(const util::NodeBasedDynamicGraph &graph, const IntersectionEdge &incoming_edge) { const auto intersection_node = graph.GetTarget(incoming_edge.edge); - const auto &outgoing_edges = intersection::getOutgoingEdges(graph, intersection_node); auto edge_geometries = getIntersectionOutgoingGeometries( graph, compressed_geometries, node_coordinates, intersection_node); + auto merged_edge_ids = std::unordered_set(); + + return getConnectedRoadsForEdgeGeometries(graph, + node_data_container, + node_restriction_map, + barrier_nodes, + turn_lanes_data, + incoming_edge, + edge_geometries, + merged_edge_ids); +} + +IntersectionView getConnectedRoadsForEdgeGeometries(const util::NodeBasedDynamicGraph &graph, + const EdgeBasedNodeDataContainer &node_data_container, + const RestrictionMap &node_restriction_map, + const std::unordered_set &barrier_nodes, + const TurnLanesIndexedArray &turn_lanes_data, + const IntersectionEdge &incoming_edge, + const IntersectionEdgeGeometries &edge_geometries, + const std::unordered_set &merged_edge_ids) +{ + const auto intersection_node = graph.GetTarget(incoming_edge.edge); + const auto &outgoing_edges = intersection::getOutgoingEdges(graph, intersection_node); // Add incoming edges with reversed bearings - const auto edges_number = edge_geometries.size(); - edge_geometries.resize(2 * edges_number); + auto processed_edge_geometries = IntersectionEdgeGeometries(edge_geometries); + const auto edges_number = processed_edge_geometries.size(); + processed_edge_geometries.resize(2 * edges_number); for (std::size_t index = 0; index < edges_number; ++index) { - const auto &geometry = edge_geometries[index]; + const auto &geometry = processed_edge_geometries[index]; const auto remote_node = graph.GetTarget(geometry.eid); const auto incoming_edge = graph.FindEdge(remote_node, intersection_node); - edge_geometries[edges_number + index] = {incoming_edge, - util::bearing::reverse(geometry.initial_bearing), - util::bearing::reverse(geometry.perceived_bearing), - geometry.segment_length}; + processed_edge_geometries[edges_number + index] = {incoming_edge, + util::bearing::reverse(geometry.initial_bearing), + util::bearing::reverse(geometry.perceived_bearing), + geometry.segment_length}; } // Enforce ordering of edges by IDs - std::sort(edge_geometries.begin(), edge_geometries.end()); + std::sort(processed_edge_geometries.begin(), processed_edge_geometries.end()); return convertToIntersectionView(graph, node_data_container, node_restriction_map, barrier_nodes, - edge_geometries, + processed_edge_geometries, turn_lanes_data, incoming_edge, outgoing_edges, - std::unordered_set()); + merged_edge_ids); } template IntersectionView