Adjust to review findings

This commit is contained in:
Michael Krasnyk 2017-12-05 14:54:20 +01:00
parent 60ef179d18
commit 0568dca4a3
5 changed files with 47 additions and 45 deletions

View File

@ -2,6 +2,7 @@
#define OSRM_EXTRACTOR_GUIDANCE_MERGEABLE_ROADS #define OSRM_EXTRACTOR_GUIDANCE_MERGEABLE_ROADS
#include "extractor/compressed_edge_container.hpp" #include "extractor/compressed_edge_container.hpp"
#include "extractor/guidance/coordinate_extractor.hpp"
#include "extractor/guidance/intersection.hpp" #include "extractor/guidance/intersection.hpp"
#include "extractor/guidance/turn_lane_types.hpp" #include "extractor/guidance/turn_lane_types.hpp"
#include "extractor/restriction_index.hpp" #include "extractor/restriction_index.hpp"
@ -47,7 +48,6 @@ class MergableRoadDetector
const RestrictionMap &node_restriction_map, const RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes, const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data, const guidance::TurnLanesIndexedArray &turn_lanes_data,
const CoordinateExtractor &coordinate_extractor,
const util::NameTable &name_table, const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table); const SuffixTable &street_name_suffix_table);
@ -170,12 +170,13 @@ class MergableRoadDetector
const RestrictionMap &node_restriction_map; const RestrictionMap &node_restriction_map;
const std::unordered_set<NodeID> &barrier_nodes; const std::unordered_set<NodeID> &barrier_nodes;
const guidance::TurnLanesIndexedArray &turn_lanes_data; const guidance::TurnLanesIndexedArray &turn_lanes_data;
const CoordinateExtractor &coordinate_extractor;
// name detection // name detection
const util::NameTable &name_table; const util::NameTable &name_table;
const SuffixTable &street_name_suffix_table; const SuffixTable &street_name_suffix_table;
const CoordinateExtractor coordinate_extractor;
// limit for detecting circles / parallel roads // limit for detecting circles / parallel roads
const static double constexpr distance_to_extract = 150; const static double constexpr distance_to_extract = 150;
}; };

View File

@ -57,6 +57,9 @@ convertToIntersectionView(const util::NodeBasedDynamicGraph &graph,
const IntersectionEdges &outgoing_edges, const IntersectionEdges &outgoing_edges,
const std::unordered_set<EdgeID> &merged_edges); const std::unordered_set<EdgeID> &merged_edges);
// Check for restrictions/barriers and generate a list of valid and invalid turns present at
// the node reached from `incoming_edge`. The resulting candidates have to be analyzed
// for their actual instructions later on.
guidance::IntersectionView guidance::IntersectionView
getConnectedRoads(const util::NodeBasedDynamicGraph &graph, getConnectedRoads(const util::NodeBasedDynamicGraph &graph,
const EdgeBasedNodeDataContainer &node_data_container, const EdgeBasedNodeDataContainer &node_data_container,
@ -67,6 +70,13 @@ getConnectedRoads(const util::NodeBasedDynamicGraph &graph,
const guidance::TurnLanesIndexedArray &turn_lanes_data, const guidance::TurnLanesIndexedArray &turn_lanes_data,
const IntersectionEdge &incoming_edge); const IntersectionEdge &incoming_edge);
// 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
// down a road, finding the next actual decision requires the look at multiple intersections.
// Here we follow the road until we either reach a dead end or find the next intersection with
// more than a single next road. This function skips over degree two nodes to find correct input
// for getConnectedRoads.
IntersectionEdge skipDegreeTwoNodes(const util::NodeBasedDynamicGraph &graph, IntersectionEdge skipDegreeTwoNodes(const util::NodeBasedDynamicGraph &graph,
IntersectionEdge road); IntersectionEdge road);
} }

View File

