From 0fc8b6289c8293788e6b2441e540d5d5b3df2b0b Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Fri, 16 Feb 2018 09:39:38 +0100 Subject: [PATCH] Merge IntersectionShapeData and IntersectionEdgeGeometry --- CHANGELOG.md | 5 ++ .../intersection/intersection_edge.hpp | 11 +++- .../intersection/intersection_view.hpp | 63 ++++++++----------- .../intersection/mergable_road_detector.hpp | 2 +- include/guidance/intersection.hpp | 2 +- include/guidance/intersection_handler.hpp | 2 +- include/util/debug.hpp | 9 +-- src/extractor/intersection/intersection.cpp | 8 +-- .../intersection/intersection_analysis.cpp | 45 ++++++------- .../intersection/mergable_road_detector.cpp | 16 ++--- .../intersection/node_based_graph_walker.cpp | 2 +- src/guidance/guidance_processing.cpp | 22 ++++--- src/guidance/sliproad_handler.cpp | 3 +- src/guidance/turn_classification.cpp | 19 +++--- 14 files changed, 103 insertions(+), 106 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aea2568d0..15eb6c0d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ - Bugfixes: - fix deduplication of route steps when waypoints are used [#4909](https://github.com/Project-OSRM/osrm-backend/issues/4909) - FIXED #4920: Use smaller range for U-turn angles in map-matching [#4920](https://github.com/Project-OSRM/osrm-backend/pull/4920) + - Profile: + - CHANGED #4929: Handle oneways in get_forward_backward_by_key [#4929](https://github.com/Project-OSRM/osrm-backend/pull/4929) + - Guidance: + - CHANGED #4929: Don't use obviousness for links bifurcations [#4929](https://github.com/Project-OSRM/osrm-backend/pull/4929) + - FIXED #4929: Adjust Straight direction modifiers of side roads in driveway handler [#4929](https://github.com/Project-OSRM/osrm-backend/pull/4929) - Tools: - `osrm-routed` accepts a new property `--memory_file` to store memory in a file on disk. - NodeJS: diff --git a/include/extractor/intersection/intersection_edge.hpp b/include/extractor/intersection/intersection_edge.hpp index 55620607b..954184abe 100644 --- a/include/extractor/intersection/intersection_edge.hpp +++ b/include/extractor/intersection/intersection_edge.hpp @@ -26,14 +26,19 @@ struct IntersectionEdge using IntersectionEdges = std::vector; +// The extracted geometry of an intersection edge only knows about edge IDs and bearings +// Bearing is the direction in clockwise angle from true north after taking the turn: +// 0 = heading north, 90 = east, 180 = south, 270 = west +// `initial_bearing` is the original OSM edge bearing +// `perceived_bearing` is the edge bearing after line fitting and edges merging struct IntersectionEdgeGeometry { - EdgeID edge; + EdgeID eid; double initial_bearing; double perceived_bearing; - double length; + double segment_length; - bool operator<(const IntersectionEdgeGeometry &other) const { return edge < other.edge; } + bool operator<(const IntersectionEdgeGeometry &other) const { return eid < other.eid; } }; using IntersectionEdgeGeometries = std::vector; diff --git a/include/extractor/intersection/intersection_view.hpp b/include/extractor/intersection/intersection_view.hpp index 1ff3c4cdc..24996bca9 100644 --- a/include/extractor/intersection/intersection_view.hpp +++ b/include/extractor/intersection/intersection_view.hpp @@ -1,6 +1,19 @@ #ifndef OSRM_EXTRACTOR_INTERSECTION_INTERSECTION_VIEW_HPP_ #define OSRM_EXTRACTOR_INTERSECTION_INTERSECTION_VIEW_HPP_ +#include "extractor/intersection/intersection_edge.hpp" + +#include "guidance/turn_instruction.hpp" + +#include "util/bearing.hpp" +#include "util/log.hpp" +#include "util/node_based_graph.hpp" +#include "util/typedefs.hpp" // EdgeID + +#include +#include +#include + #include #include #include @@ -8,17 +21,6 @@ #include #include -#include "util/bearing.hpp" -#include "util/log.hpp" -#include "util/node_based_graph.hpp" -#include "util/typedefs.hpp" // EdgeID - -#include "guidance/turn_instruction.hpp" - -#include -#include -#include - namespace osrm { namespace extractor @@ -26,24 +28,6 @@ namespace extractor namespace intersection { -// the shape of an intersection only knows about edge IDs and bearings -// `bearing` is the direction in clockwise angle from true north after taking the turn: -// 0 = heading north, 90 = east, 180 = south, 270 = west -struct IntersectionShapeData -{ - EdgeID eid; - double bearing; - double segment_length; -}; - -inline auto makeCompareShapeDataByBearing(const double base_bearing) -{ - return [base_bearing](const auto &lhs, const auto &rhs) { - return util::angularDeviation(lhs.bearing, base_bearing) < - util::angularDeviation(rhs.bearing, base_bearing); - }; -} - inline auto makeCompareAngularDeviation(const double angle) { return [angle](const auto &lhs, const auto &rhs) { @@ -60,12 +44,12 @@ inline auto makeExtractLanesForRoad(const util::NodeBasedDynamicGraph &node_base // When viewing an intersection from an incoming edge, we can transform a shape into a view which // gives additional information on angles and whether a turn is allowed -struct IntersectionViewData : IntersectionShapeData +struct IntersectionViewData : IntersectionEdgeGeometry { - IntersectionViewData(const IntersectionShapeData &shape, + IntersectionViewData(const IntersectionEdgeGeometry &geometry, const bool entry_allowed, const double angle) - : IntersectionShapeData(shape), entry_allowed(entry_allowed), angle(angle) + : IntersectionEdgeGeometry(geometry), entry_allowed(entry_allowed), angle(angle) { } @@ -80,10 +64,13 @@ struct IntersectionViewData : IntersectionShapeData template struct EnableShapeOps { // same as closest turn, but for bearings - auto FindClosestBearing(double bearing) const + auto FindClosestBearing(double base_bearing) const { - auto comp = makeCompareShapeDataByBearing(bearing); - return std::min_element(self()->begin(), self()->end(), comp); + return std::min_element( + self()->begin(), self()->end(), [base_bearing](const auto &lhs, const auto &rhs) { + return util::angularDeviation(lhs.perceived_bearing, base_bearing) < + util::angularDeviation(rhs.perceived_bearing, base_bearing); + }); } // search a given eid in the intersection @@ -119,10 +106,10 @@ template struct EnableShapeOps auto self() const { return static_cast(this); } }; -struct IntersectionShape final : std::vector, // - EnableShapeOps // +struct IntersectionShape final : std::vector, // + EnableShapeOps // { - using Base = std::vector; + using Base = std::vector; }; // Common operations shared among IntersectionView and Intersections. diff --git a/include/extractor/intersection/mergable_road_detector.hpp b/include/extractor/intersection/mergable_road_detector.hpp index b53bf6358..b6a90df15 100644 --- a/include/extractor/intersection/mergable_road_detector.hpp +++ b/include/extractor/intersection/mergable_road_detector.hpp @@ -40,7 +40,7 @@ class MergableRoadDetector { public: // in case we have to change the mode we are operating on - using MergableRoadData = IntersectionShapeData; + using MergableRoadData = IntersectionEdgeGeometry; MergableRoadDetector(const util::NodeBasedDynamicGraph &node_based_graph, const EdgeBasedNodeDataContainer &node_data_container, diff --git a/include/guidance/intersection.hpp b/include/guidance/intersection.hpp index 76a3f6bfc..265febf3c 100644 --- a/include/guidance/intersection.hpp +++ b/include/guidance/intersection.hpp @@ -114,7 +114,7 @@ inline std::string toString(const ConnectedRoad &road) result += " angle: "; result += std::to_string(road.angle); result += " bearing: "; - result += std::to_string(road.bearing); + result += std::to_string(road.perceived_bearing); result += " instruction: "; result += std::to_string(static_cast(road.instruction.type)) + " " + std::to_string(static_cast(road.instruction.direction_modifier)) + " " + diff --git a/include/guidance/intersection_handler.hpp b/include/guidance/intersection_handler.hpp index e2fed7d31..8bb589791 100644 --- a/include/guidance/intersection_handler.hpp +++ b/include/guidance/intersection_handler.hpp @@ -348,7 +348,7 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge, const auto turns_onto_through_street = [&](const auto &road) { // find edge opposite to the one we are checking (in-road) const auto in_through_candidate = - intersection.FindClosestBearing(util::bearing::reverse(road.bearing)); + intersection.FindClosestBearing(util::bearing::reverse(road.perceived_bearing)); const auto &in_edge = node_based_graph.GetEdgeData(in_through_candidate->eid); const auto &out_edge = node_based_graph.GetEdgeData(road.eid); diff --git a/include/util/debug.hpp b/include/util/debug.hpp index 1dc9f9f0a..c1ed83442 100644 --- a/include/util/debug.hpp +++ b/include/util/debug.hpp @@ -68,7 +68,7 @@ namespace guidance inline std::ostream &operator<<(std::ostream &out, const ConnectedRoad &road) { out << "ConnectedRoad {" << road.eid << " allows entry: " << road.entry_allowed - << " angle: " << road.angle << " bearing: " << road.bearing + << " angle: " << road.angle << " bearing: " << road.perceived_bearing << " instruction: " << static_cast(road.instruction.type) << " " << static_cast(road.instruction.direction_modifier) << " " << static_cast(road.lane_data_id) << "}"; @@ -80,16 +80,17 @@ namespace extractor { namespace intersection { -inline std::ostream &operator<<(std::ostream &out, const IntersectionShapeData &shape) +inline std::ostream &operator<<(std::ostream &out, const IntersectionEdgeGeometry &shape) { - out << "IntersectionShapeData { " << shape.eid << " bearing: " << shape.bearing << "}"; + out << "IntersectionEdgeGeometry { " << shape.eid << " bearing: " << shape.perceived_bearing + << "}"; return out; } inline std::ostream &operator<<(std::ostream &out, const IntersectionViewData &view) { out << "IntersectionViewData {" << view.eid << " allows entry: " << view.entry_allowed - << " angle: " << view.angle << " bearing: " << view.bearing << "}"; + << " angle: " << view.angle << " bearing: " << view.perceived_bearing << "}"; return out; } } diff --git a/src/extractor/intersection/intersection.cpp b/src/extractor/intersection/intersection.cpp index 9bdc8d447..f7cc789fe 100644 --- a/src/extractor/intersection/intersection.cpp +++ b/src/extractor/intersection/intersection.cpp @@ -19,10 +19,10 @@ bool IntersectionViewData::CompareByAngle(const IntersectionViewData &other) con return angle < other.angle; } -std::string toString(const IntersectionShapeData &shape) +std::string toString(const IntersectionEdgeGeometry &shape) { - std::string result = - "[shape] " + std::to_string(shape.eid) + " bearing: " + std::to_string(shape.bearing); + std::string result = "[shape] " + std::to_string(shape.eid) + " bearing: " + + std::to_string(shape.perceived_bearing); return result; } @@ -35,7 +35,7 @@ std::string toString(const IntersectionViewData &view) result += " angle: "; result += std::to_string(view.angle); result += " bearing: "; - result += std::to_string(view.bearing); + result += std::to_string(view.perceived_bearing); return result; } diff --git a/src/extractor/intersection/intersection_analysis.cpp b/src/extractor/intersection/intersection_analysis.cpp index a8e769253..bf09b8f57 100644 --- a/src/extractor/intersection/intersection_analysis.cpp +++ b/src/extractor/intersection/intersection_analysis.cpp @@ -120,9 +120,9 @@ std::pair findMergedBearing(const util::NodeBasedDynamicGraph &gra const auto &lhs = edge_geometries[lhs_index]; const auto &rhs = edge_geometries[rhs_index]; - BOOST_ASSERT(graph.GetEdgeData(lhs.edge).reversed != graph.GetEdgeData(rhs.edge).reversed); + BOOST_ASSERT(graph.GetEdgeData(lhs.eid).reversed != graph.GetEdgeData(rhs.eid).reversed); - const auto &entry = graph.GetEdgeData(lhs.edge).reversed ? rhs : lhs; + const auto &entry = graph.GetEdgeData(lhs.eid).reversed ? rhs : lhs; const auto opposite_bearing = findClosestOppositeBearing(edge_geometries, entry.perceived_bearing); const auto merged_bearing = findAngleBisector(rhs.perceived_bearing, lhs.perceived_bearing); @@ -178,13 +178,8 @@ bool isRoadsPairMergeable(const MergableRoadDetector &detector, // TODO: check IsDistinctFrom - it is an angle and name-only check // also check CanMergeRoad for all merging scenarios - return detector.IsDistinctFrom({llhs.edge, llhs.perceived_bearing, llhs.length}, - {lhs.edge, lhs.perceived_bearing, lhs.length}) && - detector.CanMergeRoad(intersection_node, - {lhs.edge, lhs.perceived_bearing, lhs.length}, - {rhs.edge, rhs.perceived_bearing, rhs.length}) && - detector.IsDistinctFrom({rhs.edge, rhs.perceived_bearing, rhs.length}, - {rrhs.edge, rrhs.perceived_bearing, rrhs.length}); + return detector.IsDistinctFrom(llhs, lhs) && + detector.CanMergeRoad(intersection_node, lhs, rhs) && detector.IsDistinctFrom(rhs, rrhs); } auto getIntersectionLanes(const util::NodeBasedDynamicGraph &graph, const NodeID intersection_node) @@ -293,9 +288,9 @@ getIntersectionGeometries(const util::NodeBasedDynamicGraph &graph, // Only one of the edges must be reversed, mark it as merged to remove from // intersection view - BOOST_ASSERT(graph.GetEdgeData(lhs.edge).reversed ^ - graph.GetEdgeData(rhs.edge).reversed); - merged_edge_ids.insert(graph.GetEdgeData(lhs.edge).reversed ? lhs.edge : rhs.edge); + BOOST_ASSERT(graph.GetEdgeData(lhs.eid).reversed ^ + graph.GetEdgeData(rhs.eid).reversed); + merged_edge_ids.insert(graph.GetEdgeData(lhs.eid).reversed ? lhs.eid : rhs.eid); } } } @@ -310,10 +305,10 @@ getIntersectionGeometries(const util::NodeBasedDynamicGraph &graph, // Don't adjust bearings of roads that were merged at the current intersection // or have neighbor intersection farer than the pruning distance - if (merged_edges[index] || edge_geometry.length > PRUNING_DISTANCE) + if (merged_edges[index] || edge_geometry.segment_length > PRUNING_DISTANCE) continue; - const auto neighbor_intersection_node = graph.GetTarget(edge_geometry.edge); + const auto neighbor_intersection_node = graph.GetTarget(edge_geometry.eid); const auto neighbor_geometries = getIntersectionOutgoingGeometries( graph, compressed_geometries, node_coordinates, neighbor_intersection_node); @@ -327,7 +322,7 @@ getIntersectionGeometries(const util::NodeBasedDynamicGraph &graph, std::find_if(neighbor_geometries.begin(), neighbor_geometries.end(), [&graph, &intersection_node](const auto &road) { - return graph.GetTarget(road.edge) == intersection_node; + return graph.GetTarget(road.eid) == intersection_node; })); BOOST_ASSERT(static_cast(neighbor_curr) != neighbor_geometries.size()); const auto neighbor_prev = (neighbor_curr + neighbor_edges - 1) % neighbor_edges; @@ -396,12 +391,12 @@ getIntersectionGeometries(const util::NodeBasedDynamicGraph &graph, for (std::size_t index = 0; index < edges_number; ++index) { const auto &geometry = edge_geometries[index]; - const auto remote_node = graph.GetTarget(geometry.edge); + 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.length}; + geometry.segment_length}; } // Enforce ordering of edges by IDs @@ -414,9 +409,9 @@ inline auto findEdge(const IntersectionEdgeGeometries &geometries, const EdgeID { const auto it = std::lower_bound( geometries.begin(), geometries.end(), edge, [](const auto &geometry, const auto edge) { - return geometry.edge < edge; + return geometry.eid < edge; }); - BOOST_ASSERT(it != geometries.end() && it->edge == edge); + BOOST_ASSERT(it != geometries.end() && it->eid == edge); return it; } @@ -427,7 +422,7 @@ double findEdgeBearing(const IntersectionEdgeGeometries &geometries, const EdgeI double findEdgeLength(const IntersectionEdgeGeometries &geometries, const EdgeID &edge) { - return findEdge(geometries, edge)->length; + return findEdge(geometries, edge)->segment_length; } template @@ -634,7 +629,7 @@ IntersectionView convertToIntersectionView(const util::NodeBasedDynamicGraph &gr using IntersectionViewDataWithAngle = std::pair; std::vector pre_intersection_view; - IntersectionViewData uturn{{SPECIAL_EDGEID, 0., 0.}, false, 0.}; + IntersectionViewData uturn{{SPECIAL_EDGEID, 0., 0., 0.}, false, 0.}; std::size_t allowed_uturns_number = 0; for (const auto &outgoing_edge : outgoing_edges) { @@ -643,7 +638,6 @@ IntersectionView convertToIntersectionView(const util::NodeBasedDynamicGraph &gr }; const auto edge_it = findEdge(edge_geometries, outgoing_edge.edge); - const auto segment_length = edge_it->length; const auto is_merged = merged_edges.count(outgoing_edge.edge) != 0; const auto is_turn_allowed = intersection::isTurnAllowed(graph, node_data_container, @@ -673,8 +667,7 @@ IntersectionView convertToIntersectionView(const util::NodeBasedDynamicGraph &gr const auto is_uturn_angle = is_uturn(turn_angle); - IntersectionViewData road{ - {outgoing_edge.edge, outgoing_bearing, segment_length}, is_turn_allowed, turn_angle}; + IntersectionViewData road{*edge_it, is_turn_allowed, turn_angle}; if (graph.GetTarget(outgoing_edge.edge) == incoming_edge.node) { // Save the true U-turn road to add later if no allowed U-turns will be added @@ -772,12 +765,12 @@ IntersectionView getConnectedRoads(const util::NodeBasedDynamicGraph &graph, for (std::size_t index = 0; index < edges_number; ++index) { const auto &geometry = edge_geometries[index]; - const auto remote_node = graph.GetTarget(geometry.edge); + 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.length}; + geometry.segment_length}; } // Enforce ordering of edges by IDs diff --git a/src/extractor/intersection/mergable_road_detector.cpp b/src/extractor/intersection/mergable_road_detector.cpp index 1d0e82893..0c74ff4b1 100644 --- a/src/extractor/intersection/mergable_road_detector.cpp +++ b/src/extractor/intersection/mergable_road_detector.cpp @@ -71,11 +71,11 @@ MergableRoadDetector::MergableRoadDetector( } bool MergableRoadDetector::CanMergeRoad(const NodeID intersection_node, - const IntersectionShapeData &lhs, - const IntersectionShapeData &rhs) const + const IntersectionEdgeGeometry &lhs, + const IntersectionEdgeGeometry &rhs) const { // roads should be somewhat close - if (angularDeviation(lhs.bearing, rhs.bearing) > MERGABLE_ANGLE_DIFFERENCE) + if (angularDeviation(lhs.perceived_bearing, rhs.perceived_bearing) > MERGABLE_ANGLE_DIFFERENCE) return false; const auto &lhs_edge = node_based_graph.GetEdgeData(lhs.eid); @@ -126,7 +126,7 @@ bool MergableRoadDetector::IsDistinctFrom(const MergableRoadData &lhs, const MergableRoadData &rhs) const { // needs to be far away - if (angularDeviation(lhs.bearing, rhs.bearing) > MERGABLE_ANGLE_DIFFERENCE) + if (angularDeviation(lhs.perceived_bearing, rhs.perceived_bearing) > MERGABLE_ANGLE_DIFFERENCE) return true; else // or it cannot have the same name return !HaveIdenticalNames( @@ -201,7 +201,7 @@ bool MergableRoadDetector::IsNarrowTriangle(const NodeID intersection_node, SelectStraightmostRoadByNameAndOnlyChoice selector( node_data_container.GetAnnotation(node_based_graph.GetEdgeData(lhs.eid).annotation_data) .name_id, - lhs.bearing, + lhs.perceived_bearing, /*requires entry=*/false, false); @@ -316,7 +316,7 @@ bool MergableRoadDetector::IsCircularShape(const NodeID intersection_node, SelectStraightmostRoadByNameAndOnlyChoice selector( node_data_container.GetAnnotation(node_based_graph.GetEdgeData(edge_id).annotation_data) .name_id, - lhs.bearing, + lhs.perceived_bearing, /*requires_entry=*/false, false); graph_walker.TraverseRoad(intersection_node, edge_id, accumulator, selector); @@ -372,7 +372,7 @@ bool MergableRoadDetector::HaveSameDirection(const NodeID intersection_node, const MergableRoadData &lhs, const MergableRoadData &rhs) const { - if (angularDeviation(lhs.bearing, rhs.bearing) > MERGABLE_ANGLE_DIFFERENCE) + if (angularDeviation(lhs.perceived_bearing, rhs.perceived_bearing) > MERGABLE_ANGLE_DIFFERENCE) return false; // Find a coordinate following a road that is far away @@ -388,7 +388,7 @@ bool MergableRoadDetector::HaveSameDirection(const NodeID intersection_node, SelectStraightmostRoadByNameAndOnlyChoice selector( node_data_container.GetAnnotation(node_based_graph.GetEdgeData(edge_id).annotation_data) .name_id, - lhs.bearing, + lhs.perceived_bearing, /*requires_entry=*/false, true); graph_walker.TraverseRoad(intersection_node, edge_id, accumulator, selector); diff --git a/src/extractor/intersection/node_based_graph_walker.cpp b/src/extractor/intersection/node_based_graph_walker.cpp index 3f3dd95ab..23c33559e 100644 --- a/src/extractor/intersection/node_based_graph_walker.cpp +++ b/src/extractor/intersection/node_based_graph_walker.cpp @@ -175,7 +175,7 @@ operator()(const NodeID /*nid*/, ((intersection.size() == 2 || intersection.findClosestTurn(STRAIGHT_ANGLE) == min_element) && angularDeviation(min_element->angle, STRAIGHT_ANGLE) < NARROW_TURN_ANGLE) && - angularDeviation(initial_bearing, min_element->bearing) < NARROW_TURN_ANGLE; + angularDeviation(initial_bearing, min_element->perceived_bearing) < NARROW_TURN_ANGLE; if (has_valid_angle) return (*min_element).eid; diff --git a/src/guidance/guidance_processing.cpp b/src/guidance/guidance_processing.cpp index 760a09a5a..8cf52ac79 100644 --- a/src/guidance/guidance_processing.cpp +++ b/src/guidance/guidance_processing.cpp @@ -232,12 +232,12 @@ void annotateTurns(const util::NodeBasedDynamicGraph &node_based_graph, OSRM_ASSERT(turn != intersection.end(), node_coordinates[intersection_node]); - buffer->continuous_turn_data.push_back( - guidance::TurnData{turn->instruction, - turn->lane_data_id, - entry_class_id, - guidance::TurnBearing(intersection[0].bearing), - guidance::TurnBearing(turn->bearing)}); + buffer->continuous_turn_data.push_back(guidance::TurnData{ + turn->instruction, + turn->lane_data_id, + entry_class_id, + guidance::TurnBearing(intersection[0].perceived_bearing), + guidance::TurnBearing(turn->perceived_bearing)}); // when turning off a a via-way turn restriction, we need to not only // handle the normal edges for the way, but also add turns for every @@ -271,8 +271,9 @@ void annotateTurns(const util::NodeBasedDynamicGraph &node_based_graph, turn->instruction, turn->lane_data_id, entry_class_id, - guidance::TurnBearing(intersection[0].bearing), - guidance::TurnBearing(turn->bearing)}); + guidance::TurnBearing( + intersection[0].perceived_bearing), + guidance::TurnBearing(turn->perceived_bearing)}); } else { @@ -280,8 +281,9 @@ void annotateTurns(const util::NodeBasedDynamicGraph &node_based_graph, turn->instruction, turn->lane_data_id, entry_class_id, - guidance::TurnBearing(intersection[0].bearing), - guidance::TurnBearing(turn->bearing)}); + guidance::TurnBearing( + intersection[0].perceived_bearing), + guidance::TurnBearing(turn->perceived_bearing)}); } } } diff --git a/src/guidance/sliproad_handler.cpp b/src/guidance/sliproad_handler.cpp index 4d17984a0..cd68aa536 100644 --- a/src/guidance/sliproad_handler.cpp +++ b/src/guidance/sliproad_handler.cpp @@ -562,7 +562,8 @@ operator()(const NodeID /*nid*/, const EdgeID source_edge_id, Intersection inter const auto candidate_road_target = node_based_graph.GetTarget(candidate_road.eid); if ((candidate_road_target == main_road_intersection->node) || (candidate_road_target == node_based_graph.GetTarget(crossing_road.eid) && - util::bearing::angleBetween(candidate_road.bearing, crossing_road.bearing) < + util::bearing::angleBetween(candidate_road.perceived_bearing, + crossing_road.perceived_bearing) < FUZZY_ANGLE_DIFFERENCE && (getTurnDirection(candidate_road.angle) == DirectionModifier::SharpRight || getTurnDirection(candidate_road.angle) == DirectionModifier::SharpLeft))) diff --git a/src/guidance/turn_classification.cpp b/src/guidance/turn_classification.cpp index 1fee7e04f..edc0bd047 100644 --- a/src/guidance/turn_classification.cpp +++ b/src/guidance/turn_classification.cpp @@ -20,7 +20,7 @@ classifyIntersection(Intersection intersection, const osrm::util::Coordinate &lo std::sort(intersection.begin(), intersection.end(), [](const ConnectedRoad &left, const ConnectedRoad &right) { - return left.bearing < right.bearing; + return left.perceived_bearing < right.perceived_bearing; }); util::guidance::EntryClass entry_class; @@ -31,11 +31,12 @@ classifyIntersection(Intersection intersection, const osrm::util::Coordinate &lo return true; DiscreteBearing last_discrete_bearing = util::guidance::BearingClass::getDiscreteBearing( - std::round(intersection.back().bearing)); + std::round(intersection.back().perceived_bearing)); for (const auto &road : intersection) { const DiscreteBearing discrete_bearing = - util::guidance::BearingClass::getDiscreteBearing(std::round(road.bearing)); + util::guidance::BearingClass::getDiscreteBearing( + std::round(road.perceived_bearing)); if (discrete_bearing == last_discrete_bearing) return false; last_discrete_bearing = discrete_bearing; @@ -47,8 +48,10 @@ classifyIntersection(Intersection intersection, const osrm::util::Coordinate &lo std::size_t number = 0; if (canBeDiscretized) { - if (util::guidance::BearingClass::getDiscreteBearing(intersection.back().bearing) < - util::guidance::BearingClass::getDiscreteBearing(intersection.front().bearing)) + if (util::guidance::BearingClass::getDiscreteBearing( + intersection.back().perceived_bearing) < + util::guidance::BearingClass::getDiscreteBearing( + intersection.front().perceived_bearing)) { intersection.insert(intersection.begin(), intersection.back()); intersection.pop_back(); @@ -64,8 +67,8 @@ classifyIntersection(Intersection intersection, const osrm::util::Coordinate &lo } } - auto discrete_bearing_class = - util::guidance::BearingClass::getDiscreteBearing(std::round(road.bearing)); + auto discrete_bearing_class = util::guidance::BearingClass::getDiscreteBearing( + std::round(road.perceived_bearing)); bearing_class.add(std::round(discrete_bearing_class * util::guidance::BearingClass::discrete_step_size)); ++number; @@ -83,7 +86,7 @@ classifyIntersection(Intersection intersection, const osrm::util::Coordinate &lo << util::toOSMLink(location); } } - bearing_class.add(std::round(road.bearing)); + bearing_class.add(std::round(road.perceived_bearing)); ++number; } }