From c74205e5ed2941564bf6eb719c166e9da1cc0e13 Mon Sep 17 00:00:00 2001 From: Duane Gearhart Date: Sat, 27 Jan 2018 20:26:08 -0500 Subject: [PATCH 01/16] Initial internal intersection updates paired with @oxidase and @kdiluca TODO fix tests and add in new ones --- ...segregated_intersection_classification.cpp | 255 +++++++++++------- 1 file changed, 152 insertions(+), 103 deletions(-) diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index b7f891a7ba5..6fc8c79d1f4 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -14,16 +14,20 @@ namespace RoadPriorityClass = extractor::RoadPriorityClass; struct EdgeInfo { + EdgeID edge; + NodeID node; util::StringView name; + bool reversed; + // 0 - outgoing (forward), 1 - incoming (reverse), 2 - both outgoing and incoming int direction; extractor::ClassData road_class; - RoadPriorityClass::Enum road_priority_class; + NodeBasedEdgeClassification flags; struct LessName { @@ -31,106 +35,13 @@ struct EdgeInfo }; }; -bool IsSegregated(std::vector v1, - std::vector v2, - EdgeInfo const ¤t, - double edgeLength) -{ - if (v1.size() < 2 || v2.size() < 2) - return false; - - auto const sort_by_name_fn = [](std::vector &v) { - std::sort(v.begin(), v.end(), EdgeInfo::LessName()); - }; - - sort_by_name_fn(v1); - sort_by_name_fn(v2); - - // Internal edge with the name should be connected with any other neibour edge with the same - // name, e.g. isolated edge with unique name is not segregated. - // b - 'b' road continues here - // | - // - - a - | - // b - segregated edge - // - - a - | - if (!current.name.empty()) - { - auto const findNameFn = [¤t](std::vector const &v) { - return std::binary_search(v.begin(), v.end(), current, EdgeInfo::LessName()); - }; - - if (!findNameFn(v1) && !findNameFn(v2)) - return false; - } - - // set_intersection like routine to get equal result pairs - std::vector> commons; - - auto i1 = v1.begin(); - auto i2 = v2.begin(); - - while (i1 != v1.end() && i2 != v2.end()) - { - if (i1->name == i2->name) - { - if (!i1->name.empty()) - commons.push_back(std::make_pair(&(*i1), &(*i2))); - - ++i1; - ++i2; - } - else if (i1->name < i2->name) - ++i1; - else - ++i2; - } - - if (commons.size() < 2) - return false; - - auto const check_equal_class = [](std::pair const &e) { - // Or (e.first->road_class & e.second->road_class != 0) - return e.first->road_class == e.second->road_class; - }; - - size_t equal_class_count = 0; - for (auto const &e : commons) - if (check_equal_class(e)) - ++equal_class_count; - - if (equal_class_count < 2) - return false; - - auto const get_length_threshold = [](EdgeInfo const *e) { - switch (e->road_priority_class) - { - case RoadPriorityClass::MOTORWAY: - case RoadPriorityClass::TRUNK: - return 30.0; - case RoadPriorityClass::PRIMARY: - return 20.0; - case RoadPriorityClass::SECONDARY: - case RoadPriorityClass::TERTIARY: - return 10.0; - default: - return 5.0; - } - }; - - double threshold = std::numeric_limits::max(); - for (auto const &e : commons) - threshold = - std::min(threshold, get_length_threshold(e.first) + get_length_threshold(e.second)); - - return edgeLength <= threshold; -} - std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFactory &factory, const util::NameTable &names) { auto const &graph = factory.GetGraph(); auto const &annotation = factory.GetAnnotationData(); + auto const &coordinates = factory.GetCoordinates(); extractor::intersection::CoordinateExtractor coordExtractor( graph, factory.GetCompressedEdges(), factory.GetCoordinates()); @@ -145,18 +56,139 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa return length; }; - auto const get_edge_info = [&](NodeID node, auto const &edgeData) -> EdgeInfo { + // Returns an angle between edges from from_edge_id to to_edge_id + auto const get_angle = [&](NodeID from_node, EdgeID from_edge_id, NodeID to_edge_id) { + auto intersection_node = graph.GetTarget(from_edge_id); + auto from_edge_id_outgoing = graph.FindEdge(intersection_node, from_node); + auto to_node = graph.GetTarget(to_edge_id); + auto const node_to = + coordExtractor.GetCoordinateCloseToTurn(intersection_node, to_edge_id, false, to_node); + auto const node_from = coordExtractor.GetCoordinateCloseToTurn( + intersection_node, from_edge_id_outgoing, false, from_node); + return util::coordinate_calculation::computeAngle( + node_from, coordinates[intersection_node], node_to); + }; + + auto const get_edge_info = [&](EdgeID edge_id, NodeID node, auto const &edgeData) -> EdgeInfo { /// @todo Make string normalization/lowercase/trim for comparison ... auto const id = annotation[edgeData.annotation_data].name_id; BOOST_ASSERT(id != INVALID_NAMEID); auto const name = names.GetNameForID(id); - return {node, + return {edge_id, + node, name, + edgeData.reversed, edgeData.reversed ? 1 : 0, annotation[edgeData.annotation_data].classes, - edgeData.flags.road_classification.GetClass()}; + edgeData.flags}; + }; + + auto is_bidirectional = [](auto flags) { return flags.is_split || (!flags.is_split && flags.forward && flags.backward); }; + + auto isSegregated = [&](NodeID node1, + std::vector v1, + NodeID node2, + std::vector v2, + EdgeInfo const ¤t, + double edgeLength) { + // Internal intersection edges must be short and cannot be a roundabout + // TODO adjust length as needed with lamda + if (edgeLength > 32.0f || current.flags.roundabout) { + return false; + } + + // Print information about angles at node 1 from all inbound edge to the current edge + std::cout << "\nINBOUND to NODE_1 | Angles at node " << node1 << "\n"; + bool oneway_inbound = false; + for (auto const &edge_from : v1) { + // Get the inbound edge and edge data + auto edge_inbound = graph.FindEdge(edge_from.node, node1); + auto const &edge_inbound_data = graph.GetEdgeData(edge_inbound); + if (!edge_inbound_data.reversed) { + // Skip any inbound edges not oneway (i.e. skip bidirectional) + // and link edge + // and not a road + if (is_bidirectional(edge_inbound_data.flags) + || edge_inbound_data.flags.road_classification.IsLinkClass() + || (edge_inbound_data.flags.road_classification.GetClass() > RoadPriorityClass::SIDE_RESIDENTIAL)) { + continue; + } + + // Get the turn degree from the inbound edge to the current edge + auto const turn_degree = get_angle(edge_from.node, edge_inbound, current.edge); + // Skip if the inbound edge is not somewhat perpendicular to the current edge + if (turn_degree > 150 && turn_degree < 210) { + continue; + } + + // TODO rm + std::cout << "Angle for (" << edge_from.node << ", " + << edge_inbound << " " << (is_bidirectional(edge_inbound_data.flags) ? "bidirectional" : "oneway") << " " + << " -> " + << current.edge << " " << (is_bidirectional(current.flags) ? "bidirectional" : "oneway") << ") " + << get_angle(edge_from.node, edge_inbound, current.edge) << "\n"; + + // If we are here the edge is a candidate oneway inbound + oneway_inbound = true; + break; + } + } + + // Return false if no valid oneway inbound edge + if (!oneway_inbound) { + return false; + } + + // Print information about angles at node 2 from the current edge to all outbound edges + std::cout << "OUTBOUND at NODE_2 | Angles at node " << node2 << "\n"; + bool oneway_outbound = false; + for (auto const &edge_to : v2) + { + if (!edge_to.reversed) + { + // Skip any outbound edges not oneway (i.e. skip bidirectional) + // and link edge + // and not a road + if (is_bidirectional(edge_to.flags) + || edge_to.flags.road_classification.IsLinkClass() + || (edge_to.flags.road_classification.GetClass() > RoadPriorityClass::SIDE_RESIDENTIAL)) { + continue; + } + + // Get the turn degree from the current edge to the outbound edge + auto const turn_degree = get_angle(node1, current.edge, edge_to.edge); + // Skip if the outbound edge is not somewhat perpendicular to the current edge + if (turn_degree > 150 && turn_degree < 210) { + continue; + } + + // TODO rm + std::cout << "Angle for (" << node1 << ", " + << current.edge << " " << (is_bidirectional(current.flags) ? "bidirectional" : "oneway") << " " + << " -> " + << edge_to.edge << " " << (is_bidirectional(edge_to.flags) ? "bidirectional" : "oneway") << ") " + << get_angle(node1, current.edge, edge_to.edge) << "\n"; + + // If we are here the edge is a candidate oneway outbound + oneway_outbound = true; + break; + } + } + + // Return false if no valid oneway outbound edge + if (!oneway_outbound) { + return false; + } + + // TODO - determine if we need to add name checks + + // TODO - do we need to check headings of the inbound and outbound + // oneway edges + + // Assume this is an intersection internal edge + return true; }; auto const collect_edge_info_fn = [&](auto const &edges1, NodeID node2) { @@ -168,7 +200,7 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa if (target == node2) continue; - info.push_back(get_edge_info(target, graph.GetEdgeData(e))); + info.push_back(get_edge_info(e, target, graph.GetEdgeData(e))); } if (info.empty()) @@ -203,15 +235,18 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa return info; }; - auto const isSegregatedFn = [&](auto const &edgeData, + auto const isSegregatedFn = [&](EdgeID edgeID, + auto const &edgeData, auto const &edges1, NodeID node1, auto const &edges2, NodeID node2, double edgeLength) { - return IsSegregated(collect_edge_info_fn(edges1, node2), + return isSegregated(node1, + collect_edge_info_fn(edges1, node2), + node2, collect_edge_info_fn(edges2, node1), - get_edge_info(node1, edgeData), + get_edge_info(edgeID, node1, edgeData), edgeLength); }; @@ -224,6 +259,20 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa { auto const &edgeData = graph.GetEdgeData(edgeID); + // { + + // auto rev_edge = graph.FindEdge(graph.GetTarget(edgeID), sourceID); + // auto const &rev_edgeData = graph.GetEdgeData(rev_edge); + // bool bidirectional = !edgeData.reversed && !rev_edgeData.reversed; + + // std::cout << "sourceID = " << sourceID << " edgeID " << edgeID << " targetID " << + // graph.GetTarget(edgeID) << " reversed flag " << edgeData.reversed << " " << + // (bidirectional ? "bidirectional" : "oneway edge") << " forward " << + // (int)edgeData.flags.forward << " backward " << (int)edgeData.flags.backward << " + // is_split " << (int)edgeData.flags.is_split << "\n"; + + // } + if (edgeData.reversed) continue; @@ -231,7 +280,7 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa auto const targetEdges = graph.GetAdjacentEdgeRange(targetID); double const length = get_edge_length(sourceID, edgeID, targetID); - if (isSegregatedFn(edgeData, sourceEdges, sourceID, targetEdges, targetID, length)) + if (isSegregatedFn(edgeID, edgeData, sourceEdges, sourceID, targetEdges, targetID, length)) segregated_edges.insert(edgeID); } } From 7400b22fa166d7f720f76bee9efd7720a927e018 Mon Sep 17 00:00:00 2001 From: Duane Gearhart Date: Thu, 1 Feb 2018 09:46:05 -0500 Subject: [PATCH 02/16] Added Internal Intersection Model --- .../guidance/internal-intersections.feature | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 features/guidance/internal-intersections.feature diff --git a/features/guidance/internal-intersections.feature b/features/guidance/internal-intersections.feature new file mode 100644 index 00000000000..d482e56f0f5 --- /dev/null +++ b/features/guidance/internal-intersections.feature @@ -0,0 +1,46 @@ +@guidance +Feature: Internal Intersection Model + + Background: + Given the profile "car" + Given a grid size of 10 meters + + Scenario: Dual-carriage way intersection + Given the node map + """ + a b + | | + c--d--e--f + | | + g--h--i--j + | | + k l + """ + + And the ways + | nodes | oneway | name | + | adhk | yes | Broken Land Parkway | + | lieb | yes | Broken Land Parkway | + | fed | yes | Snowden River Parkway | + | dc | yes | Patuxent Woods Drive | + | gh | yes | Patuxent Woods Drive | + | hij | yes | Snowden River Parkway | + + When I route I should get + | waypoints | route | turns | + | a,k | Broken Land Parkway,Broken Land Parkway | depart,arrive | + | l,b | Broken Land Parkway,Broken Land Parkway | depart,arrive | +# | g,j | Patuxent Woods Drive,Snowden River Parkway,Snowden River Parkway | depart,continue,arrive | +# | f,c | Snowden River Parkway,Patuxent Woods Drive,Patuxent Woods Drive | depart,continue,arrive | + | a,c | Broken Land Parkway,Patuxent Woods Drive,Patuxent Woods Drive | depart,turn right,arrive | + | g,k | Patuxent Woods Drive,Broken Land Parkway,Broken Land Parkway | depart,turn right,arrive | + | l,j | Broken Land Parkway,Snowden River Parkway,Snowden River Parkway | depart,turn right,arrive | + | f,b | Snowden River Parkway,Broken Land Parkway,Broken Land Parkway | depart,turn right,arrive | + | a,j | Broken Land Parkway,Snowden River Parkway,Snowden River Parkway | depart,turn left,arrive | + | g,b | Patuxent Woods Drive,Broken Land Parkway,Broken Land Parkway | depart,turn left,arrive | + | l,c | Broken Land Parkway,Patuxent Woods Drive,Patuxent Woods Drive | depart,turn left,arrive | + | f,k | Snowden River Parkway,Broken Land Parkway,Broken Land Parkway | depart,turn left,arrive | + | a,b | Broken Land Parkway,Broken Land Parkway,Broken Land Parkway | depart,continue uturn,arrive | + | g,c | Patuxent Woods Drive,Patuxent Woods Drive,Patuxent Woods Drive | depart,continue uturn,arrive | + | l,k | Broken Land Parkway,Broken Land Parkway,Broken Land Parkway | depart,continue uturn,arrive | + | f,j | Snowden River Parkway,Snowden River Parkway,Snowden River Parkway | depart,continue uturn,arrive | From bc309ef6eeca2377ad1ca99a469d9930def9ad88 Mon Sep 17 00:00:00 2001 From: Duane Gearhart Date: Thu, 1 Feb 2018 11:15:21 -0500 Subject: [PATCH 03/16] removed debug info --- ...segregated_intersection_classification.cpp | 34 ++----------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index 6fc8c79d1f4..124a8d6a9b0 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -89,7 +89,6 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa auto isSegregated = [&](NodeID node1, std::vector v1, - NodeID node2, std::vector v2, EdgeInfo const ¤t, double edgeLength) { @@ -100,7 +99,6 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa } // Print information about angles at node 1 from all inbound edge to the current edge - std::cout << "\nINBOUND to NODE_1 | Angles at node " << node1 << "\n"; bool oneway_inbound = false; for (auto const &edge_from : v1) { // Get the inbound edge and edge data @@ -119,17 +117,11 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa // Get the turn degree from the inbound edge to the current edge auto const turn_degree = get_angle(edge_from.node, edge_inbound, current.edge); // Skip if the inbound edge is not somewhat perpendicular to the current edge + // TODO add turn degree lamda if (turn_degree > 150 && turn_degree < 210) { continue; } - // TODO rm - std::cout << "Angle for (" << edge_from.node << ", " - << edge_inbound << " " << (is_bidirectional(edge_inbound_data.flags) ? "bidirectional" : "oneway") << " " - << " -> " - << current.edge << " " << (is_bidirectional(current.flags) ? "bidirectional" : "oneway") << ") " - << get_angle(edge_from.node, edge_inbound, current.edge) << "\n"; - // If we are here the edge is a candidate oneway inbound oneway_inbound = true; break; @@ -142,7 +134,6 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa } // Print information about angles at node 2 from the current edge to all outbound edges - std::cout << "OUTBOUND at NODE_2 | Angles at node " << node2 << "\n"; bool oneway_outbound = false; for (auto const &edge_to : v2) { @@ -160,17 +151,11 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa // Get the turn degree from the current edge to the outbound edge auto const turn_degree = get_angle(node1, current.edge, edge_to.edge); // Skip if the outbound edge is not somewhat perpendicular to the current edge + // TODO add turn degree lamda if (turn_degree > 150 && turn_degree < 210) { continue; } - // TODO rm - std::cout << "Angle for (" << node1 << ", " - << current.edge << " " << (is_bidirectional(current.flags) ? "bidirectional" : "oneway") << " " - << " -> " - << edge_to.edge << " " << (is_bidirectional(edge_to.flags) ? "bidirectional" : "oneway") << ") " - << get_angle(node1, current.edge, edge_to.edge) << "\n"; - // If we are here the edge is a candidate oneway outbound oneway_outbound = true; break; @@ -244,7 +229,6 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa double edgeLength) { return isSegregated(node1, collect_edge_info_fn(edges1, node2), - node2, collect_edge_info_fn(edges2, node1), get_edge_info(edgeID, node1, edgeData), edgeLength); @@ -259,20 +243,6 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa { auto const &edgeData = graph.GetEdgeData(edgeID); - // { - - // auto rev_edge = graph.FindEdge(graph.GetTarget(edgeID), sourceID); - // auto const &rev_edgeData = graph.GetEdgeData(rev_edge); - // bool bidirectional = !edgeData.reversed && !rev_edgeData.reversed; - - // std::cout << "sourceID = " << sourceID << " edgeID " << edgeID << " targetID " << - // graph.GetTarget(edgeID) << " reversed flag " << edgeData.reversed << " " << - // (bidirectional ? "bidirectional" : "oneway edge") << " forward " << - // (int)edgeData.flags.forward << " backward " << (int)edgeData.flags.backward << " - // is_split " << (int)edgeData.flags.is_split << "\n"; - - // } - if (edgeData.reversed) continue; From eae966058598ca76abc3803ed40b4a75e1e24fae Mon Sep 17 00:00:00 2001 From: kdiluca Date: Mon, 5 Feb 2018 16:20:58 -0500 Subject: [PATCH 04/16] updates per PR 4845 --- .../guidance/internal-intersections.feature | 34 ++--- ...segregated_intersection_classification.cpp | 117 ++++++++---------- test/nodejs/constants.js | 2 +- 3 files changed, 73 insertions(+), 80 deletions(-) diff --git a/features/guidance/internal-intersections.feature b/features/guidance/internal-intersections.feature index d482e56f0f5..887e11c50bf 100644 --- a/features/guidance/internal-intersections.feature +++ b/features/guidance/internal-intersections.feature @@ -27,20 +27,20 @@ Feature: Internal Intersection Model | hij | yes | Snowden River Parkway | When I route I should get - | waypoints | route | turns | - | a,k | Broken Land Parkway,Broken Land Parkway | depart,arrive | - | l,b | Broken Land Parkway,Broken Land Parkway | depart,arrive | -# | g,j | Patuxent Woods Drive,Snowden River Parkway,Snowden River Parkway | depart,continue,arrive | -# | f,c | Snowden River Parkway,Patuxent Woods Drive,Patuxent Woods Drive | depart,continue,arrive | - | a,c | Broken Land Parkway,Patuxent Woods Drive,Patuxent Woods Drive | depart,turn right,arrive | - | g,k | Patuxent Woods Drive,Broken Land Parkway,Broken Land Parkway | depart,turn right,arrive | - | l,j | Broken Land Parkway,Snowden River Parkway,Snowden River Parkway | depart,turn right,arrive | - | f,b | Snowden River Parkway,Broken Land Parkway,Broken Land Parkway | depart,turn right,arrive | - | a,j | Broken Land Parkway,Snowden River Parkway,Snowden River Parkway | depart,turn left,arrive | - | g,b | Patuxent Woods Drive,Broken Land Parkway,Broken Land Parkway | depart,turn left,arrive | - | l,c | Broken Land Parkway,Patuxent Woods Drive,Patuxent Woods Drive | depart,turn left,arrive | - | f,k | Snowden River Parkway,Broken Land Parkway,Broken Land Parkway | depart,turn left,arrive | - | a,b | Broken Land Parkway,Broken Land Parkway,Broken Land Parkway | depart,continue uturn,arrive | - | g,c | Patuxent Woods Drive,Patuxent Woods Drive,Patuxent Woods Drive | depart,continue uturn,arrive | - | l,k | Broken Land Parkway,Broken Land Parkway,Broken Land Parkway | depart,continue uturn,arrive | - | f,j | Snowden River Parkway,Snowden River Parkway,Snowden River Parkway | depart,continue uturn,arrive | + | waypoints | route | turns | # | + | a,k | Broken Land Parkway,Broken Land Parkway | depart,arrive || + | l,b | Broken Land Parkway,Broken Land Parkway | depart,arrive || +# | g,j | Patuxent Woods Drive,Snowden River Parkway,Snowden River Parkway | depart,continue,arrive | did not work as expected - might be another issue to handle in post process? | +# | f,c | Snowden River Parkway,Patuxent Woods Drive,Patuxent Woods Drive | depart,continue,arrive | did not work as expected - might be another issue to handle in post process? | + | a,c | Broken Land Parkway,Patuxent Woods Drive,Patuxent Woods Drive | depart,turn right,arrive || + | g,k | Patuxent Woods Drive,Broken Land Parkway,Broken Land Parkway | depart,turn right,arrive || + | l,j | Broken Land Parkway,Snowden River Parkway,Snowden River Parkway | depart,turn right,arrive || + | f,b | Snowden River Parkway,Broken Land Parkway,Broken Land Parkway | depart,turn right,arrive || + | a,j | Broken Land Parkway,Snowden River Parkway,Snowden River Parkway | depart,turn left,arrive || + | g,b | Patuxent Woods Drive,Broken Land Parkway,Broken Land Parkway | depart,turn left,arrive || + | l,c | Broken Land Parkway,Patuxent Woods Drive,Patuxent Woods Drive | depart,turn left,arrive || + | f,k | Snowden River Parkway,Broken Land Parkway,Broken Land Parkway | depart,turn left,arrive || + | a,b | Broken Land Parkway,Broken Land Parkway,Broken Land Parkway | depart,continue uturn,arrive || + | g,c | Patuxent Woods Drive,Patuxent Woods Drive,Patuxent Woods Drive | depart,continue uturn,arrive || + | l,k | Broken Land Parkway,Broken Land Parkway,Broken Land Parkway | depart,continue uturn,arrive || + | f,j | Snowden River Parkway,Snowden River Parkway,Snowden River Parkway | depart,continue uturn,arrive || diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index 124a8d6a9b0..aa7892a0728 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -10,7 +10,8 @@ namespace osrm namespace guidance { -namespace RoadPriorityClass = extractor::RoadPriorityClass; +// Maximum length in meters of an internal intersection edge +constexpr float kMaxInternalLength = 32.0f; struct EdgeInfo { @@ -22,12 +23,9 @@ struct EdgeInfo bool reversed; - // 0 - outgoing (forward), 1 - incoming (reverse), 2 - both outgoing and incoming - int direction; - extractor::ClassData road_class; - NodeBasedEdgeClassification flags; + extractor::NodeBasedEdgeClassification flags; struct LessName { @@ -38,16 +36,16 @@ struct EdgeInfo std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFactory &factory, const util::NameTable &names) { - auto const &graph = factory.GetGraph(); auto const &annotation = factory.GetAnnotationData(); auto const &coordinates = factory.GetCoordinates(); extractor::intersection::CoordinateExtractor coordExtractor( - graph, factory.GetCompressedEdges(), factory.GetCoordinates()); + graph, factory.GetCompressedEdges(), coordinates); - auto const get_edge_length = [&](NodeID from_node, EdgeID edgeID, NodeID to_node) { - auto const geom = coordExtractor.GetCoordinatesAlongRoad(from_node, edgeID, false, to_node); + auto const get_edge_length = [&](NodeID from_node, EdgeID edge_id, NodeID to_node) { + auto const geom = + coordExtractor.GetCoordinatesAlongRoad(from_node, edge_id, false, to_node); double length = 0.0; for (size_t i = 1; i < geom.size(); ++i) { @@ -69,48 +67,53 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa node_from, coordinates[intersection_node], node_to); }; - auto const get_edge_info = [&](EdgeID edge_id, NodeID node, auto const &edgeData) -> EdgeInfo { + auto const get_edge_info = [&](EdgeID edge_id, NodeID node, auto const &edge_data) -> EdgeInfo { /// @todo Make string normalization/lowercase/trim for comparison ... - auto const id = annotation[edgeData.annotation_data].name_id; + auto const id = annotation[edge_data.annotation_data].name_id; BOOST_ASSERT(id != INVALID_NAMEID); auto const name = names.GetNameForID(id); return {edge_id, node, name, - edgeData.reversed, - edgeData.reversed ? 1 : 0, - annotation[edgeData.annotation_data].classes, - edgeData.flags}; + edge_data.reversed, + annotation[edge_data.annotation_data].classes, + edge_data.flags}; }; - auto is_bidirectional = [](auto flags) { return flags.is_split || (!flags.is_split && flags.forward && flags.backward); }; + auto is_bidirectional = [](auto flags) { + return flags.is_split || (!flags.is_split && flags.forward && flags.backward); + }; auto isSegregated = [&](NodeID node1, std::vector v1, std::vector v2, EdgeInfo const ¤t, - double edgeLength) { + double edge_length) { // Internal intersection edges must be short and cannot be a roundabout // TODO adjust length as needed with lamda - if (edgeLength > 32.0f || current.flags.roundabout) { + if (edge_length > kMaxInternalLength || current.flags.roundabout) + { return false; } - // Print information about angles at node 1 from all inbound edge to the current edge bool oneway_inbound = false; - for (auto const &edge_from : v1) { + for (auto const &edge_from : v1) + { // Get the inbound edge and edge data auto edge_inbound = graph.FindEdge(edge_from.node, node1); auto const &edge_inbound_data = graph.GetEdgeData(edge_inbound); - if (!edge_inbound_data.reversed) { + if (!edge_inbound_data.reversed) + { // Skip any inbound edges not oneway (i.e. skip bidirectional) // and link edge // and not a road - if (is_bidirectional(edge_inbound_data.flags) - || edge_inbound_data.flags.road_classification.IsLinkClass() - || (edge_inbound_data.flags.road_classification.GetClass() > RoadPriorityClass::SIDE_RESIDENTIAL)) { + if (is_bidirectional(edge_inbound_data.flags) || + edge_inbound_data.flags.road_classification.IsLinkClass() || + (edge_inbound_data.flags.road_classification.GetClass() > + extractor::RoadPriorityClass::SIDE_RESIDENTIAL)) + { continue; } @@ -118,7 +121,8 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa auto const turn_degree = get_angle(edge_from.node, edge_inbound, current.edge); // Skip if the inbound edge is not somewhat perpendicular to the current edge // TODO add turn degree lamda - if (turn_degree > 150 && turn_degree < 210) { + if (turn_degree > 150 && turn_degree < 210) + { continue; } @@ -129,11 +133,11 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa } // Return false if no valid oneway inbound edge - if (!oneway_inbound) { + if (!oneway_inbound) + { return false; } - // Print information about angles at node 2 from the current edge to all outbound edges bool oneway_outbound = false; for (auto const &edge_to : v2) { @@ -142,9 +146,11 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa // Skip any outbound edges not oneway (i.e. skip bidirectional) // and link edge // and not a road - if (is_bidirectional(edge_to.flags) - || edge_to.flags.road_classification.IsLinkClass() - || (edge_to.flags.road_classification.GetClass() > RoadPriorityClass::SIDE_RESIDENTIAL)) { + if (is_bidirectional(edge_to.flags) || + edge_to.flags.road_classification.IsLinkClass() || + (edge_to.flags.road_classification.GetClass() > + extractor::RoadPriorityClass::SIDE_RESIDENTIAL)) + { continue; } @@ -152,7 +158,8 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa auto const turn_degree = get_angle(node1, current.edge, edge_to.edge); // Skip if the outbound edge is not somewhat perpendicular to the current edge // TODO add turn degree lamda - if (turn_degree > 150 && turn_degree < 210) { + if (turn_degree > 150 && turn_degree < 210) + { continue; } @@ -163,7 +170,8 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa } // Return false if no valid oneway outbound edge - if (!oneway_outbound) { + if (!oneway_outbound) + { return false; } @@ -195,22 +203,6 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa return e1.node < e2.node; }); - // Merge equal infos with correct direction. - auto curr = info.begin(); - auto next = curr; - while (++next != info.end()) - { - if (curr->node == next->node) - { - BOOST_ASSERT(curr->name == next->name); - BOOST_ASSERT(curr->road_class == next->road_class); - BOOST_ASSERT(curr->direction != next->direction); - curr->direction = 2; - } - else - curr = next; - } - info.erase( std::unique(info.begin(), info.end(), @@ -220,38 +212,39 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa return info; }; - auto const isSegregatedFn = [&](EdgeID edgeID, - auto const &edgeData, + auto const isSegregatedFn = [&](EdgeID edge_id, + auto const &edge_data, auto const &edges1, NodeID node1, auto const &edges2, NodeID node2, - double edgeLength) { + double edge_length) { return isSegregated(node1, collect_edge_info_fn(edges1, node2), collect_edge_info_fn(edges2, node1), - get_edge_info(edgeID, node1, edgeData), - edgeLength); + get_edge_info(edge_id, node1, edge_data), + edge_length); }; std::unordered_set segregated_edges; - for (NodeID sourceID = 0; sourceID < graph.GetNumberOfNodes(); ++sourceID) + for (NodeID source_id = 0; source_id < graph.GetNumberOfNodes(); ++source_id) { - auto const sourceEdges = graph.GetAdjacentEdgeRange(sourceID); - for (EdgeID edgeID : sourceEdges) + auto const source_edges = graph.GetAdjacentEdgeRange(source_id); + for (EdgeID edge_id : source_edges) { - auto const &edgeData = graph.GetEdgeData(edgeID); + auto const &edgeData = graph.GetEdgeData(edge_id); if (edgeData.reversed) continue; - NodeID const targetID = graph.GetTarget(edgeID); - auto const targetEdges = graph.GetAdjacentEdgeRange(targetID); + NodeID const target_id = graph.GetTarget(edge_id); + auto const targetEdges = graph.GetAdjacentEdgeRange(target_id); - double const length = get_edge_length(sourceID, edgeID, targetID); - if (isSegregatedFn(edgeID, edgeData, sourceEdges, sourceID, targetEdges, targetID, length)) - segregated_edges.insert(edgeID); + double const length = get_edge_length(source_id, edge_id, target_id); + if (isSegregatedFn( + edge_id, edgeData, source_edges, source_id, targetEdges, target_id, length)) + segregated_edges.insert(edge_id); } } diff --git a/test/nodejs/constants.js b/test/nodejs/constants.js index 370b7f6d3cc..1f22ac08315 100644 --- a/test/nodejs/constants.js +++ b/test/nodejs/constants.js @@ -10,7 +10,7 @@ exports.three_test_coordinates = [[7.41337, 43.72956], exports.two_test_coordinates = exports.three_test_coordinates.slice(0, 2) -exports.test_tile = {'at': [17059, 11948, 15], 'size': 169387}; +exports.test_tile = {'at': [17059, 11948, 15], 'size': 168975}; // Test files generated by the routing engine; check test/data if (process.env.OSRM_DATA_PATH !== undefined) { From d833e9d6ca35d33050db10359d4e5c2882dd26fb Mon Sep 17 00:00:00 2001 From: kdiluca Date: Tue, 6 Feb 2018 08:06:09 -0500 Subject: [PATCH 05/16] fixing build errors --- ...segregated_intersection_classification.hpp | 1 + ...segregated_intersection_classification.cpp | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/guidance/segregated_intersection_classification.hpp b/include/guidance/segregated_intersection_classification.hpp index 25d39d929f9..3424a49625c 100644 --- a/include/guidance/segregated_intersection_classification.hpp +++ b/include/guidance/segregated_intersection_classification.hpp @@ -12,6 +12,7 @@ class NameTable; namespace extractor { class NodeBasedGraphFactory; + } namespace guidance diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index aa7892a0728..3f4a52dacf6 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -23,6 +23,9 @@ struct EdgeInfo bool reversed; + // 0 - outgoing (forward), 1 - incoming (reverse), 2 - both outgoing and incoming + int direction; + extractor::ClassData road_class; extractor::NodeBasedEdgeClassification flags; @@ -33,7 +36,8 @@ struct EdgeInfo }; }; -std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFactory &factory, +std::unordered_set +osrm::extractor::guidance::findSegregatedNodes(const NodeBasedGraphFactory &factory, const util::NameTable &names) { auto const &graph = factory.GetGraph(); @@ -203,6 +207,22 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa return e1.node < e2.node; }); + // Merge equal infos with correct direction. + auto curr = info.begin(); + auto next = curr; + while (++next != info.end()) + { + if (curr->node == next->node) + { + BOOST_ASSERT(curr->name == next->name); + BOOST_ASSERT(curr->road_class == next->road_class); + BOOST_ASSERT(curr->direction != next->direction); + curr->direction = 2; + } + else + curr = next; + } + info.erase( std::unique(info.begin(), info.end(), From 2028b3ebcc69feffb158511da9709b8368a197ac Mon Sep 17 00:00:00 2001 From: kdiluca Date: Tue, 6 Feb 2018 08:58:03 -0500 Subject: [PATCH 06/16] fixing all compile errors --- ...segregated_intersection_classification.hpp | 1 - ...segregated_intersection_classification.cpp | 22 +------------------ 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/include/guidance/segregated_intersection_classification.hpp b/include/guidance/segregated_intersection_classification.hpp index 3424a49625c..25d39d929f9 100644 --- a/include/guidance/segregated_intersection_classification.hpp +++ b/include/guidance/segregated_intersection_classification.hpp @@ -12,7 +12,6 @@ class NameTable; namespace extractor { class NodeBasedGraphFactory; - } namespace guidance diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index 3f4a52dacf6..aa7892a0728 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -23,9 +23,6 @@ struct EdgeInfo bool reversed; - // 0 - outgoing (forward), 1 - incoming (reverse), 2 - both outgoing and incoming - int direction; - extractor::ClassData road_class; extractor::NodeBasedEdgeClassification flags; @@ -36,8 +33,7 @@ struct EdgeInfo }; }; -std::unordered_set -osrm::extractor::guidance::findSegregatedNodes(const NodeBasedGraphFactory &factory, +std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFactory &factory, const util::NameTable &names) { auto const &graph = factory.GetGraph(); @@ -207,22 +203,6 @@ osrm::extractor::guidance::findSegregatedNodes(const NodeBasedGraphFactory &fact return e1.node < e2.node; }); - // Merge equal infos with correct direction. - auto curr = info.begin(); - auto next = curr; - while (++next != info.end()) - { - if (curr->node == next->node) - { - BOOST_ASSERT(curr->name == next->name); - BOOST_ASSERT(curr->road_class == next->road_class); - BOOST_ASSERT(curr->direction != next->direction); - curr->direction = 2; - } - else - curr = next; - } - info.erase( std::unique(info.begin(), info.end(), From 1fac1dc0b6be879442a1ffbff7049386522e83ab Mon Sep 17 00:00:00 2001 From: Duane Gearhart Date: Tue, 6 Feb 2018 10:13:43 -0500 Subject: [PATCH 07/16] fixed EdgeID param --- src/guidance/segregated_intersection_classification.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index aa7892a0728..b240045dffd 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -55,7 +55,7 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa }; // Returns an angle between edges from from_edge_id to to_edge_id - auto const get_angle = [&](NodeID from_node, EdgeID from_edge_id, NodeID to_edge_id) { + auto const get_angle = [&](NodeID from_node, EdgeID from_edge_id, EdgeID to_edge_id) { auto intersection_node = graph.GetTarget(from_edge_id); auto from_edge_id_outgoing = graph.FindEdge(intersection_node, from_node); auto to_node = graph.GetTarget(to_edge_id); From 8a2fae5063f0c28fc23b2a7b6cff9c171dd6da78 Mon Sep 17 00:00:00 2001 From: Duane Gearhart Date: Tue, 6 Feb 2018 11:04:47 -0500 Subject: [PATCH 08/16] Added is_internal_straight lambda Added/Updated constexpr names and values --- ...segregated_intersection_classification.cpp | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index b240045dffd..1a8c9db0025 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -11,7 +11,11 @@ namespace guidance { // Maximum length in meters of an internal intersection edge -constexpr float kMaxInternalLength = 32.0f; +constexpr auto INTERNAL_LENGTH_MAX = 32.0f; + +// The lower and upper bound internal straight values +constexpr auto INTERNAL_STRAIGHT_LOWER_BOUND = 150.0; +constexpr auto INTERNAL_STRAIGHT_UPPER_BOUND = 210.0; struct EdgeInfo { @@ -86,6 +90,11 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa return flags.is_split || (!flags.is_split && flags.forward && flags.backward); }; + auto is_internal_straight = [](auto const turn_degree) { + return (turn_degree > INTERNAL_STRAIGHT_LOWER_BOUND && + turn_degree < INTERNAL_STRAIGHT_UPPER_BOUND); + }; + auto isSegregated = [&](NodeID node1, std::vector v1, std::vector v2, @@ -93,11 +102,12 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa double edge_length) { // Internal intersection edges must be short and cannot be a roundabout // TODO adjust length as needed with lamda - if (edge_length > kMaxInternalLength || current.flags.roundabout) + if (edge_length > INTERNAL_LENGTH_MAX || current.flags.roundabout) { return false; } + // Look for oneway inbound edge bool oneway_inbound = false; for (auto const &edge_from : v1) { @@ -118,10 +128,8 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa } // Get the turn degree from the inbound edge to the current edge - auto const turn_degree = get_angle(edge_from.node, edge_inbound, current.edge); // Skip if the inbound edge is not somewhat perpendicular to the current edge - // TODO add turn degree lamda - if (turn_degree > 150 && turn_degree < 210) + if (is_internal_straight(get_angle(edge_from.node, edge_inbound, current.edge))) { continue; } @@ -138,6 +146,7 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa return false; } + // Look for oneway outbound edge bool oneway_outbound = false; for (auto const &edge_to : v2) { @@ -155,10 +164,8 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa } // Get the turn degree from the current edge to the outbound edge - auto const turn_degree = get_angle(node1, current.edge, edge_to.edge); // Skip if the outbound edge is not somewhat perpendicular to the current edge - // TODO add turn degree lamda - if (turn_degree > 150 && turn_degree < 210) + if (is_internal_straight(get_angle(node1, current.edge, edge_to.edge))) { continue; } @@ -175,11 +182,6 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa return false; } - // TODO - determine if we need to add name checks - - // TODO - do we need to check headings of the inbound and outbound - // oneway edges - // Assume this is an intersection internal edge return true; }; From 641628e2ebfbdc7e50fbfd3511395e23b92f00ef Mon Sep 17 00:00:00 2001 From: kdiluca Date: Thu, 22 Feb 2018 09:19:38 -0500 Subject: [PATCH 09/16] added rejection case turn degree logic --- ...segregated_intersection_classification.cpp | 57 ++++++++++++++++--- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index 1a8c9db0025..6e5c026b3fb 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -1,10 +1,13 @@ #include "guidance/segregated_intersection_classification.hpp" #include "extractor/intersection/coordinate_extractor.hpp" #include "extractor/node_based_graph_factory.hpp" +#include "guidance/turn_instruction.hpp" #include "util/coordinate_calculation.hpp" #include "util/name_table.hpp" +using osrm::guidance::getTurnDirection; + namespace osrm { namespace guidance @@ -95,20 +98,35 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa turn_degree < INTERNAL_STRAIGHT_UPPER_BOUND); }; + // Lambda to check if the turn set includes a right turn type + const auto has_turn_right = [](std::set &turn_types) { + return turn_types.find(guidance::DirectionModifier::Right) != turn_types.end() || + turn_types.find(guidance::DirectionModifier::SharpRight) != turn_types.end(); + }; + // Lambda to check if the turn set includes a left turn type + const auto has_turn_left = [](std::set &turn_types) { + return turn_types.find(guidance::DirectionModifier::Left) != turn_types.end() || + turn_types.find(guidance::DirectionModifier::SharpLeft) != turn_types.end(); + }; + auto isSegregated = [&](NodeID node1, std::vector v1, std::vector v2, EdgeInfo const ¤t, double edge_length) { - // Internal intersection edges must be short and cannot be a roundabout + // Internal intersection edges must be short and cannot be a roundabout. + // Also they must be a road use (not footway, cycleway, etc.) + // TODO - consider whether alleys, cul-de-sacs, and other road uses + // are candidates to be marked as internal intersection edges. // TODO adjust length as needed with lamda if (edge_length > INTERNAL_LENGTH_MAX || current.flags.roundabout) { return false; } - - // Look for oneway inbound edge + // Iterate through inbound edges and get turn degrees from driveable inbound + // edges onto the candidate edge. bool oneway_inbound = false; + std::set incoming_turn_type; for (auto const &edge_from : v1) { // Get the inbound edge and edge data @@ -116,6 +134,10 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa auto const &edge_inbound_data = graph.GetEdgeData(edge_inbound); if (!edge_inbound_data.reversed) { + // Store the turn type of incoming driveable edges. + incoming_turn_type.insert(guidance::getTurnDirection( + get_angle(edge_from.node, edge_inbound, current.edge))); + // Skip any inbound edges not oneway (i.e. skip bidirectional) // and link edge // and not a road @@ -126,32 +148,37 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa { continue; } - // Get the turn degree from the inbound edge to the current edge // Skip if the inbound edge is not somewhat perpendicular to the current edge if (is_internal_straight(get_angle(edge_from.node, edge_inbound, current.edge))) { continue; } - // If we are here the edge is a candidate oneway inbound oneway_inbound = true; break; } } - // Return false if no valid oneway inbound edge + // Must have an inbound oneway, excluding edges that are nearly straight + // turn type onto the directed edge. if (!oneway_inbound) { return false; } - // Look for oneway outbound edge + // Iterate through outbound edges and get turn degrees from the candidate + // edge onto outbound driveable edges. bool oneway_outbound = false; + std::set outgoing_turn_type; for (auto const &edge_to : v2) { if (!edge_to.reversed) { + // Store outgoing turn type for any driveable edges + outgoing_turn_type.insert( + guidance::getTurnDirection(get_angle(node1, current.edge, edge_to.edge))); + // Skip any outbound edges not oneway (i.e. skip bidirectional) // and link edge // and not a road @@ -175,13 +202,25 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa break; } } - - // Return false if no valid oneway outbound edge + // Must have outbound oneway at end node (exclude edges that are nearly + // straight turn from directed edge if (!oneway_outbound) { return false; } + // A further rejection case is if there are incoming edges that + // have "opposite" turn degrees than outgoing edges or if the outgoing + // edges have opposing turn degrees. + if ((has_turn_left(incoming_turn_type) && has_turn_right(outgoing_turn_type)) || + (has_turn_right(incoming_turn_type) && has_turn_left(outgoing_turn_type)) || + (has_turn_left(outgoing_turn_type) && has_turn_right(outgoing_turn_type))) { + return false; + } + + // TODO - determine if we need to add name checks or need to check headings + // of the inbound and outbound oneway edges + // Assume this is an intersection internal edge return true; }; From 1faa918e2c26149ac8d310a68bb5943422de6f81 Mon Sep 17 00:00:00 2001 From: kdiluca Date: Thu, 22 Feb 2018 16:38:52 -0500 Subject: [PATCH 10/16] debug logging --- src/guidance/segregated_intersection_classification.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index 6e5c026b3fb..5d5a5b90ecf 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -70,6 +70,13 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa coordExtractor.GetCoordinateCloseToTurn(intersection_node, to_edge_id, false, to_node); auto const node_from = coordExtractor.GetCoordinateCloseToTurn( intersection_node, from_edge_id_outgoing, false, from_node); + + util::Log() << "from edge id :: " << from_edge_id << ", to edge id :: " << to_edge_id; + util::Log() << "intersection node :: " << intersection_node; + util::Log() << "coords of intersection node :: " << coordinates[intersection_node].lat << ", " << coordinates[intersection_node].lon; + util::Log() << "turn angle :: " << util::coordinate_calculation::computeAngle( + node_from, coordinates[intersection_node], node_to) ; + return util::coordinate_calculation::computeAngle( node_from, coordinates[intersection_node], node_to); }; @@ -81,6 +88,7 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa BOOST_ASSERT(id != INVALID_NAMEID); auto const name = names.GetNameForID(id); + util::Log() << "node :: " << node << ", edge_id :: " << edge_id << ", name :: " << name; return {edge_id, node, name, From 47ef208891ec1ef191dabfc3fbf8c863e908815d Mon Sep 17 00:00:00 2001 From: kdiluca Date: Fri, 23 Feb 2018 10:28:23 -0500 Subject: [PATCH 11/16] added turn angle logic to reject if there are incoming edges that have opposite turn degrees than outgoing edges or if the outgoing edges have opposing turn degrees; also merged with master v5.16 --- src/guidance/segregated_intersection_classification.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index 5d5a5b90ecf..437c654930a 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -70,13 +70,6 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa coordExtractor.GetCoordinateCloseToTurn(intersection_node, to_edge_id, false, to_node); auto const node_from = coordExtractor.GetCoordinateCloseToTurn( intersection_node, from_edge_id_outgoing, false, from_node); - - util::Log() << "from edge id :: " << from_edge_id << ", to edge id :: " << to_edge_id; - util::Log() << "intersection node :: " << intersection_node; - util::Log() << "coords of intersection node :: " << coordinates[intersection_node].lat << ", " << coordinates[intersection_node].lon; - util::Log() << "turn angle :: " << util::coordinate_calculation::computeAngle( - node_from, coordinates[intersection_node], node_to) ; - return util::coordinate_calculation::computeAngle( node_from, coordinates[intersection_node], node_to); }; @@ -87,8 +80,6 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa auto const id = annotation[edge_data.annotation_data].name_id; BOOST_ASSERT(id != INVALID_NAMEID); auto const name = names.GetNameForID(id); - - util::Log() << "node :: " << node << ", edge_id :: " << edge_id << ", name :: " << name; return {edge_id, node, name, From 6de4f4c95bf3c882de3d73571b59711963873061 Mon Sep 17 00:00:00 2001 From: kdiluca Date: Fri, 23 Feb 2018 10:31:25 -0500 Subject: [PATCH 12/16] fixed formatting --- src/guidance/segregated_intersection_classification.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index 437c654930a..f06259f52b1 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -213,8 +213,9 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa // edges have opposing turn degrees. if ((has_turn_left(incoming_turn_type) && has_turn_right(outgoing_turn_type)) || (has_turn_right(incoming_turn_type) && has_turn_left(outgoing_turn_type)) || - (has_turn_left(outgoing_turn_type) && has_turn_right(outgoing_turn_type))) { - return false; + (has_turn_left(outgoing_turn_type) && has_turn_right(outgoing_turn_type))) + { + return false; } // TODO - determine if we need to add name checks or need to check headings From 921702a2a5f2530dc7f5086ae0ab5b7b8ac7b08a Mon Sep 17 00:00:00 2001 From: kdiluca Date: Fri, 23 Feb 2018 13:22:55 -0500 Subject: [PATCH 13/16] fix to decrease tile size based on latest turn angle internal intersection updates --- test/nodejs/constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/nodejs/constants.js b/test/nodejs/constants.js index 1f22ac08315..b14bd367417 100644 --- a/test/nodejs/constants.js +++ b/test/nodejs/constants.js @@ -10,7 +10,7 @@ exports.three_test_coordinates = [[7.41337, 43.72956], exports.two_test_coordinates = exports.three_test_coordinates.slice(0, 2) -exports.test_tile = {'at': [17059, 11948, 15], 'size': 168975}; +exports.test_tile = {'at': [17059, 11948, 15], 'size': 168612}; // Test files generated by the routing engine; check test/data if (process.env.OSRM_DATA_PATH !== undefined) { From 298bf1f9b8cbab9ef9444f81a4ec9ba5cca84bda Mon Sep 17 00:00:00 2001 From: kdiluca Date: Fri, 23 Feb 2018 15:40:28 -0500 Subject: [PATCH 14/16] Removed breaks Breaks in code were a mistake and caused a change in the internal intersection identification. --- src/guidance/segregated_intersection_classification.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index f06259f52b1..d93301463cd 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -155,7 +155,6 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa } // If we are here the edge is a candidate oneway inbound oneway_inbound = true; - break; } } @@ -198,7 +197,6 @@ std::unordered_set findSegregatedNodes(const extractor::NodeBasedGraphFa // If we are here the edge is a candidate oneway outbound oneway_outbound = true; - break; } } // Must have outbound oneway at end node (exclude edges that are nearly From 4ef649a1b91d30eeb9d341f70bb4bc09c906745e Mon Sep 17 00:00:00 2001 From: kdiluca Date: Fri, 23 Feb 2018 16:27:18 -0500 Subject: [PATCH 15/16] Update segregated_intersection_classification.cpp --- src/guidance/segregated_intersection_classification.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/guidance/segregated_intersection_classification.cpp b/src/guidance/segregated_intersection_classification.cpp index d93301463cd..50df992884c 100644 --- a/src/guidance/segregated_intersection_classification.cpp +++ b/src/guidance/segregated_intersection_classification.cpp @@ -5,6 +5,7 @@ #include "util/coordinate_calculation.hpp" #include "util/name_table.hpp" +#include using osrm::guidance::getTurnDirection; From 3175d1b4010c2484ea47390be80f89a7b04f5a13 Mon Sep 17 00:00:00 2001 From: kdiluca Date: Tue, 27 Feb 2018 14:39:19 -0500 Subject: [PATCH 16/16] Update CHANGELOG.md Added CHANGED #4845: Updated segregated intersection identification to Unreleased --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b05d0f34d57..dd255e6f00e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ - `osrm-routed` accepts a new property `--memory_file` to store memory in a file on disk. - NodeJS: - `OSRM` object accepts a new option `memory_file` that stores the memory in a file on disk. + - Internals + - CHANGED #4845: Updated segregated intersection identification # 5.16.0