Merge IntersectionShapeData and IntersectionEdgeGeometry

This commit is contained in:
Michael Krasnyk 2018-02-16 09:39:38 +01:00
parent 0f93a7dd05
commit 0fc8b6289c
14 changed files with 103 additions and 106 deletions

View File

@ -3,6 +3,11 @@
- Bugfixes: - Bugfixes:
- fix deduplication of route steps when waypoints are used [#4909](https://github.com/Project-OSRM/osrm-backend/issues/4909) - 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) - 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: - Tools:
- `osrm-routed` accepts a new property `--memory_file` to store memory in a file on disk. - `osrm-routed` accepts a new property `--memory_file` to store memory in a file on disk.
- NodeJS: - NodeJS:

View File

@ -26,14 +26,19 @@ struct IntersectionEdge
using IntersectionEdges = std::vector<IntersectionEdge>; using IntersectionEdges = std::vector<IntersectionEdge>;
// 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 struct IntersectionEdgeGeometry
{ {
EdgeID edge; EdgeID eid;
double initial_bearing; double initial_bearing;
double perceived_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<IntersectionEdgeGeometry>; using IntersectionEdgeGeometries = std::vector<IntersectionEdgeGeometry>;

View File

@ -1,6 +1,19 @@
#ifndef OSRM_EXTRACTOR_INTERSECTION_INTERSECTION_VIEW_HPP_ #ifndef OSRM_EXTRACTOR_INTERSECTION_INTERSECTION_VIEW_HPP_
#define 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 <boost/range/algorithm/count_if.hpp>
#include <boost/range/algorithm/find_if.hpp>
#include <boost/range/algorithm/min_element.hpp>
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
#include <limits> #include <limits>
@ -8,17 +21,6 @@
#include <type_traits> #include <type_traits>
#include <vector> #include <vector>
#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 <boost/range/algorithm/count_if.hpp>
#include <boost/range/algorithm/find_if.hpp>
#include <boost/range/algorithm/min_element.hpp>
namespace osrm namespace osrm
{ {
namespace extractor namespace extractor
@ -26,24 +28,6 @@ namespace extractor
namespace intersection 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) inline auto makeCompareAngularDeviation(const double angle)
{ {
return [angle](const auto &lhs, const auto &rhs) { 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 // 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 // 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 bool entry_allowed,
const double angle) 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 <typename Self> struct EnableShapeOps template <typename Self> struct EnableShapeOps
{ {
// same as closest turn, but for bearings // 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(
return std::min_element(self()->begin(), self()->end(), comp); 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 // search a given eid in the intersection
@ -119,10 +106,10 @@ template <typename Self> struct EnableShapeOps
auto self() const { return static_cast<const Self *>(this); } auto self() const { return static_cast<const Self *>(this); }
}; };
struct IntersectionShape final : std::vector<IntersectionShapeData>, // struct IntersectionShape final : std::vector<IntersectionEdgeGeometry>, //
EnableShapeOps<IntersectionShape> // EnableShapeOps<IntersectionShape> //
{ {
using Base = std::vector<IntersectionShapeData>; using Base = std::vector<IntersectionEdgeGeometry>;
}; };
// Common operations shared among IntersectionView and Intersections. // Common operations shared among IntersectionView and Intersections.

View File

@ -40,7 +40,7 @@ class MergableRoadDetector
{ {
public: public:
// in case we have to change the mode we are operating on // 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, MergableRoadDetector(const util::NodeBasedDynamicGraph &node_based_graph,
const EdgeBasedNodeDataContainer &node_data_container, const EdgeBasedNodeDataContainer &node_data_container,

View File

@ -114,7 +114,7 @@ inline std::string toString(const ConnectedRoad &road)
result += " angle: "; result += " angle: ";
result += std::to_string(road.angle); result += std::to_string(road.angle);
result += " bearing: "; result += " bearing: ";
result += std::to_string(road.bearing); result += std::to_string(road.perceived_bearing);
result += " instruction: "; result += " instruction: ";
result += std::to_string(static_cast<std::int32_t>(road.instruction.type)) + " " + result += std::to_string(static_cast<std::int32_t>(road.instruction.type)) + " " +
std::to_string(static_cast<std::int32_t>(road.instruction.direction_modifier)) + " " + std::to_string(static_cast<std::int32_t>(road.instruction.direction_modifier)) + " " +

View File

@ -348,7 +348,7 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
const auto turns_onto_through_street = [&](const auto &road) { const auto turns_onto_through_street = [&](const auto &road) {
// find edge opposite to the one we are checking (in-road) // find edge opposite to the one we are checking (in-road)
const auto in_through_candidate = 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 &in_edge = node_based_graph.GetEdgeData(in_through_candidate->eid);
const auto &out_edge = node_based_graph.GetEdgeData(road.eid); const auto &out_edge = node_based_graph.GetEdgeData(road.eid);

View File

@ -68,7 +68,7 @@ namespace guidance
inline std::ostream &operator<<(std::ostream &out, const ConnectedRoad &road) inline std::ostream &operator<<(std::ostream &out, const ConnectedRoad &road)
{ {
out << "ConnectedRoad {" << road.eid << " allows entry: " << road.entry_allowed 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<std::int32_t>(road.instruction.type) << " " << " instruction: " << static_cast<std::int32_t>(road.instruction.type) << " "
<< static_cast<std::int32_t>(road.instruction.direction_modifier) << " " << static_cast<std::int32_t>(road.instruction.direction_modifier) << " "
<< static_cast<std::int32_t>(road.lane_data_id) << "}"; << static_cast<std::int32_t>(road.lane_data_id) << "}";
@ -80,16 +80,17 @@ namespace extractor
{ {
namespace intersection 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; return out;
} }
inline std::ostream &operator<<(std::ostream &out, const IntersectionViewData &view) inline std::ostream &operator<<(std::ostream &out, const IntersectionViewData &view)
{ {
out << "IntersectionViewData {" << view.eid << " allows entry: " << view.entry_allowed out << "IntersectionViewData {" << view.eid << " allows entry: " << view.entry_allowed
<< " angle: " << view.angle << " bearing: " << view.bearing << "}"; << " angle: " << view.angle << " bearing: " << view.perceived_bearing << "}";
return out; return out;
} }
} }

View File

@ -19,10 +19,10 @@ bool IntersectionViewData::CompareByAngle(const IntersectionViewData &other) con
return angle < other.angle; return angle < other.angle;
} }
std::string toString(const IntersectionShapeData &shape) std::string toString(const IntersectionEdgeGeometry &shape)
{ {
std::string result = std::string result = "[shape] " + std::to_string(shape.eid) + " bearing: " +
"[shape] " + std::to_string(shape.eid) + " bearing: " + std::to_string(shape.bearing); std::to_string(shape.perceived_bearing);
return result; return result;
} }
@ -35,7 +35,7 @@ std::string toString(const IntersectionViewData &view)
result += " angle: "; result += " angle: ";
result += std::to_string(view.angle); result += std::to_string(view.angle);
result += " bearing: "; result += " bearing: ";
result += std::to_string(view.bearing); result += std::to_string(view.perceived_bearing);
return result; return result;
} }

View File

@ -120,9 +120,9 @@ std::pair<bool, double> findMergedBearing(const util::NodeBasedDynamicGraph &gra
const auto &lhs = edge_geometries[lhs_index]; const auto &lhs = edge_geometries[lhs_index];
const auto &rhs = edge_geometries[rhs_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 = const auto opposite_bearing =
findClosestOppositeBearing(edge_geometries, entry.perceived_bearing); findClosestOppositeBearing(edge_geometries, entry.perceived_bearing);
const auto merged_bearing = findAngleBisector(rhs.perceived_bearing, lhs.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 // TODO: check IsDistinctFrom - it is an angle and name-only check
// also check CanMergeRoad for all merging scenarios // also check CanMergeRoad for all merging scenarios
return detector.IsDistinctFrom({llhs.edge, llhs.perceived_bearing, llhs.length}, return detector.IsDistinctFrom(llhs, lhs) &&
{lhs.edge, lhs.perceived_bearing, lhs.length}) && detector.CanMergeRoad(intersection_node, lhs, rhs) && detector.IsDistinctFrom(rhs, rrhs);
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});
} }
auto getIntersectionLanes(const util::NodeBasedDynamicGraph &graph, const NodeID intersection_node) 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 // Only one of the edges must be reversed, mark it as merged to remove from
// intersection view // intersection view
BOOST_ASSERT(graph.GetEdgeData(lhs.edge).reversed ^ BOOST_ASSERT(graph.GetEdgeData(lhs.eid).reversed ^
graph.GetEdgeData(rhs.edge).reversed); graph.GetEdgeData(rhs.eid).reversed);
merged_edge_ids.insert(graph.GetEdgeData(lhs.edge).reversed ? lhs.edge : rhs.edge); 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 // Don't adjust bearings of roads that were merged at the current intersection
// or have neighbor intersection farer than the pruning distance // 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; 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<false>( const auto neighbor_geometries = getIntersectionOutgoingGeometries<false>(
graph, compressed_geometries, node_coordinates, neighbor_intersection_node); graph, compressed_geometries, node_coordinates, neighbor_intersection_node);
@ -327,7 +322,7 @@ getIntersectionGeometries(const util::NodeBasedDynamicGraph &graph,
std::find_if(neighbor_geometries.begin(), std::find_if(neighbor_geometries.begin(),
neighbor_geometries.end(), neighbor_geometries.end(),
[&graph, &intersection_node](const auto &road) { [&graph, &intersection_node](const auto &road) {
return graph.GetTarget(road.edge) == intersection_node; return graph.GetTarget(road.eid) == intersection_node;
})); }));
BOOST_ASSERT(static_cast<std::size_t>(neighbor_curr) != neighbor_geometries.size()); BOOST_ASSERT(static_cast<std::size_t>(neighbor_curr) != neighbor_geometries.size());
const auto neighbor_prev = (neighbor_curr + neighbor_edges - 1) % neighbor_edges; 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) for (std::size_t index = 0; index < edges_number; ++index)
{ {
const auto &geometry = edge_geometries[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); const auto incoming_edge = graph.FindEdge(remote_node, intersection_node);
edge_geometries[edges_number + index] = {incoming_edge, edge_geometries[edges_number + index] = {incoming_edge,
util::bearing::reverse(geometry.initial_bearing), util::bearing::reverse(geometry.initial_bearing),
util::bearing::reverse(geometry.perceived_bearing), util::bearing::reverse(geometry.perceived_bearing),
geometry.length}; geometry.segment_length};
} }
// Enforce ordering of edges by IDs // Enforce ordering of edges by IDs
@ -414,9 +409,9 @@ inline auto findEdge(const IntersectionEdgeGeometries &geometries, const EdgeID
{ {
const auto it = std::lower_bound( const auto it = std::lower_bound(
geometries.begin(), geometries.end(), edge, [](const auto &geometry, const auto edge) { 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; return it;
} }
@ -427,7 +422,7 @@ double findEdgeBearing(const IntersectionEdgeGeometries &geometries, const EdgeI
double findEdgeLength(const IntersectionEdgeGeometries &geometries, const EdgeID &edge) double findEdgeLength(const IntersectionEdgeGeometries &geometries, const EdgeID &edge)
{ {
return findEdge(geometries, edge)->length; return findEdge(geometries, edge)->segment_length;
} }
template <typename RestrictionsRange> template <typename RestrictionsRange>
@ -634,7 +629,7 @@ IntersectionView convertToIntersectionView(const util::NodeBasedDynamicGraph &gr
using IntersectionViewDataWithAngle = std::pair<IntersectionViewData, double>; using IntersectionViewDataWithAngle = std::pair<IntersectionViewData, double>;
std::vector<IntersectionViewDataWithAngle> pre_intersection_view; std::vector<IntersectionViewDataWithAngle> 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; std::size_t allowed_uturns_number = 0;
for (const auto &outgoing_edge : outgoing_edges) 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 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_merged = merged_edges.count(outgoing_edge.edge) != 0;
const auto is_turn_allowed = intersection::isTurnAllowed(graph, const auto is_turn_allowed = intersection::isTurnAllowed(graph,
node_data_container, node_data_container,
@ -673,8 +667,7 @@ IntersectionView convertToIntersectionView(const util::NodeBasedDynamicGraph &gr
const auto is_uturn_angle = is_uturn(turn_angle); const auto is_uturn_angle = is_uturn(turn_angle);
IntersectionViewData road{ IntersectionViewData road{*edge_it, is_turn_allowed, turn_angle};
{outgoing_edge.edge, outgoing_bearing, segment_length}, is_turn_allowed, turn_angle};
if (graph.GetTarget(outgoing_edge.edge) == incoming_edge.node) 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 { // 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) for (std::size_t index = 0; index < edges_number; ++index)
{ {
const auto &geometry = edge_geometries[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); const auto incoming_edge = graph.FindEdge(remote_node, intersection_node);
edge_geometries[edges_number + index] = {incoming_edge, edge_geometries[edges_number + index] = {incoming_edge,
util::bearing::reverse(geometry.initial_bearing), util::bearing::reverse(geometry.initial_bearing),
util::bearing::reverse(geometry.perceived_bearing), util::bearing::reverse(geometry.perceived_bearing),
geometry.length}; geometry.segment_length};
} }
// Enforce ordering of edges by IDs // Enforce ordering of edges by IDs

View File

@ -71,11 +71,11 @@ MergableRoadDetector::MergableRoadDetector(
} }
bool MergableRoadDetector::CanMergeRoad(const NodeID intersection_node, bool MergableRoadDetector::CanMergeRoad(const NodeID intersection_node,
const IntersectionShapeData &lhs, const IntersectionEdgeGeometry &lhs,
const IntersectionShapeData &rhs) const const IntersectionEdgeGeometry &rhs) const
{ {
// roads should be somewhat close // 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; return false;
const auto &lhs_edge = node_based_graph.GetEdgeData(lhs.eid); const auto &lhs_edge = node_based_graph.GetEdgeData(lhs.eid);
@ -126,7 +126,7 @@ bool MergableRoadDetector::IsDistinctFrom(const MergableRoadData &lhs,
const MergableRoadData &rhs) const const MergableRoadData &rhs) const
{ {
// needs to be far away // 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; return true;
else // or it cannot have the same name else // or it cannot have the same name
return !HaveIdenticalNames( return !HaveIdenticalNames(
@ -201,7 +201,7 @@ bool MergableRoadDetector::IsNarrowTriangle(const NodeID intersection_node,
SelectStraightmostRoadByNameAndOnlyChoice selector( SelectStraightmostRoadByNameAndOnlyChoice selector(
node_data_container.GetAnnotation(node_based_graph.GetEdgeData(lhs.eid).annotation_data) node_data_container.GetAnnotation(node_based_graph.GetEdgeData(lhs.eid).annotation_data)
.name_id, .name_id,
lhs.bearing, lhs.perceived_bearing,
/*requires entry=*/false, /*requires entry=*/false,
false); false);
@ -316,7 +316,7 @@ bool MergableRoadDetector::IsCircularShape(const NodeID intersection_node,
SelectStraightmostRoadByNameAndOnlyChoice selector( SelectStraightmostRoadByNameAndOnlyChoice selector(
node_data_container.GetAnnotation(node_based_graph.GetEdgeData(edge_id).annotation_data) node_data_container.GetAnnotation(node_based_graph.GetEdgeData(edge_id).annotation_data)
.name_id, .name_id,
lhs.bearing, lhs.perceived_bearing,
/*requires_entry=*/false, /*requires_entry=*/false,
false); false);
graph_walker.TraverseRoad(intersection_node, edge_id, accumulator, selector); 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 &lhs,
const MergableRoadData &rhs) const 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; return false;
// Find a coordinate following a road that is far away // Find a coordinate following a road that is far away
@ -388,7 +388,7 @@ bool MergableRoadDetector::HaveSameDirection(const NodeID intersection_node,
SelectStraightmostRoadByNameAndOnlyChoice selector( SelectStraightmostRoadByNameAndOnlyChoice selector(
node_data_container.GetAnnotation(node_based_graph.GetEdgeData(edge_id).annotation_data) node_data_container.GetAnnotation(node_based_graph.GetEdgeData(edge_id).annotation_data)
.name_id, .name_id,
lhs.bearing, lhs.perceived_bearing,
/*requires_entry=*/false, /*requires_entry=*/false,
true); true);
graph_walker.TraverseRoad(intersection_node, edge_id, accumulator, selector); graph_walker.TraverseRoad(intersection_node, edge_id, accumulator, selector);

View File

@ -175,7 +175,7 @@ operator()(const NodeID /*nid*/,
((intersection.size() == 2 || ((intersection.size() == 2 ||
intersection.findClosestTurn(STRAIGHT_ANGLE) == min_element) && intersection.findClosestTurn(STRAIGHT_ANGLE) == min_element) &&
angularDeviation(min_element->angle, STRAIGHT_ANGLE) < NARROW_TURN_ANGLE) && 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) if (has_valid_angle)
return (*min_element).eid; return (*min_element).eid;

View File

@ -232,12 +232,12 @@ void annotateTurns(const util::NodeBasedDynamicGraph &node_based_graph,
OSRM_ASSERT(turn != intersection.end(), OSRM_ASSERT(turn != intersection.end(),
node_coordinates[intersection_node]); node_coordinates[intersection_node]);
buffer->continuous_turn_data.push_back( buffer->continuous_turn_data.push_back(guidance::TurnData{
guidance::TurnData{turn->instruction, turn->instruction,
turn->lane_data_id, turn->lane_data_id,
entry_class_id, entry_class_id,
guidance::TurnBearing(intersection[0].bearing), guidance::TurnBearing(intersection[0].perceived_bearing),
guidance::TurnBearing(turn->bearing)}); guidance::TurnBearing(turn->perceived_bearing)});
// when turning off a a via-way turn restriction, we need to not only // 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 // 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->instruction,
turn->lane_data_id, turn->lane_data_id,
entry_class_id, entry_class_id,
guidance::TurnBearing(intersection[0].bearing), guidance::TurnBearing(
guidance::TurnBearing(turn->bearing)}); intersection[0].perceived_bearing),
guidance::TurnBearing(turn->perceived_bearing)});
} }
else else
{ {
@ -280,8 +281,9 @@ void annotateTurns(const util::NodeBasedDynamicGraph &node_based_graph,
turn->instruction, turn->instruction,
turn->lane_data_id, turn->lane_data_id,
entry_class_id, entry_class_id,
guidance::TurnBearing(intersection[0].bearing), guidance::TurnBearing(
guidance::TurnBearing(turn->bearing)}); intersection[0].perceived_bearing),
guidance::TurnBearing(turn->perceived_bearing)});
} }
} }
} }

View File

@ -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); const auto candidate_road_target = node_based_graph.GetTarget(candidate_road.eid);
if ((candidate_road_target == main_road_intersection->node) || if ((candidate_road_target == main_road_intersection->node) ||
(candidate_road_target == node_based_graph.GetTarget(crossing_road.eid) && (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 && FUZZY_ANGLE_DIFFERENCE &&
(getTurnDirection(candidate_road.angle) == DirectionModifier::SharpRight || (getTurnDirection(candidate_road.angle) == DirectionModifier::SharpRight ||
getTurnDirection(candidate_road.angle) == DirectionModifier::SharpLeft))) getTurnDirection(candidate_road.angle) == DirectionModifier::SharpLeft)))

View File

@ -20,7 +20,7 @@ classifyIntersection(Intersection intersection, const osrm::util::Coordinate &lo
std::sort(intersection.begin(), std::sort(intersection.begin(),
intersection.end(), intersection.end(),
[](const ConnectedRoad &left, const ConnectedRoad &right) { [](const ConnectedRoad &left, const ConnectedRoad &right) {
return left.bearing < right.bearing; return left.perceived_bearing < right.perceived_bearing;
}); });
util::guidance::EntryClass entry_class; util::guidance::EntryClass entry_class;
@ -31,11 +31,12 @@ classifyIntersection(Intersection intersection, const osrm::util::Coordinate &lo
return true; return true;
DiscreteBearing last_discrete_bearing = util::guidance::BearingClass::getDiscreteBearing( DiscreteBearing last_discrete_bearing = util::guidance::BearingClass::getDiscreteBearing(
std::round(intersection.back().bearing)); std::round(intersection.back().perceived_bearing));
for (const auto &road : intersection) for (const auto &road : intersection)
{ {
const DiscreteBearing discrete_bearing = 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) if (discrete_bearing == last_discrete_bearing)
return false; return false;
last_discrete_bearing = discrete_bearing; last_discrete_bearing = discrete_bearing;
@ -47,8 +48,10 @@ classifyIntersection(Intersection intersection, const osrm::util::Coordinate &lo
std::size_t number = 0; std::size_t number = 0;
if (canBeDiscretized) if (canBeDiscretized)
{ {
if (util::guidance::BearingClass::getDiscreteBearing(intersection.back().bearing) < if (util::guidance::BearingClass::getDiscreteBearing(
util::guidance::BearingClass::getDiscreteBearing(intersection.front().bearing)) intersection.back().perceived_bearing) <
util::guidance::BearingClass::getDiscreteBearing(
intersection.front().perceived_bearing))
{ {
intersection.insert(intersection.begin(), intersection.back()); intersection.insert(intersection.begin(), intersection.back());
intersection.pop_back(); intersection.pop_back();
@ -64,8 +67,8 @@ classifyIntersection(Intersection intersection, const osrm::util::Coordinate &lo
} }
} }
auto discrete_bearing_class = auto discrete_bearing_class = util::guidance::BearingClass::getDiscreteBearing(
util::guidance::BearingClass::getDiscreteBearing(std::round(road.bearing)); std::round(road.perceived_bearing));
bearing_class.add(std::round(discrete_bearing_class * bearing_class.add(std::round(discrete_bearing_class *
util::guidance::BearingClass::discrete_step_size)); util::guidance::BearingClass::discrete_step_size));
++number; ++number;
@ -83,7 +86,7 @@ classifyIntersection(Intersection intersection, const osrm::util::Coordinate &lo
<< util::toOSMLink(location); << util::toOSMLink(location);
} }
} }
bearing_class.add(std::round(road.bearing)); bearing_class.add(std::round(road.perceived_bearing));
++number; ++number;
} }
} }