Skip to content

Commit

Permalink
Account merged edges when processing turn legs
Browse files Browse the repository at this point in the history
  • Loading branch information
themylogin committed Jan 27, 2021
1 parent e7acc9d commit d9d8739
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 19 deletions.
9 changes: 9 additions & 0 deletions include/extractor/intersection/intersection_analysis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NodeID> &barrier_nodes,
const TurnLanesIndexedArray &turn_lanes_data,
const IntersectionEdge &incoming_edge,
const IntersectionEdgeGeometries &edge_geometries,
const std::unordered_set<EdgeID> &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
Expand Down
16 changes: 8 additions & 8 deletions src/extractor/edge_based_graph_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,14 +715,14 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
++node_based_edge_counter;

const auto connected_roads =
extractor::intersection::getConnectedRoads<false>(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 =
Expand Down
45 changes: 34 additions & 11 deletions src/extractor/intersection/intersection_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<USE_CLOSE_COORDINATE>(
graph, compressed_geometries, node_coordinates, intersection_node);
auto merged_edge_ids = std::unordered_set<EdgeID>();

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<NodeID> &barrier_nodes,
const TurnLanesIndexedArray &turn_lanes_data,
const IntersectionEdge &incoming_edge,
const IntersectionEdgeGeometries &edge_geometries,
const std::unordered_set<EdgeID> &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<EdgeID>());
merged_edge_ids);
}

template IntersectionView
Expand Down

0 comments on commit d9d8739

Please sign in to comment.