@ -423,11 +423,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
TurnDataExternalContainer turn_data_container; TurnDataExternalContainer turn_data_container;
// TODO: add a MergableRoadDetector instance, to be deleted later
SuffixTable street_name_suffix_table(scripting_environment); SuffixTable street_name_suffix_table(scripting_environment);
const auto &turn_lanes_data = transformTurnLaneMapIntoArrays(lane_description_map); const auto &turn_lanes_data = transformTurnLaneMapIntoArrays(lane_description_map);
guidance::CoordinateExtractor coordinate_extractor(
m_node_based_graph, m_compressed_edge_container, m_coordinates);
guidance::MergableRoadDetector mergable_road_detector(m_node_based_graph, guidance::MergableRoadDetector mergable_road_detector(m_node_based_graph,
m_edge_based_node_container, m_edge_based_node_container,
m_coordinates, m_coordinates,
@ -435,7 +432,6 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
node_restriction_map, node_restriction_map,
m_barrier_nodes, m_barrier_nodes,
turn_lanes_data, turn_lanes_data,
coordinate_extractor,
name_table, name_table,
street_name_suffix_table); street_name_suffix_table);
@ -562,14 +558,14 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
// the situation of the turn // the situation of the turn
const auto node_along_road_entering, const auto node_along_road_entering,
const auto node_based_edge_from, const auto node_based_edge_from,
const auto node_at_center_of_intersection, const auto intersection_node,
const auto node_based_edge_to, const auto node_based_edge_to,
const auto incoming_bearing, const auto incoming_bearing,
const auto &turn, const auto &turn,
const auto entry_class_id) { const auto entry_class_id) {
const auto node_restricted = isRestricted(node_along_road_entering, const auto node_restricted = isRestricted(node_along_road_entering,
node_at_center_of_intersection, intersection_node,
m_node_based_graph.GetTarget(turn.eid), m_node_based_graph.GetTarget(turn.eid),
conditional_restriction_map); conditional_restriction_map);
@ -581,7 +577,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
conditional = {{edge_based_node_from, conditional = {{edge_based_node_from,
edge_based_node_to, edge_based_node_to,
{static_cast<std::uint64_t>(-1), {static_cast<std::uint64_t>(-1),
m_coordinates[node_at_center_of_intersection], m_coordinates[intersection_node],
conditions}}}; conditions}}};
} }
@ -601,10 +597,10 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
util::guidance::TurnBearing(turn.bearing)}; util::guidance::TurnBearing(turn.bearing)};
// compute weight and duration penalties // compute weight and duration penalties
auto is_traffic_light = m_traffic_lights.count(node_at_center_of_intersection); auto is_traffic_light = m_traffic_lights.count(intersection_node);
ExtractionTurn extracted_turn( ExtractionTurn extracted_turn(
turn.angle, turn.angle,
m_node_based_graph.GetOutDegree(node_at_center_of_intersection), m_node_based_graph.GetOutDegree(intersection_node),
turn.instruction.IsUTurn(), turn.instruction.IsUTurn(),
is_traffic_light, is_traffic_light,
edge_data1.flags.restricted, edge_data1.flags.restricted,
@ -655,8 +651,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
: m_compressed_edge_container.GetLastEdgeSourceID(node_based_edge_from); : m_compressed_edge_container.GetLastEdgeSourceID(node_based_edge_from);
const auto &to_node = m_compressed_edge_container.GetFirstEdgeTargetID(turn.eid); const auto &to_node = m_compressed_edge_container.GetFirstEdgeTargetID(turn.eid);
lookup::TurnIndexBlock turn_index_block = { lookup::TurnIndexBlock turn_index_block = {from_node, intersection_node, to_node};
from_node, node_at_center_of_intersection, to_node};
// insert data into the designated buffer // insert data into the designated buffer
return std::make_pair( return std::make_pair(
@ -678,25 +673,26 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
if (buffer->nodes_processed == 0) if (buffer->nodes_processed == 0)
return buffer; return buffer;
for (auto node_at_center_of_intersection = intersection_node_range.begin(), for (auto intersection_node = intersection_node_range.begin(),
end = intersection_node_range.end(); end = intersection_node_range.end();
node_at_center_of_intersection < end; intersection_node < end;
++node_at_center_of_intersection) ++intersection_node)
{ {
// We capture the thread-local work in these objects, then flush // We capture the thread-local work in these objects, then flush
// them in a controlled manner at the end of the parallel range // them in a controlled manner at the end of the parallel range
const auto &incoming_edges = intersection::getIncomingEdges( const auto &incoming_edges =
m_node_based_graph, node_at_center_of_intersection); intersection::getIncomingEdges(m_node_based_graph, intersection_node);
const auto &outgoing_edges = intersection::getOutgoingEdges( const auto &outgoing_edges =
m_node_based_graph, node_at_center_of_intersection); intersection::getOutgoingEdges(m_node_based_graph, intersection_node);
const auto &edge_geometries_and_merged_edges =
intersection::IntersectionEdgeGeometries edge_geometries;
std::unordered_set<EdgeID> merged_edge_ids;
std::tie(edge_geometries, merged_edge_ids) =
intersection::getIntersectionGeometries(m_node_based_graph, intersection::getIntersectionGeometries(m_node_based_graph,
m_compressed_edge_container, m_compressed_edge_container,
m_coordinates, m_coordinates,
mergable_road_detector, mergable_road_detector,
node_at_center_of_intersection); intersection_node);
const auto &edge_geometries = edge_geometries_and_merged_edges.first;
const auto &merged_edge_ids = edge_geometries_and_merged_edges.second;
// all nodes in the graph are connected in both directions. We check all // all nodes in the graph are connected in both directions. We check all
// outgoing nodes to find the incoming edge. This is a larger search overhead, // outgoing nodes to find the incoming edge. This is a larger search overhead,
@ -735,15 +731,14 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
auto intersection = turn_analysis.AssignTurnTypes( auto intersection = turn_analysis.AssignTurnTypes(
incoming_edge.node, incoming_edge.edge, intersection_view); incoming_edge.node, incoming_edge.edge, intersection_view);
OSRM_ASSERT(intersection.valid(), OSRM_ASSERT(intersection.valid(), m_coordinates[intersection_node]);
m_coordinates[node_at_center_of_intersection]);
intersection = turn_lane_handler.assignTurnLanes( intersection = turn_lane_handler.assignTurnLanes(
incoming_edge.node, incoming_edge.edge, std::move(intersection)); incoming_edge.node, incoming_edge.edge, std::move(intersection));
// the entry class depends on the turn, so we have to classify the // the entry class depends on the turn, so we have to classify the
// interesction for every edge // interesction for every edge
const auto turn_classification = classifyIntersection( const auto turn_classification =
intersection, m_coordinates[node_at_center_of_intersection]); classifyIntersection(intersection, m_coordinates[intersection_node]);
const auto entry_class_id = const auto entry_class_id =
entry_class_hash.ConcurrentFindOrAdd(turn_classification.first); entry_class_hash.ConcurrentFindOrAdd(turn_classification.first);
@ -754,12 +749,11 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
// Note - this is strictly speaking not thread safe, but we know we // Note - this is strictly speaking not thread safe, but we know we
// should never be touching the same element twice, so we should // should never be touching the same element twice, so we should
// be fine. // be fine.
bearing_class_by_node_based_node[node_at_center_of_intersection] = bearing_class_by_node_based_node[intersection_node] = bearing_class_id;
bearing_class_id;
// check if we are turning off a via way // check if we are turning off a via way
const auto turning_off_via_way = way_restriction_map.IsViaWay( const auto turning_off_via_way =
incoming_edge.node, node_at_center_of_intersection); way_restriction_map.IsViaWay(incoming_edge.node, intersection_node);
// Save reversed incoming bearing to compute turn angles // Save reversed incoming bearing to compute turn angles
const auto reversed_incoming_bearing = util::bearing::reverse( const auto reversed_incoming_bearing = util::bearing::reverse(
@ -783,7 +777,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
[edge = outgoing_edge.edge](const auto &road) { [edge = outgoing_edge.edge](const auto &road) {
return road.eid == edge; return road.eid == edge;
}); });
BOOST_ASSERT(turn != intersection.end()); OSRM_ASSERT(turn != intersection.end(),
m_coordinates[intersection_node]);
// In case a way restriction starts at a given location, add a turn onto // In case a way restriction starts at a given location, add a turn onto
// every artificial node eminating here. // every artificial node eminating here.
@ -848,7 +843,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
if (turning_off_via_way) if (turning_off_via_way)
{ {
const auto duplicated_nodes = way_restriction_map.DuplicatedNodeIDs( const auto duplicated_nodes = way_restriction_map.DuplicatedNodeIDs(
incoming_edge.node, node_at_center_of_intersection); incoming_edge.node, intersection_node);
// next to the normal restrictions tracked in `entry_allowed`, via // next to the normal restrictions tracked in `entry_allowed`, via
// ways might introduce additional restrictions. These are handled // ways might introduce additional restrictions. These are handled
@ -903,7 +898,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
{from_id, {from_id,
nbe_to_ebn_mapping[outgoing_edge.edge], nbe_to_ebn_mapping[outgoing_edge.edge],
{static_cast<std::uint64_t>(-1), {static_cast<std::uint64_t>(-1),
m_coordinates[node_at_center_of_intersection], m_coordinates[intersection_node],
restriction.condition}}); restriction.condition}});
} }
} }

View File

@ -1,6 +1,5 @@
#include "extractor/guidance/mergable_road_detector.hpp" #include "extractor/guidance/mergable_road_detector.hpp"
#include "extractor/guidance/constants.hpp" #include "extractor/guidance/constants.hpp"
#include "extractor/guidance/coordinate_extractor.hpp"
#include "extractor/guidance/node_based_graph_walker.hpp" #include "extractor/guidance/node_based_graph_walker.hpp"
#include "extractor/intersection/intersection_analysis.hpp" #include "extractor/intersection/intersection_analysis.hpp"
#include "extractor/query_node.hpp" #include "extractor/query_node.hpp"
@ -60,14 +59,14 @@ MergableRoadDetector::MergableRoadDetector(
const RestrictionMap &node_restriction_map, const RestrictionMap &node_restriction_map,
const std::unordered_set<NodeID> &barrier_nodes, const std::unordered_set<NodeID> &barrier_nodes,
const guidance::TurnLanesIndexedArray &turn_lanes_data, const guidance::TurnLanesIndexedArray &turn_lanes_data,
const CoordinateExtractor &coordinate_extractor,
const util::NameTable &name_table, const util::NameTable &name_table,
const SuffixTable &street_name_suffix_table) const SuffixTable &street_name_suffix_table)
: node_based_graph(node_based_graph), node_data_container(node_data_container), : node_based_graph(node_based_graph), node_data_container(node_data_container),
node_coordinates(node_coordinates), compressed_geometries(compressed_geometries), node_coordinates(node_coordinates), compressed_geometries(compressed_geometries),
node_restriction_map(node_restriction_map), barrier_nodes(barrier_nodes), node_restriction_map(node_restriction_map), barrier_nodes(barrier_nodes),
turn_lanes_data(turn_lanes_data), coordinate_extractor(coordinate_extractor), turn_lanes_data(turn_lanes_data), name_table(name_table),
name_table(name_table), street_name_suffix_table(street_name_suffix_table) street_name_suffix_table(street_name_suffix_table),
coordinate_extractor(node_based_graph, compressed_geometries, node_coordinates)
{ {
} }

View File

@ -43,11 +43,7 @@ IntersectionEdges getOutgoingEdges(const util::NodeBasedDynamicGraph &graph,
for (const auto outgoing_edge : graph.GetAdjacentEdgeRange(intersection_node)) for (const auto outgoing_edge : graph.GetAdjacentEdgeRange(intersection_node))
{ {
// TODO: to use TurnAnalysis all outgoing edges are required, to be uncommented later result.push_back({intersection_node, outgoing_edge});
// if (!graph.GetEdgeData(outgoing_edge).reversed)
{
result.push_back({intersection_node, outgoing_edge});
}
} }
BOOST_ASSERT(std::is_sorted(result.begin(), result.end())); BOOST_ASSERT(std::is_sorted(result.begin(), result.end()));
@ -558,6 +554,7 @@ bool isTurnAllowed(const util::NodeBasedDynamicGraph &graph,
return true; return true;
// Allow U-turn if the incoming edge has a U-turn lane // Allow U-turn if the incoming edge has a U-turn lane
// TODO: revisit the use-case, related PR #2753
const auto &incoming_edge_annotation_id = graph.GetEdgeData(from.edge).annotation_data; const auto &incoming_edge_annotation_id = graph.GetEdgeData(from.edge).annotation_data;
const auto lane_description_id = static_cast<std::size_t>( const auto lane_description_id = static_cast<std::size_t>(
node_data_container.GetAnnotation(incoming_edge_annotation_id).lane_description_id); node_data_container.GetAnnotation(incoming_edge_annotation_id).lane_description_id);
@ -722,7 +719,7 @@ convertToIntersectionView(const util::NodeBasedDynamicGraph &graph,
next != pre_intersection_view.end(); next != pre_intersection_view.end();
++curr, ++next) ++curr, ++next)
{ {
// Check the the perceived angles order is the same as the initial OSM one // Check that the perceived angles order is the same as the initial OSM one
if (next->first.angle < curr->first.angle) if (next->first.angle < curr->first.angle)
{ // If the true bearing is out of the initial order (next before current) then { // If the true bearing is out of the initial order (next before current) then
// adjust the next road angle to keep the order. The adjustment angle is at most // adjust the next road angle to keep the order. The adjustment angle is at most