Split intersection analysis and guidance code
Intersection analysis occupy in osrm::extractor::intersection namespace and guidance code osrm::guidance
This commit is contained in:
@@ -1,25 +1,23 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_CONSTANTS_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_CONSTANTS_HPP_
|
||||
#ifndef OSRM_GUIDANCE_CONSTANTS_HPP_
|
||||
#define OSRM_GUIDANCE_CONSTANTS_HPP_
|
||||
|
||||
#include "extractor/intersection/constants.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
const bool constexpr INVERT = true;
|
||||
|
||||
// what angle is interpreted as going straight
|
||||
const double constexpr STRAIGHT_ANGLE = 180.;
|
||||
const double constexpr ORTHOGONAL_ANGLE = 90.;
|
||||
using extractor::intersection::STRAIGHT_ANGLE;
|
||||
// if a turn deviates this much from going straight, it will be kept straight
|
||||
const double constexpr MAXIMAL_ALLOWED_NO_TURN_DEVIATION = 3.;
|
||||
using extractor::intersection::MAXIMAL_ALLOWED_NO_TURN_DEVIATION;
|
||||
// angle that lies between two nearly indistinguishable roads
|
||||
const double constexpr NARROW_TURN_ANGLE = 40.;
|
||||
const double constexpr GROUP_ANGLE = 60;
|
||||
using extractor::intersection::NARROW_TURN_ANGLE;
|
||||
using extractor::intersection::GROUP_ANGLE;
|
||||
// angle difference that can be classified as straight, if its the only narrow turn
|
||||
const double constexpr FUZZY_ANGLE_DIFFERENCE = 25.;
|
||||
using extractor::intersection::FUZZY_ANGLE_DIFFERENCE;
|
||||
|
||||
const double constexpr DISTINCTION_RATIO = 2;
|
||||
|
||||
// Named roundabouts with radii larger then than this are seen as rotary
|
||||
@@ -32,19 +30,7 @@ const double constexpr INCREASES_BY_FOURTY_PERCENT = 1.4;
|
||||
|
||||
const int constexpr MAX_SLIPROAD_THRESHOLD = 250;
|
||||
|
||||
// Road priorities give an idea of how obvious a turn is. If two priorities differ greatly (e.g.
|
||||
// service road over a primary road, the better priority can be seen as obvious due to its road
|
||||
// category).
|
||||
const double constexpr PRIORITY_DISTINCTION_FACTOR = 1.75;
|
||||
|
||||
// the lane width we assume for a single lane
|
||||
const auto constexpr ASSUMED_LANE_WIDTH = 3.25;
|
||||
|
||||
// how far apart can roads be at the most, when thinking about merging them?
|
||||
const auto constexpr MERGABLE_ANGLE_DIFFERENCE = 95.0;
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_EXTRACTOR_GUIDANCE_CONSTANTS_HPP_
|
||||
#endif // OSRM_GUIDANCE_CONSTANTS_HPP_
|
||||
|
||||
@@ -1,258 +0,0 @@
|
||||
#ifndef OSRM_EXTRACTOR_COORDINATE_EXTRACTOR_HPP_
|
||||
#define OSRM_EXTRACTOR_COORDINATE_EXTRACTOR_HPP_
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "extractor/compressed_edge_container.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
|
||||
#include "util/attributes.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
class CoordinateExtractor
|
||||
{
|
||||
public:
|
||||
CoordinateExtractor(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries,
|
||||
const std::vector<util::Coordinate> &node_coordinates);
|
||||
|
||||
/* Find a interpolated coordinate a long the compressed geometries. The desired coordinate
|
||||
* should be in a certain distance. This method is dedicated to find representative coordinates
|
||||
* at turns.
|
||||
* Note: The segment between intersection and turn coordinate can be zero, if the OSM modelling
|
||||
* is unfortunate. See https://github.com/Project-OSRM/osrm-backend/issues/3470
|
||||
*/
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
util::Coordinate GetCoordinateAlongRoad(const NodeID intersection_node,
|
||||
const EdgeID turn_edge,
|
||||
const bool traversed_in_reverse,
|
||||
const NodeID to_node,
|
||||
const std::uint8_t number_of_in_lanes) const;
|
||||
|
||||
// Given a set of precomputed coordinates, select the representative coordinate along the road
|
||||
// that best describes the turn
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
util::Coordinate
|
||||
ExtractRepresentativeCoordinate(const NodeID intersection_node,
|
||||
const EdgeID turn_edge,
|
||||
const bool traversed_in_reverse,
|
||||
const NodeID to_node,
|
||||
const std::uint8_t intersection_lanes,
|
||||
std::vector<util::Coordinate> coordinates) const;
|
||||
|
||||
// instead of finding only a single coordinate, we can also list all coordinates along a
|
||||
// road.
|
||||
OSRM_ATTR_WARN_UNUSED std::vector<util::Coordinate>
|
||||
GetCoordinatesAlongRoad(const NodeID intersection_node,
|
||||
const EdgeID turn_edge,
|
||||
const bool traversed_in_reverse,
|
||||
const NodeID to_node) const;
|
||||
|
||||
// wrapper in case of normal forward edges (traversed_in_reverse = false, to_node =
|
||||
// node_based_graph.GetTarget(turn_edge)
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
std::vector<util::Coordinate> GetForwardCoordinatesAlongRoad(const NodeID from,
|
||||
const EdgeID turn_edge) const;
|
||||
|
||||
// a less precise way to compute coordinates along a route. Due to the heavy interaction of
|
||||
// graph traversal and turn instructions, we often don't care for high precision. We only want
|
||||
// to check for available connections in order, or find (with room for error) the straightmost
|
||||
// turn. This function will offer a bit more error potential but allow for much higher
|
||||
// performance
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
util::Coordinate GetCoordinateCloseToTurn(const NodeID from_node,
|
||||
const EdgeID turn_edge,
|
||||
const bool traversed_in_reverse,
|
||||
const NodeID to_node) const;
|
||||
|
||||
/* When extracting the coordinates, we first extract all coordinates. We don't care about most
|
||||
* of them, though.
|
||||
*
|
||||
* Our very first step trims the coordinates to a saller set, close to the intersection.. The
|
||||
* idea here is to filter all coordinates at the end of the road and consider only the formi
|
||||
* close to the intersection:
|
||||
*
|
||||
* a -------------- v ----------.
|
||||
* .
|
||||
* .
|
||||
* .
|
||||
* b
|
||||
*
|
||||
* For calculating the turn angle for the intersection at `a`, we do not care about the turn
|
||||
* between `v` and `b`. This calculation trims the coordinates to the ones immediately at the
|
||||
* intersection.
|
||||
*
|
||||
* The optional length cache needs to store the accumulated distance up to the respective
|
||||
* coordinate index [0,d(0,1),...]
|
||||
*/
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
std::vector<util::Coordinate>
|
||||
TrimCoordinatesToLength(std::vector<util::Coordinate> coordinates,
|
||||
const double desired_length,
|
||||
const std::vector<double> &length_cache = {}) const;
|
||||
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
std::vector<double> PrepareLengthCache(const std::vector<util::Coordinate> &coordinates,
|
||||
const double limit) const;
|
||||
|
||||
/* when looking at a set of coordinates, this function allows trimming the vector to a smaller,
|
||||
* only containing coordinates up to a given distance along the path. The last coordinate might
|
||||
* be interpolated
|
||||
*/
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
std::vector<util::Coordinate>
|
||||
TrimCoordinatesByLengthFront(std::vector<util::Coordinate> coordinates,
|
||||
const double desired_length) const;
|
||||
|
||||
/*
|
||||
* to correct for the initial offset, we move the lookahead coordinate close
|
||||
* to the original road. We do so by subtracting the difference between the
|
||||
* turn coordinate and the offset coordinate from the lookahead coordinge:
|
||||
*
|
||||
* a ------ b ------ c
|
||||
* |
|
||||
* d
|
||||
* \
|
||||
* \
|
||||
* e
|
||||
*
|
||||
* is converted to:
|
||||
*
|
||||
* a ------ b ------ c
|
||||
* \
|
||||
* \
|
||||
* e
|
||||
*
|
||||
* for fixpoint `b`, vector_base `d` and vector_head `e`
|
||||
*/
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
util::Coordinate GetCorrectedCoordinate(const util::Coordinate fixpoint,
|
||||
const util::Coordinate vector_base,
|
||||
const util::Coordinate vector_head) const;
|
||||
|
||||
/* generate a uniform vector of coordinates in same range distances
|
||||
*
|
||||
* Turns:
|
||||
* x ------------ x -- x - x
|
||||
*
|
||||
* Into:
|
||||
* x -- x -- x -- x -- x - x
|
||||
*/
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
std::vector<util::Coordinate>
|
||||
SampleCoordinates(const std::vector<util::Coordinate> &coordinates,
|
||||
const double length,
|
||||
const double rate) const;
|
||||
|
||||
// find the coordinate at a specific distance in the vector
|
||||
util::Coordinate
|
||||
ExtractCoordinateAtLength(const double distance,
|
||||
const std::vector<util::Coordinate> &coordinates) const;
|
||||
util::Coordinate ExtractCoordinateAtLength(const double distance,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const std::vector<double> &length_cache) const;
|
||||
|
||||
private:
|
||||
const util::NodeBasedDynamicGraph &node_based_graph;
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries;
|
||||
const std::vector<util::Coordinate> &node_coordinates;
|
||||
|
||||
double ComputeInterpolationFactor(const double desired_distance,
|
||||
const double distance_to_first,
|
||||
const double distance_to_second) const;
|
||||
|
||||
std::pair<util::Coordinate, util::Coordinate>
|
||||
RegressionLine(const std::vector<util::Coordinate> &coordinates) const;
|
||||
|
||||
/* In an ideal world, the road would only have two coordinates if it goes mainly straigt. Since
|
||||
* OSM is operating on noisy data, we have some variations going straight.
|
||||
*
|
||||
* b d
|
||||
* a ---------------------------------------------- e
|
||||
* c
|
||||
*
|
||||
* The road from a-e offers a lot of variation, even though it is mostly straight. Here we
|
||||
* calculate the distances of all nodes in between to the straight line between a and e. If the
|
||||
* distances inbetween are small, we assume a straight road. To calculate these distances, we
|
||||
* don't use the coordinates of the road itself but our just calculated regression vector
|
||||
*/
|
||||
double GetMaxDeviation(std::vector<util::Coordinate>::const_iterator range_begin,
|
||||
const std::vector<util::Coordinate>::const_iterator &range_end,
|
||||
const util::Coordinate straight_begin,
|
||||
const util::Coordinate straight_end) const;
|
||||
|
||||
/*
|
||||
* the curve is still best described as looking at the very first vector for the turn angle.
|
||||
* Consider:
|
||||
*
|
||||
* |
|
||||
* a - 1
|
||||
* | o
|
||||
* | 2
|
||||
* | o
|
||||
* | 3
|
||||
* | o
|
||||
* | 4
|
||||
*
|
||||
* The turn itself from a-1 would be considered as a 90 degree turn, even though the road is
|
||||
* taking a turn later.
|
||||
* In this situaiton we return the very first coordinate, describing the road just at the
|
||||
* turn.
|
||||
* As an added benefit, we get a straight turn at a curved road:
|
||||
*
|
||||
* o b o
|
||||
* o o
|
||||
* o o
|
||||
* o o
|
||||
* o o
|
||||
* a c
|
||||
*
|
||||
* The turn from a-b to b-c is straight. With every vector we go further down the road, the
|
||||
* turn
|
||||
* angle would get stronger. Therefore we consider the very first coordinate as our best
|
||||
* choice
|
||||
*/
|
||||
bool IsCurve(const std::vector<util::Coordinate> &coordinates,
|
||||
const std::vector<double> &segment_distances,
|
||||
const double segment_length,
|
||||
const double considered_lane_width,
|
||||
const extractor::NodeBasedEdgeClassification &edge_data) const;
|
||||
|
||||
/*
|
||||
* If the very first coordinate is within lane offsets and the rest offers a near straight line,
|
||||
* we use an offset coordinate.
|
||||
*
|
||||
* ----------------------------------------
|
||||
*
|
||||
* ----------------------------------------
|
||||
* a -
|
||||
* ----------------------------------------
|
||||
* \
|
||||
* ----------------------------------------
|
||||
* \
|
||||
* b --------------------c
|
||||
*
|
||||
* Will be considered a very slight turn, instead of the near 90 degree turn we see right here.
|
||||
*/
|
||||
bool IsDirectOffset(const std::vector<util::Coordinate> &coordinates,
|
||||
const std::size_t straight_index,
|
||||
const double straight_distance,
|
||||
const double segment_length,
|
||||
const std::vector<double> &segment_distances,
|
||||
const std::uint8_t considered_lanes) const;
|
||||
};
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_EXTRACTOR_COORDINATE_EXTRACTOR_HPP_
|
||||
@@ -1,12 +1,10 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_DRIVEWAY_HANDLER_HPP
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_DRIVEWAY_HANDLER_HPP
|
||||
#ifndef OSRM_GUIDANCE_DRIVEWAY_HANDLER_HPP
|
||||
#define OSRM_GUIDANCE_DRIVEWAY_HANDLER_HPP
|
||||
|
||||
#include "guidance/intersection_handler.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
@@ -15,14 +13,14 @@ class DrivewayHandler final : public IntersectionHandler
|
||||
{
|
||||
public:
|
||||
DrivewayHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const extractor::EdgeBasedNodeDataContainer &node_data_container,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries,
|
||||
const RestrictionMap &node_restriction_map,
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
const extractor::SuffixTable &street_name_suffix_table);
|
||||
|
||||
~DrivewayHandler() override final = default;
|
||||
|
||||
@@ -38,7 +36,6 @@ class DrivewayHandler final : public IntersectionHandler
|
||||
};
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /* OSRM_EXTRACTOR_GUIDANCE_DRIVEWAY_HANDLER_HPP */
|
||||
#endif /* OSRM_GUIDANCE_DRIVEWAY_HANDLER_HPP */
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef OSRM_GUIDANCE_FILES_HPP
|
||||
#define OSRM_GUIDANCE_FILES_HPP
|
||||
|
||||
#include "guidance/serialization.hpp"
|
||||
#include "guidance/turn_data_container.hpp"
|
||||
|
||||
#include "util/packed_vector.hpp"
|
||||
#include "util/range_table.hpp"
|
||||
#include "util/serialization.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
namespace files
|
||||
{
|
||||
|
||||
// reads .osrm.edges
|
||||
template <typename TurnDataT>
|
||||
inline void readTurnData(const boost::filesystem::path &path, TurnDataT &turn_data)
|
||||
{
|
||||
static_assert(std::is_same<guidance::TurnDataContainer, TurnDataT>::value ||
|
||||
std::is_same<guidance::TurnDataView, TurnDataT>::value ||
|
||||
std::is_same<guidance::TurnDataExternalContainer, TurnDataT>::value,
|
||||
"");
|
||||
const auto fingerprint = storage::io::FileReader::VerifyFingerprint;
|
||||
storage::io::FileReader reader{path, fingerprint};
|
||||
|
||||
serialization::read(reader, turn_data);
|
||||
}
|
||||
|
||||
// writes .osrm.edges
|
||||
template <typename TurnDataT>
|
||||
inline void writeTurnData(const boost::filesystem::path &path, const TurnDataT &turn_data)
|
||||
{
|
||||
static_assert(std::is_same<guidance::TurnDataContainer, TurnDataT>::value ||
|
||||
std::is_same<guidance::TurnDataView, TurnDataT>::value ||
|
||||
std::is_same<guidance::TurnDataExternalContainer, TurnDataT>::value,
|
||||
"");
|
||||
const auto fingerprint = storage::io::FileWriter::GenerateFingerprint;
|
||||
storage::io::FileWriter writer{path, fingerprint};
|
||||
|
||||
serialization::write(writer, turn_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,27 +0,0 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_
|
||||
|
||||
#include "guidance/constants.hpp"
|
||||
#include "extractor/suffix_table.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
// check if two name ids can be seen as identical (in presence of refs/others)
|
||||
// in our case this translates into no name announcement in either direction (lhs->rhs and
|
||||
// rhs->lhs)
|
||||
bool HaveIdenticalNames(const NameID lhs,
|
||||
const NameID rhs,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /*OSRM_EXTRACTOR_GUIDANCE_HAVE_IDENTICAL_NAMES_HPP_*/
|
||||
@@ -1,80 +1,14 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_INTERSECTION_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_INTERSECTION_HPP_
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include "util/bearing.hpp"
|
||||
#include "util/log.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
#include "util/typedefs.hpp" // EdgeID
|
||||
#ifndef OSRM_GUIDANCE_INTERSECTION_HPP_
|
||||
#define OSRM_GUIDANCE_INTERSECTION_HPP_
|
||||
|
||||
#include "extractor/intersection/intersection_view.hpp"
|
||||
#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 extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
// 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) {
|
||||
return util::angularDeviation(lhs.angle, angle) < util::angularDeviation(rhs.angle, angle);
|
||||
};
|
||||
}
|
||||
|
||||
inline auto makeExtractLanesForRoad(const util::NodeBasedDynamicGraph &node_based_graph)
|
||||
{
|
||||
return [&node_based_graph](const auto &road) {
|
||||
return node_based_graph.GetEdgeData(road.eid).road_classification.GetNumberOfLanes();
|
||||
};
|
||||
}
|
||||
|
||||
// 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
|
||||
{
|
||||
IntersectionViewData(const IntersectionShapeData &shape,
|
||||
const bool entry_allowed,
|
||||
const double angle)
|
||||
: IntersectionShapeData(shape), entry_allowed(entry_allowed), angle(angle)
|
||||
{
|
||||
}
|
||||
|
||||
bool entry_allowed;
|
||||
double angle;
|
||||
|
||||
bool CompareByAngle(const IntersectionViewData &other) const;
|
||||
};
|
||||
|
||||
// A Connected Road is the internal representation of a potential turn. Internally, we require
|
||||
// full list of all connected roads to determine the outcome.
|
||||
// The reasoning behind is that even invalid turns can influence the perceived angles, or even
|
||||
@@ -95,9 +29,9 @@ struct IntersectionViewData : IntersectionShapeData
|
||||
// aaaaaaaa
|
||||
//
|
||||
// We would perceive a->c as a sharp turn, a->b as a slight turn, and b->c as a slight turn.
|
||||
struct ConnectedRoad final : IntersectionViewData
|
||||
struct ConnectedRoad final : extractor::intersection::IntersectionViewData
|
||||
{
|
||||
ConnectedRoad(const IntersectionViewData &view,
|
||||
ConnectedRoad(const extractor::intersection::IntersectionViewData &view,
|
||||
const TurnInstruction instruction,
|
||||
const LaneDataID lane_data_id)
|
||||
: IntersectionViewData(view), instruction(instruction), lane_data_id(lane_data_id)
|
||||
@@ -111,187 +45,34 @@ struct ConnectedRoad final : IntersectionViewData
|
||||
bool compareByAngle(const ConnectedRoad &other) const;
|
||||
|
||||
// make a left turn into an equivalent right turn and vice versa
|
||||
void mirror();
|
||||
void mirror()
|
||||
{
|
||||
const constexpr DirectionModifier::Enum mirrored_modifiers[] = {
|
||||
DirectionModifier::UTurn,
|
||||
DirectionModifier::SharpLeft,
|
||||
DirectionModifier::Left,
|
||||
DirectionModifier::SlightLeft,
|
||||
DirectionModifier::Straight,
|
||||
DirectionModifier::SlightRight,
|
||||
DirectionModifier::Right,
|
||||
DirectionModifier::SharpRight};
|
||||
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
ConnectedRoad getMirroredCopy() const;
|
||||
static_assert(
|
||||
sizeof(mirrored_modifiers) / sizeof(DirectionModifier::Enum) ==
|
||||
DirectionModifier::MaxDirectionModifier,
|
||||
"The list of mirrored modifiers needs to match the available modifiers in size.");
|
||||
|
||||
if (util::angularDeviation(angle, 0) > std::numeric_limits<double>::epsilon())
|
||||
{
|
||||
angle = 360 - angle;
|
||||
instruction.direction_modifier = mirrored_modifiers[instruction.direction_modifier];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// small helper function to print the content of a connected road
|
||||
std::string toString(const IntersectionShapeData &shape);
|
||||
std::string toString(const IntersectionViewData &view);
|
||||
std::string toString(const ConnectedRoad &road);
|
||||
|
||||
// Intersections are sorted roads: [0] being the UTurn road, then from sharp right to sharp left.
|
||||
// common operations shared amongst all intersection types
|
||||
template <typename Self> struct EnableShapeOps
|
||||
{
|
||||
// same as closest turn, but for bearings
|
||||
auto FindClosestBearing(double bearing) const
|
||||
{
|
||||
auto comp = makeCompareShapeDataByBearing(bearing);
|
||||
return std::min_element(self()->begin(), self()->end(), comp);
|
||||
}
|
||||
|
||||
// search a given eid in the intersection
|
||||
auto FindEid(const EdgeID eid) const
|
||||
{
|
||||
return boost::range::find_if(*self(), [eid](const auto &road) { return road.eid == eid; });
|
||||
}
|
||||
|
||||
// find the maximum value based on a conversion operator
|
||||
template <typename UnaryProjection> auto FindMaximum(UnaryProjection converter) const
|
||||
{
|
||||
BOOST_ASSERT(!self()->empty());
|
||||
auto initial = converter(self()->front());
|
||||
|
||||
const auto extract_maximal_value = [&initial, converter](const auto &road) {
|
||||
initial = std::max(initial, converter(road));
|
||||
return false;
|
||||
};
|
||||
|
||||
boost::range::find_if(*self(), extract_maximal_value);
|
||||
return initial;
|
||||
}
|
||||
|
||||
// find the maximum value based on a conversion operator and a predefined initial value
|
||||
template <typename UnaryPredicate> auto Count(UnaryPredicate detector) const
|
||||
{
|
||||
BOOST_ASSERT(!self()->empty());
|
||||
return boost::range::count_if(*self(), detector);
|
||||
}
|
||||
|
||||
private:
|
||||
auto self() { return static_cast<Self *>(this); }
|
||||
auto self() const { return static_cast<const Self *>(this); }
|
||||
};
|
||||
|
||||
struct IntersectionShape final : std::vector<IntersectionShapeData>, //
|
||||
EnableShapeOps<IntersectionShape> //
|
||||
{
|
||||
using Base = std::vector<IntersectionShapeData>;
|
||||
};
|
||||
|
||||
// Common operations shared among IntersectionView and Intersections.
|
||||
// Inherit to enable those operations on your compatible type. CRTP pattern.
|
||||
template <typename Self> struct EnableIntersectionOps
|
||||
{
|
||||
// Find the turn whose angle offers the least angular deviation to the specified angle
|
||||
// For turn angles [0, 90, 260] and a query of 180 we return the 260 degree turn.
|
||||
auto findClosestTurn(double angle) const
|
||||
{
|
||||
auto comp = makeCompareAngularDeviation(angle);
|
||||
return boost::range::min_element(*self(), comp);
|
||||
}
|
||||
// returns a non-const_interator
|
||||
auto findClosestTurn(double angle)
|
||||
{
|
||||
auto comp = makeCompareAngularDeviation(angle);
|
||||
return std::min_element(self()->begin(), self()->end(), comp);
|
||||
}
|
||||
|
||||
/* Check validity of the intersection object. We assume a few basic properties every set of
|
||||
* connected roads should follow throughout guidance pre-processing. This utility function
|
||||
* allows checking intersections for validity
|
||||
*/
|
||||
auto valid() const
|
||||
{
|
||||
if (self()->empty())
|
||||
return false;
|
||||
|
||||
auto comp = [](const auto &lhs, const auto &rhs) { return lhs.CompareByAngle(rhs); };
|
||||
|
||||
const auto ordered = std::is_sorted(self()->begin(), self()->end(), comp);
|
||||
|
||||
if (!ordered)
|
||||
return false;
|
||||
|
||||
const auto uturn = self()->operator[](0).angle < std::numeric_limits<double>::epsilon();
|
||||
|
||||
if (!uturn)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns the UTurn road we took to arrive at this intersection.
|
||||
const auto &getUTurnRoad() const { return self()->operator[](0); }
|
||||
|
||||
// Returns the right-most road at this intersection.
|
||||
const auto &getRightmostRoad() const
|
||||
{
|
||||
return self()->size() > 1 ? self()->operator[](1) : self()->getUTurnRoad();
|
||||
}
|
||||
|
||||
// Returns the left-most road at this intersection.
|
||||
const auto &getLeftmostRoad() const
|
||||
{
|
||||
return self()->size() > 1 ? self()->back() : self()->getUTurnRoad();
|
||||
}
|
||||
|
||||
// Can this be skipped over?
|
||||
auto isTrafficSignalOrBarrier() const { return self()->size() == 2; }
|
||||
|
||||
// Checks if there is at least one road available (except UTurn road) on which to continue.
|
||||
auto isDeadEnd() const
|
||||
{
|
||||
auto pred = [](const auto &road) { return road.entry_allowed; };
|
||||
return std::none_of(self()->begin() + 1, self()->end(), pred);
|
||||
}
|
||||
|
||||
// Returns the number of roads we can enter at this intersection, respectively.
|
||||
auto countEnterable() const
|
||||
{
|
||||
auto pred = [](const auto &road) { return road.entry_allowed; };
|
||||
return boost::range::count_if(*self(), pred);
|
||||
}
|
||||
|
||||
// Returns the number of roads we can not enter at this intersection, respectively.
|
||||
auto countNonEnterable() const { return self()->size() - self()->countEnterable(); }
|
||||
|
||||
// same as find closests turn but with an additional predicate to allow filtering
|
||||
// the filter has to return `true` for elements that should be ignored
|
||||
template <typename UnaryPredicate>
|
||||
auto findClosestTurn(const double angle, const UnaryPredicate filter) const
|
||||
{
|
||||
BOOST_ASSERT(!self()->empty());
|
||||
const auto candidate =
|
||||
boost::range::min_element(*self(), [angle, &filter](const auto &lhs, const auto &rhs) {
|
||||
const auto filtered_lhs = filter(lhs), filtered_rhs = filter(rhs);
|
||||
const auto deviation_lhs = util::angularDeviation(lhs.angle, angle),
|
||||
deviation_rhs = util::angularDeviation(rhs.angle, angle);
|
||||
return std::tie(filtered_lhs, deviation_lhs) <
|
||||
std::tie(filtered_rhs, deviation_rhs);
|
||||
});
|
||||
|
||||
// make sure only to return valid elements
|
||||
return filter(*candidate) ? self()->end() : candidate;
|
||||
}
|
||||
|
||||
// check if all roads between begin and end allow entry
|
||||
template <typename InputIt>
|
||||
bool hasAllValidEntries(const InputIt begin, const InputIt end) const
|
||||
{
|
||||
static_assert(
|
||||
std::is_base_of<std::input_iterator_tag,
|
||||
typename std::iterator_traits<InputIt>::iterator_category>::value,
|
||||
"hasAllValidEntries() only accepts input iterators");
|
||||
return std::all_of(
|
||||
begin, end, [](const IntersectionViewData &road) { return road.entry_allowed; });
|
||||
}
|
||||
|
||||
private:
|
||||
auto self() { return static_cast<Self *>(this); }
|
||||
auto self() const { return static_cast<const Self *>(this); }
|
||||
};
|
||||
|
||||
struct IntersectionView final : std::vector<IntersectionViewData>, //
|
||||
EnableShapeOps<IntersectionView>, //
|
||||
EnableIntersectionOps<IntersectionView> //
|
||||
{
|
||||
using Base = std::vector<IntersectionViewData>;
|
||||
};
|
||||
|
||||
// `Intersection` is a relative view of an intersection by an incoming edge.
|
||||
// `Intersection` are streets at an intersection stored as an ordered list of connected roads
|
||||
// ordered from sharp right counter-clockwise to
|
||||
@@ -317,15 +98,31 @@ struct IntersectionView final : std::vector<IntersectionViewData>, //
|
||||
// intersec := intersection
|
||||
// nbh := node_based_graph
|
||||
//
|
||||
struct Intersection final : std::vector<ConnectedRoad>, //
|
||||
EnableShapeOps<Intersection>, //
|
||||
EnableIntersectionOps<Intersection> //
|
||||
struct Intersection final : std::vector<ConnectedRoad>, //
|
||||
extractor::intersection::EnableShapeOps<Intersection>, //
|
||||
extractor::intersection::EnableIntersectionOps<Intersection> //
|
||||
{
|
||||
using Base = std::vector<ConnectedRoad>;
|
||||
};
|
||||
|
||||
inline std::string toString(const ConnectedRoad &road)
|
||||
{
|
||||
std::string result = "[connection] ";
|
||||
result += std::to_string(road.eid);
|
||||
result += " allows entry: ";
|
||||
result += std::to_string(road.entry_allowed);
|
||||
result += " angle: ";
|
||||
result += std::to_string(road.angle);
|
||||
result += " bearing: ";
|
||||
result += std::to_string(road.bearing);
|
||||
result += " instruction: ";
|
||||
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.lane_data_id));
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /*OSRM_EXTRACTOR_GUIDANCE_INTERSECTION_HPP_*/
|
||||
#endif /* OSRM_GUIDANCE_INTERSECTION_HPP_*/
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_INTERSECTION_HANDLER_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_INTERSECTION_HANDLER_HPP_
|
||||
#ifndef OSRM_GUIDANCE_INTERSECTION_HANDLER_HPP_
|
||||
#define OSRM_GUIDANCE_INTERSECTION_HANDLER_HPP_
|
||||
|
||||
#include "extractor/intersection/intersection_analysis.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "extractor/intersection/node_based_graph_walker.hpp"
|
||||
#include "extractor/suffix_table.hpp"
|
||||
#include "guidance/constants.hpp"
|
||||
#include "guidance/intersection.hpp"
|
||||
#include "guidance/node_based_graph_walker.hpp"
|
||||
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/guidance/name_announcements.hpp"
|
||||
@@ -21,8 +21,6 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
@@ -33,14 +31,14 @@ class IntersectionHandler
|
||||
{
|
||||
public:
|
||||
IntersectionHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const extractor::EdgeBasedNodeDataContainer &node_data_container,
|
||||
const std::vector<util::Coordinate> &node_coordinates,
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries,
|
||||
const RestrictionMap &node_restriction_map,
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
const extractor::SuffixTable &street_name_suffix_table);
|
||||
|
||||
virtual ~IntersectionHandler() = default;
|
||||
|
||||
@@ -54,15 +52,16 @@ class IntersectionHandler
|
||||
|
||||
protected:
|
||||
const util::NodeBasedDynamicGraph &node_based_graph;
|
||||
const EdgeBasedNodeDataContainer &node_data_container;
|
||||
const extractor::EdgeBasedNodeDataContainer &node_data_container;
|
||||
const std::vector<util::Coordinate> &node_coordinates;
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries;
|
||||
const RestrictionMap &node_restriction_map;
|
||||
const extractor::RestrictionMap &node_restriction_map;
|
||||
const std::unordered_set<NodeID> &barrier_nodes;
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data;
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data;
|
||||
const util::NameTable &name_table;
|
||||
const SuffixTable &street_name_suffix_table;
|
||||
const NodeBasedGraphWalker graph_walker; // for skipping traffic signal, distances etc.
|
||||
const extractor::SuffixTable &street_name_suffix_table;
|
||||
const extractor::intersection::NodeBasedGraphWalker
|
||||
graph_walker; // for skipping traffic signal, distances etc.
|
||||
|
||||
// Decide on a basic turn types
|
||||
TurnType::Enum findBasicTurnType(const EdgeID via_edge, const ConnectedRoad &candidate) const;
|
||||
@@ -101,8 +100,8 @@ class IntersectionHandler
|
||||
// See `getNextIntersection`
|
||||
struct IntersectionViewAndNode final
|
||||
{
|
||||
IntersectionView intersection; // < actual intersection
|
||||
NodeID node; // < node at this intersection
|
||||
extractor::intersection::IntersectionView intersection; // < actual intersection
|
||||
NodeID node; // < node at this intersection
|
||||
};
|
||||
|
||||
// Skips over artificial intersections i.e. traffic lights, barriers etc.
|
||||
@@ -153,7 +152,7 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
|
||||
double best_continue_deviation = 180;
|
||||
|
||||
/* helper functions */
|
||||
const auto IsContinueRoad = [&](const NodeBasedEdgeAnnotation &way_data) {
|
||||
const auto IsContinueRoad = [&](const extractor::NodeBasedEdgeAnnotation &way_data) {
|
||||
return !util::guidance::requiresNameAnnounced(
|
||||
in_way_data.name_id, way_data.name_id, name_table, street_name_suffix_table);
|
||||
};
|
||||
@@ -571,20 +570,20 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
|
||||
// even reverse the direction. Since we don't want to compute actual turns but simply
|
||||
// try to find whether there is a turn going to the opposite direction of our obvious
|
||||
// turn, this should be alright.
|
||||
const auto previous_intersection = [&]() -> IntersectionView {
|
||||
const auto parameters = intersection::skipDegreeTwoNodes(
|
||||
const auto previous_intersection = [&]() -> extractor::intersection::IntersectionView {
|
||||
const auto parameters = extractor::intersection::skipDegreeTwoNodes(
|
||||
node_based_graph, {node_at_intersection, intersection[0].eid});
|
||||
if (node_based_graph.GetTarget(parameters.edge) == node_at_intersection)
|
||||
return {};
|
||||
|
||||
return intersection::getConnectedRoads<false>(node_based_graph,
|
||||
node_data_container,
|
||||
node_coordinates,
|
||||
compressed_geometries,
|
||||
node_restriction_map,
|
||||
barrier_nodes,
|
||||
turn_lanes_data,
|
||||
parameters);
|
||||
return extractor::intersection::getConnectedRoads<false>(node_based_graph,
|
||||
node_data_container,
|
||||
node_coordinates,
|
||||
compressed_geometries,
|
||||
node_restriction_map,
|
||||
barrier_nodes,
|
||||
turn_lanes_data,
|
||||
parameters);
|
||||
}();
|
||||
|
||||
if (!previous_intersection.empty())
|
||||
@@ -615,7 +614,6 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /*OSRM_EXTRACTOR_GUIDANCE_INTERSECTION_HANDLER_HPP_*/
|
||||
#endif /*OSRM_GUIDANCE_INTERSECTION_HANDLER_HPP_*/
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_IS_THROUGH_STREET_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_IS_THROUGH_STREET_HPP_
|
||||
#ifndef OSRM_GUIDANCE_IS_THROUGH_STREET_HPP_
|
||||
#define OSRM_GUIDANCE_IS_THROUGH_STREET_HPP_
|
||||
|
||||
#include "guidance/constants.hpp"
|
||||
|
||||
#include "extractor/intersection/have_identical_names.hpp"
|
||||
#include "extractor/node_data_container.hpp"
|
||||
#include "extractor/suffix_table.hpp"
|
||||
|
||||
#include "util/guidance/name_announcements.hpp"
|
||||
|
||||
using osrm::util::angularDeviation;
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
@@ -18,10 +18,11 @@ template <typename IntersectionType>
|
||||
inline bool isThroughStreet(const std::size_t index,
|
||||
const IntersectionType &intersection,
|
||||
const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const extractor::EdgeBasedNodeDataContainer &node_data_container,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table)
|
||||
const extractor::SuffixTable &street_name_suffix_table)
|
||||
{
|
||||
using osrm::util::angularDeviation;
|
||||
|
||||
const auto &data_at_index = node_data_container.GetAnnotation(
|
||||
node_based_graph.GetEdgeData(intersection[index].eid).annotation_data);
|
||||
@@ -43,7 +44,7 @@ inline bool isThroughStreet(const std::size_t index,
|
||||
const bool is_nearly_straight = angularDeviation(road.angle, intersection[index].angle) >
|
||||
(STRAIGHT_ANGLE - FUZZY_ANGLE_DIFFERENCE);
|
||||
|
||||
const bool have_same_name = HaveIdenticalNames(
|
||||
const bool have_same_name = extractor::intersection::HaveIdenticalNames(
|
||||
data_at_index.name_id, road_data.name_id, name_table, street_name_suffix_table);
|
||||
|
||||
const bool have_same_category =
|
||||
@@ -57,7 +58,6 @@ inline bool isThroughStreet(const std::size_t index,
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /*OSRM_EXTRACTOR_GUIDANCE_IS_THROUGH_STREET_HPP_*/
|
||||
#endif /*OSRM_GUIDANCE_IS_THROUGH_STREET_HPP_*/
|
||||
|
||||
@@ -1,184 +0,0 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_MERGEABLE_ROADS
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_MERGEABLE_ROADS
|
||||
|
||||
#include "extractor/compressed_edge_container.hpp"
|
||||
#include "extractor/restriction_index.hpp"
|
||||
#include "guidance/have_identical_names.hpp"
|
||||
#include "guidance/coordinate_extractor.hpp"
|
||||
#include "guidance/intersection.hpp"
|
||||
#include "guidance/turn_lane_types.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
|
||||
// FWD declarations
|
||||
namespace util
|
||||
{
|
||||
class NameTable;
|
||||
} // namespace util
|
||||
|
||||
namespace extractor
|
||||
{
|
||||
|
||||
class SuffixTable;
|
||||
|
||||
namespace guidance
|
||||
{
|
||||
class IntersectionGenerator;
|
||||
class CoordinateExtractor;
|
||||
|
||||
class MergableRoadDetector
|
||||
{
|
||||
public:
|
||||
// in case we have to change the mode we are operating on
|
||||
using MergableRoadData = IntersectionShapeData;
|
||||
|
||||
MergableRoadDetector(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const std::vector<util::Coordinate> &node_coordinates,
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries,
|
||||
const RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
|
||||
// OSM ways tend to be modelled as separate ways for different directions. This is often due to
|
||||
// small gras strips in the middle between the two directions or due to pedestrian islands at
|
||||
// intersections.
|
||||
//
|
||||
// To reduce unnecessary information due to these artificial intersections (which are not
|
||||
// actually perceived as such) we try and merge these for our internal representation to both
|
||||
// get better perceived turn angles and get a better reprsentation of our intersections in
|
||||
// general.
|
||||
//
|
||||
// i h i,h
|
||||
// | | |
|
||||
// | | |
|
||||
// b - - - v - - - g |
|
||||
// > a < is transformed into: b,c - - - a - - - g,f
|
||||
// c - - - ^ - - - f |
|
||||
// | | |
|
||||
// | | |
|
||||
// d e d,e
|
||||
bool CanMergeRoad(const NodeID intersection_node,
|
||||
const MergableRoadData &lhs,
|
||||
const MergableRoadData &rhs) const;
|
||||
|
||||
// check if a road cannot influence the merging of the other. This is necessary to prevent
|
||||
// situations with more than two roads that could participate in a merge
|
||||
bool IsDistinctFrom(const MergableRoadData &lhs, const MergableRoadData &rhs) const;
|
||||
|
||||
private:
|
||||
// When it comes to merging roads, we need to find out if two ways actually represent the
|
||||
// same road. This check tries to identify roads which are the same road in opposite directions
|
||||
bool EdgeDataSupportsMerge(const NodeBasedEdgeClassification &lhs_flags,
|
||||
const NodeBasedEdgeClassification &rhs_flags,
|
||||
const NodeBasedEdgeAnnotation &lhs_edge_annotation,
|
||||
const NodeBasedEdgeAnnotation &rhs_edge_annotation) const;
|
||||
|
||||
// Detect traffic loops.
|
||||
// Since OSRM cannot handle loop edges, we cannot directly see a connection between a node and
|
||||
// itself. We need to skip at least a single node in between.
|
||||
bool IsTrafficLoop(const NodeID intersection_node, const MergableRoadData &road) const;
|
||||
|
||||
// Detector to check if we are looking at roads splitting up just prior to entering an
|
||||
// intersection:
|
||||
//
|
||||
// c
|
||||
// / |
|
||||
// a -< |
|
||||
// \ |
|
||||
// b
|
||||
//
|
||||
// A common scheme in OSRM is that roads spit up in separate ways when approaching an
|
||||
// intersection. This detector tries to detect these narrow triangles which usually just offer a
|
||||
// small island for pedestrians in the middle.
|
||||
bool IsNarrowTriangle(const NodeID intersection_node,
|
||||
const MergableRoadData &lhs,
|
||||
const MergableRoadData &rhs) const;
|
||||
|
||||
// Detector to check for whether two roads are following the same direction.
|
||||
// If roads don't end up right at a connected intersection, we could look at a situation like
|
||||
//
|
||||
// __________________________
|
||||
// /
|
||||
// ---
|
||||
// \__________________________
|
||||
//
|
||||
// This detector tries to find out about whether two roads are parallel after the separation
|
||||
bool HaveSameDirection(const NodeID intersection_node,
|
||||
const MergableRoadData &lhs,
|
||||
const MergableRoadData &rhs) const;
|
||||
|
||||
// Detector for small traffic islands. If a road is splitting up, just to connect again later,
|
||||
// we don't wan't to have this information within our list of intersections/possible turn
|
||||
// locations.
|
||||
//
|
||||
// ___________
|
||||
// ---<___________>-----
|
||||
//
|
||||
//
|
||||
// Would feel just like a single straight road to a driver and should be represented as such in
|
||||
// our engine
|
||||
bool IsTrafficIsland(const NodeID intersection_node,
|
||||
const MergableRoadData &lhs,
|
||||
const MergableRoadData &rhs) const;
|
||||
|
||||
// A negative detector, preventing a merge, trying to detect link roads between two main roads.
|
||||
//
|
||||
// d - - - - - - - - e - f
|
||||
// . / '
|
||||
// a - - - b - - - - - - c
|
||||
//
|
||||
// The detector wants to prevent merges that are connected to `b-e`
|
||||
bool IsLinkRoad(const NodeID intersection_node, const MergableRoadData &road) const;
|
||||
|
||||
// The condition suppresses roads merging for intersections like
|
||||
// . .
|
||||
// . .
|
||||
// ---- ----
|
||||
// . .
|
||||
// . .
|
||||
// but will allow roads merging for intersections like
|
||||
// -------
|
||||
// / \
|
||||
// ---- ----
|
||||
// \ /
|
||||
// -------
|
||||
bool IsCircularShape(const NodeID intersection_node,
|
||||
const MergableRoadData &lhs,
|
||||
const MergableRoadData &rhs) const;
|
||||
|
||||
const util::NodeBasedDynamicGraph &node_based_graph;
|
||||
const EdgeBasedNodeDataContainer &node_data_container;
|
||||
const std::vector<util::Coordinate> &node_coordinates;
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries;
|
||||
const RestrictionMap &node_restriction_map;
|
||||
const std::unordered_set<NodeID> &barrier_nodes;
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data;
|
||||
|
||||
// name detection
|
||||
const util::NameTable &name_table;
|
||||
const SuffixTable &street_name_suffix_table;
|
||||
|
||||
const CoordinateExtractor coordinate_extractor;
|
||||
|
||||
// limit for detecting circles / parallel roads
|
||||
const static double constexpr distance_to_extract = 120;
|
||||
};
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_MOTORWAY_HANDLER_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_MOTORWAY_HANDLER_HPP_
|
||||
#ifndef OSRM_GUIDANCE_MOTORWAY_HANDLER_HPP_
|
||||
#define OSRM_GUIDANCE_MOTORWAY_HANDLER_HPP_
|
||||
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "guidance/intersection.hpp"
|
||||
#include "guidance/intersection_handler.hpp"
|
||||
#include "guidance/is_through_street.hpp"
|
||||
@@ -14,8 +13,6 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
@@ -24,14 +21,14 @@ class MotorwayHandler : public IntersectionHandler
|
||||
{
|
||||
public:
|
||||
MotorwayHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const extractor::EdgeBasedNodeDataContainer &node_data_container,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries,
|
||||
const RestrictionMap &node_restriction_map,
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
const extractor::SuffixTable &street_name_suffix_table);
|
||||
|
||||
~MotorwayHandler() override final = default;
|
||||
|
||||
@@ -61,7 +58,6 @@ class MotorwayHandler : public IntersectionHandler
|
||||
};
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /*OSRM_EXTRACTOR_GUIDANCE_MOTORWAY_HANDLER_HPP_*/
|
||||
#endif /*OSRM_GUIDANCE_MOTORWAY_HANDLER_HPP_*/
|
||||
|
||||
@@ -1,318 +0,0 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_NODE_BASED_GRAPH_WALKER
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_NODE_BASED_GRAPH_WALKER
|
||||
|
||||
#include "extractor/intersection/intersection_analysis.hpp"
|
||||
#include "guidance/constants.hpp"
|
||||
#include "guidance/coordinate_extractor.hpp"
|
||||
#include "guidance/turn_lane_data.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
/*
|
||||
* The graph hopper is a utility that lets you find certain intersections with a node based graph,
|
||||
* accumulating information along the way
|
||||
*/
|
||||
class NodeBasedGraphWalker
|
||||
{
|
||||
public:
|
||||
NodeBasedGraphWalker(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const std::vector<util::Coordinate> &node_coordinates,
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries,
|
||||
const RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data);
|
||||
|
||||
/*
|
||||
* the returned node-id, edge-id are either the last ones used, just prior accumulator
|
||||
* terminating or empty if the traversal ran into a dead end. For examples of the
|
||||
* selector/accumulator look below. You can find an example for both (and the required interface
|
||||
* description). The function returns the last used `NodeID` and `EdgeID` (node just prior to
|
||||
* the last intersection and the edge it was reached by), if it wasn't stopped early (e.g. the
|
||||
* selector not provinding any further edge to traverse)
|
||||
*/
|
||||
template <class accumulator_type, class selector_type>
|
||||
boost::optional<std::pair<NodeID, EdgeID>> TraverseRoad(NodeID starting_at_node_id,
|
||||
EdgeID following_edge_id,
|
||||
accumulator_type &accumulator,
|
||||
const selector_type &selector) const;
|
||||
|
||||
private:
|
||||
const util::NodeBasedDynamicGraph &node_based_graph;
|
||||
const EdgeBasedNodeDataContainer &node_data_container;
|
||||
const std::vector<util::Coordinate> &node_coordinates;
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries;
|
||||
const RestrictionMap &node_restriction_map;
|
||||
const std::unordered_set<NodeID> &barrier_nodes;
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data;
|
||||
};
|
||||
|
||||
/*
|
||||
* Accumulate all coordinates following a road until we
|
||||
* Example of a possible accumulator for walking a node-based graph
|
||||
*/
|
||||
struct LengthLimitedCoordinateAccumulator
|
||||
{
|
||||
LengthLimitedCoordinateAccumulator(
|
||||
const extractor::guidance::CoordinateExtractor &coordinate_extractor,
|
||||
const double max_length);
|
||||
|
||||
/*
|
||||
* !! REQUIRED - Function for the use of TraverseRoad in the graph walker.
|
||||
* Terminate should return true if the last intersection given to accumulator is supposed to
|
||||
* stop the search. A typical example would be to find the next intersection with degree larger
|
||||
* than 2 (an actual intersection). Here you should return true if the last intersection you
|
||||
* looked at was of degree larger than 2.
|
||||
*/
|
||||
bool terminate(); // true if the path has traversed enough distance
|
||||
|
||||
/*
|
||||
* !! REQUIRED - Function for the use of TraverseRoad in the graph walker.
|
||||
* starting with the very first provided node and edge, the graph walker will call `update` on
|
||||
* your accumulator. Here you can choose to accumulate any data that you might want to collect /
|
||||
* update your termination criteria. The accumulator described here will extract the coordinates
|
||||
* that we see traversing `via_edge` and store them for later usage.
|
||||
*/
|
||||
void update(const NodeID from_node, const EdgeID via_edge, const NodeID to_node);
|
||||
|
||||
double accumulated_length = 0;
|
||||
std::vector<util::Coordinate> coordinates;
|
||||
|
||||
private:
|
||||
const extractor::guidance::CoordinateExtractor &coordinate_extractor;
|
||||
const double max_length;
|
||||
};
|
||||
|
||||
/*
|
||||
* The SelectRoadByNameOnlyChoiceAndStraightness tries to follow a given name along a route. We
|
||||
* offer methods to skip
|
||||
* over bridges/similar situations if desired, following narrow turns
|
||||
* This struct offers an example implementation of a possible road selector for traversing the
|
||||
* node-based graph using the NodeBasedGraphWalker
|
||||
*/
|
||||
struct SelectRoadByNameOnlyChoiceAndStraightness
|
||||
{
|
||||
SelectRoadByNameOnlyChoiceAndStraightness(const NameID desired_name_id,
|
||||
const bool requires_entry);
|
||||
|
||||
/*
|
||||
* !! REQUIRED - Function for the use of TraverseRoad in the graph walker.
|
||||
* The operator() needs to return (if any is found) the next road to continue in the graph
|
||||
* traversal. If no such edge is found, return {} is allowed. Usually you want to choose some
|
||||
* form of obious turn to follow.
|
||||
*/
|
||||
boost::optional<EdgeID> operator()(const NodeID nid,
|
||||
const EdgeID via_edge_id,
|
||||
const IntersectionView &intersection,
|
||||
const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container) const;
|
||||
|
||||
private:
|
||||
const NameID desired_name_id;
|
||||
const bool requires_entry;
|
||||
};
|
||||
|
||||
/* Following only a straight road
|
||||
* Follow only the straightmost turn, as long as its the only choice or has the desired name
|
||||
*/
|
||||
struct SelectStraightmostRoadByNameAndOnlyChoice
|
||||
{
|
||||
SelectStraightmostRoadByNameAndOnlyChoice(const NameID desired_name_id,
|
||||
const double initial_bearing,
|
||||
const bool requires_entry,
|
||||
const bool stop_on_ambiguous_turns);
|
||||
|
||||
/*
|
||||
* !! REQUIRED - Function for the use of TraverseRoad in the graph walker.
|
||||
* The operator() needs to return (if any is found) the next road to continue in the graph
|
||||
* traversal. If no such edge is found, return {} is allowed. Usually you want to choose some
|
||||
* form of obious turn to follow.
|
||||
*/
|
||||
boost::optional<EdgeID> operator()(const NodeID nid,
|
||||
const EdgeID via_edge_id,
|
||||
const IntersectionView &intersection,
|
||||
const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container) const;
|
||||
|
||||
private:
|
||||
const NameID desired_name_id;
|
||||
const double initial_bearing;
|
||||
const bool requires_entry;
|
||||
const bool stop_on_ambiguous_turns;
|
||||
};
|
||||
|
||||
// find the next intersection given a hop limit
|
||||
struct IntersectionFinderAccumulator
|
||||
{
|
||||
IntersectionFinderAccumulator(const std::uint8_t hop_limit,
|
||||
const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const std::vector<util::Coordinate> &node_coordinates,
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries,
|
||||
const RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data);
|
||||
// true if the path has traversed enough distance
|
||||
bool terminate();
|
||||
|
||||
// update the accumulator
|
||||
void update(const NodeID from_node, const EdgeID via_edge, const NodeID to_node);
|
||||
|
||||
std::uint8_t hops;
|
||||
const std::uint8_t hop_limit;
|
||||
|
||||
// the result we are looking for
|
||||
NodeID nid;
|
||||
EdgeID via_edge_id;
|
||||
IntersectionView intersection;
|
||||
|
||||
private:
|
||||
const util::NodeBasedDynamicGraph &node_based_graph;
|
||||
const EdgeBasedNodeDataContainer &node_data_container;
|
||||
const std::vector<util::Coordinate> &node_coordinates;
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries;
|
||||
const RestrictionMap &node_restriction_map;
|
||||
const std::unordered_set<NodeID> &barrier_nodes;
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data;
|
||||
};
|
||||
|
||||
template <class accumulator_type, class selector_type>
|
||||
boost::optional<std::pair<NodeID, EdgeID>>
|
||||
NodeBasedGraphWalker::TraverseRoad(NodeID current_node_id,
|
||||
EdgeID current_edge_id,
|
||||
accumulator_type &accumulator,
|
||||
const selector_type &selector) const
|
||||
{
|
||||
/*
|
||||
* since graph hopping is used in many ways, we don't generate an adjusted intersection
|
||||
* (otherwise we could end up in infinite recursion if we call the graph hopper during the
|
||||
* adjustment itself). Relying only on `GetConnectedRoads` (which itself does no graph hopping),
|
||||
* we prevent this from happening.
|
||||
*/
|
||||
const auto stop_node_id = current_node_id;
|
||||
/* we wan't to put out the last valid entries. To do so, we need to update within the following
|
||||
* loop. We use a for loop since traversal of the node-based-graph is expensive and we don't
|
||||
* want to look at many coordinates. If you require more than 2/3 intersections down the road,
|
||||
* you are doing something wrong/unsupported by OSRM. To not fail hard in cases that offer
|
||||
* strange loop contractions, we restrict ourselves to an extremely large number of possible
|
||||
* steps and simply warn in cases were extraction runs into these limits.
|
||||
*/
|
||||
for (std::size_t safety_hop_limit = 0; safety_hop_limit < 1000; ++safety_hop_limit)
|
||||
{
|
||||
accumulator.update(
|
||||
current_node_id, current_edge_id, node_based_graph.GetTarget(current_edge_id));
|
||||
|
||||
// we have looped back to our initial intersection
|
||||
if (node_based_graph.GetTarget(current_edge_id) == stop_node_id)
|
||||
return {};
|
||||
|
||||
// look at the next intersection
|
||||
const auto next_intersection =
|
||||
intersection::getConnectedRoads<true>(node_based_graph,
|
||||
node_data_container,
|
||||
node_coordinates,
|
||||
compressed_geometries,
|
||||
node_restriction_map,
|
||||
barrier_nodes,
|
||||
turn_lanes_data,
|
||||
{current_node_id, current_edge_id});
|
||||
|
||||
// don't follow u-turns or go past our initial intersection
|
||||
if (next_intersection.size() <= 1)
|
||||
return {};
|
||||
|
||||
auto next_edge_id = selector(current_node_id,
|
||||
current_edge_id,
|
||||
next_intersection,
|
||||
node_based_graph,
|
||||
node_data_container);
|
||||
|
||||
if (!next_edge_id)
|
||||
return {};
|
||||
|
||||
if (accumulator.terminate())
|
||||
return {std::make_pair(current_node_id, current_edge_id)};
|
||||
|
||||
current_node_id = node_based_graph.GetTarget(current_edge_id);
|
||||
current_edge_id = *next_edge_id;
|
||||
}
|
||||
|
||||
BOOST_ASSERT(
|
||||
"Reached safety hop limit. Graph hopper seems to have been caught in an endless loop");
|
||||
return {};
|
||||
}
|
||||
|
||||
struct SkipTrafficSignalBarrierRoadSelector
|
||||
{
|
||||
boost::optional<EdgeID> operator()(const NodeID,
|
||||
const EdgeID,
|
||||
const IntersectionView &intersection,
|
||||
const util::NodeBasedDynamicGraph &,
|
||||
const EdgeBasedNodeDataContainer &) const
|
||||
{
|
||||
if (intersection.isTrafficSignalOrBarrier())
|
||||
{
|
||||
return boost::make_optional(intersection[1].eid);
|
||||
}
|
||||
else
|
||||
{
|
||||
return boost::none;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct DistanceToNextIntersectionAccumulator
|
||||
{
|
||||
DistanceToNextIntersectionAccumulator(
|
||||
const extractor::guidance::CoordinateExtractor &extractor_,
|
||||
const util::NodeBasedDynamicGraph &graph_,
|
||||
const double threshold)
|
||||
: extractor{extractor_}, graph{graph_}, threshold{threshold}
|
||||
{
|
||||
}
|
||||
|
||||
bool terminate()
|
||||
{
|
||||
if (distance > threshold)
|
||||
{
|
||||
too_far_away = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void update(const NodeID start, const EdgeID onto, const NodeID)
|
||||
{
|
||||
using namespace util::coordinate_calculation;
|
||||
|
||||
const auto coords = extractor.GetForwardCoordinatesAlongRoad(start, onto);
|
||||
distance += getLength(coords.begin(), coords.end(), &haversineDistance);
|
||||
}
|
||||
|
||||
const extractor::guidance::CoordinateExtractor &extractor;
|
||||
const util::NodeBasedDynamicGraph &graph;
|
||||
const double threshold;
|
||||
bool too_far_away = false;
|
||||
double distance = 0.;
|
||||
};
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /* OSRM_EXTRACTOR_GUIDANCE_NODE_BASED_GRAPH_WALKER */
|
||||
@@ -1,149 +0,0 @@
|
||||
#ifndef OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_
|
||||
#define OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
#include "guidance/constants.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
// Priorities are used to distinguish between how likely a turn is in comparison to a different
|
||||
// road. The priorities here are used to distinguish between obvious turns (e.g. following a primary
|
||||
// road next to a residential one is obvious). The decision what is obvious is described in the
|
||||
// guidance constants.
|
||||
namespace RoadPriorityClass
|
||||
{
|
||||
typedef std::uint8_t Enum;
|
||||
// Top priority Road
|
||||
const constexpr Enum MOTORWAY = 0;
|
||||
// Second highest priority
|
||||
const constexpr Enum TRUNK = 2;
|
||||
// Main roads
|
||||
const constexpr Enum PRIMARY = 4;
|
||||
const constexpr Enum SECONDARY = 6;
|
||||
const constexpr Enum TERTIARY = 8;
|
||||
// Residential Categories
|
||||
const constexpr Enum MAIN_RESIDENTIAL = 10;
|
||||
const constexpr Enum SIDE_RESIDENTIAL = 11;
|
||||
// Link Category
|
||||
const constexpr Enum LINK_ROAD = 14;
|
||||
// Bike Accessible
|
||||
const constexpr Enum BIKE_PATH = 16;
|
||||
// Walk Accessible
|
||||
const constexpr Enum FOOT_PATH = 18;
|
||||
// Link types are usually not considered in forks, unless amongst each other.
|
||||
// a road simply offered for connectivity. Will be ignored in forks/other decisions. Always
|
||||
// considered non-obvious to continue on
|
||||
const constexpr Enum CONNECTIVITY = 31;
|
||||
} // namespace Road Class
|
||||
|
||||
#pragma pack(push, 1)
|
||||
class RoadClassification
|
||||
{
|
||||
// a class that behaves like a motorway (separated directions)
|
||||
std::uint8_t motorway_class : 1;
|
||||
// all types of link classes
|
||||
std::uint8_t link_class : 1;
|
||||
// a low priority class is a pure connectivity way. It can be ignored in multiple decisions
|
||||
// (e.g. fork on a primary vs service will not happen)
|
||||
std::uint8_t may_be_ignored : 1;
|
||||
// the road priority is used as an indicator for forks. If the roads are of similar priority
|
||||
// (difference <=1), we can see the road as a fork. Else one of the road classes is seen as
|
||||
// obvious choice
|
||||
RoadPriorityClass::Enum road_priority_class : 5;
|
||||
// the number of lanes in the road
|
||||
std::uint8_t number_of_lanes;
|
||||
|
||||
public:
|
||||
// default construction
|
||||
RoadClassification()
|
||||
: motorway_class(0), link_class(0), may_be_ignored(0),
|
||||
road_priority_class(RoadPriorityClass::CONNECTIVITY), number_of_lanes(0)
|
||||
{
|
||||
}
|
||||
|
||||
RoadClassification(bool motorway_class,
|
||||
bool link_class,
|
||||
bool may_be_ignored,
|
||||
RoadPriorityClass::Enum road_priority_class,
|
||||
std::uint8_t number_of_lanes)
|
||||
: motorway_class(motorway_class), link_class(link_class), may_be_ignored(may_be_ignored),
|
||||
road_priority_class(road_priority_class), number_of_lanes(number_of_lanes)
|
||||
{
|
||||
}
|
||||
|
||||
bool IsMotorwayClass() const { return (0 != motorway_class) && (0 == link_class); }
|
||||
void SetMotorwayFlag(const bool new_value) { motorway_class = new_value; }
|
||||
|
||||
bool IsRampClass() const { return (0 != motorway_class) && (0 != link_class); }
|
||||
|
||||
bool IsLinkClass() const { return (0 != link_class); }
|
||||
void SetLinkClass(const bool new_value) { link_class = new_value; }
|
||||
|
||||
bool IsLowPriorityRoadClass() const { return (0 != may_be_ignored); }
|
||||
void SetLowPriorityFlag(const bool new_value) { may_be_ignored = new_value; }
|
||||
|
||||
std::uint8_t GetNumberOfLanes() const { return number_of_lanes; }
|
||||
void SetNumberOfLanes(const std::uint8_t new_value) { number_of_lanes = new_value; }
|
||||
|
||||
std::uint32_t GetPriority() const { return static_cast<std::uint32_t>(road_priority_class); }
|
||||
|
||||
RoadPriorityClass::Enum GetClass() const { return road_priority_class; }
|
||||
void SetClass(const RoadPriorityClass::Enum new_value) { road_priority_class = new_value; }
|
||||
|
||||
bool operator==(const RoadClassification &other) const
|
||||
{
|
||||
return motorway_class == other.motorway_class && link_class == other.link_class &&
|
||||
may_be_ignored == other.may_be_ignored &&
|
||||
road_priority_class == other.road_priority_class;
|
||||
}
|
||||
|
||||
bool operator!=(const RoadClassification &other) const { return !(*this == other); }
|
||||
|
||||
std::string ToString() const
|
||||
{
|
||||
return std::string() + (motorway_class ? "motorway" : "normal") +
|
||||
(link_class ? "_link" : "") + (may_be_ignored ? " ignorable " : " important ") +
|
||||
std::to_string(road_priority_class);
|
||||
}
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
static_assert(
|
||||
sizeof(RoadClassification) == 2,
|
||||
"Road Classification should fit two bytes. Increasing this has a severe impact on memory.");
|
||||
|
||||
inline bool canBeSeenAsFork(const RoadClassification first, const RoadClassification second)
|
||||
{
|
||||
return std::abs(static_cast<int>(first.GetPriority()) -
|
||||
static_cast<int>(second.GetPriority())) <= 1;
|
||||
}
|
||||
|
||||
inline bool obviousByRoadClass(const RoadClassification in_classification,
|
||||
const RoadClassification obvious_candidate,
|
||||
const RoadClassification compare_candidate)
|
||||
{
|
||||
// lower numbers are of higher priority
|
||||
const bool has_high_priority = PRIORITY_DISTINCTION_FACTOR * obvious_candidate.GetPriority() <
|
||||
compare_candidate.GetPriority();
|
||||
|
||||
const bool continues_on_same_class = in_classification == obvious_candidate;
|
||||
return (has_high_priority && continues_on_same_class) ||
|
||||
(!obvious_candidate.IsLowPriorityRoadClass() &&
|
||||
!in_classification.IsLowPriorityRoadClass() &&
|
||||
compare_candidate.IsLowPriorityRoadClass());
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_EXTRACTOR_CLASSIFICATION_DATA_HPP_
|
||||
@@ -1,13 +1,13 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_ROUNDABOUT_HANDLER_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_ROUNDABOUT_HANDLER_HPP_
|
||||
#ifndef OSRM_GUIDANCE_ROUNDABOUT_HANDLER_HPP_
|
||||
#define OSRM_GUIDANCE_ROUNDABOUT_HANDLER_HPP_
|
||||
|
||||
#include "extractor/compressed_edge_container.hpp"
|
||||
#include "extractor/intersection/coordinate_extractor.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "guidance/coordinate_extractor.hpp"
|
||||
#include "guidance/intersection.hpp"
|
||||
#include "guidance/intersection_handler.hpp"
|
||||
#include "guidance/roundabout_type.hpp"
|
||||
#include "guidance/is_through_street.hpp"
|
||||
#include "guidance/roundabout_type.hpp"
|
||||
|
||||
#include "util/name_table.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
@@ -40,14 +38,14 @@ class RoundaboutHandler : public IntersectionHandler
|
||||
{
|
||||
public:
|
||||
RoundaboutHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const extractor::EdgeBasedNodeDataContainer &node_data_container,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries,
|
||||
const RestrictionMap &node_restriction_map,
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
const extractor::SuffixTable &street_name_suffix_table);
|
||||
|
||||
~RoundaboutHandler() override final = default;
|
||||
|
||||
@@ -82,11 +80,10 @@ class RoundaboutHandler : public IntersectionHandler
|
||||
bool
|
||||
qualifiesAsRoundaboutIntersection(const std::unordered_set<NodeID> &roundabout_nodes) const;
|
||||
|
||||
const CoordinateExtractor coordinate_extractor;
|
||||
const extractor::intersection::CoordinateExtractor coordinate_extractor;
|
||||
};
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /*OSRM_EXTRACTOR_GUIDANCE_ROUNDABOUT_HANDLER_HPP_*/
|
||||
#endif /*OSRM_GUIDANCE_ROUNDABOUT_HANDLER_HPP_*/
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_ROUNDABOUT_TYPES_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_ROUNDABOUT_TYPES_HPP_
|
||||
#ifndef OSRM_GUIDANCE_ROUNDABOUT_TYPES_HPP_
|
||||
#define OSRM_GUIDANCE_ROUNDABOUT_TYPES_HPP_
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
enum class RoundaboutType
|
||||
@@ -15,7 +13,6 @@ enum class RoundaboutType
|
||||
RoundaboutIntersection // small roundabout with distinct turns, handled as intersection
|
||||
};
|
||||
} /* namespace guidance */
|
||||
} /* namespace extractor */
|
||||
} /* namespace osrm */
|
||||
|
||||
#endif /* OSRM_EXTRACTOR_GUIDANCE_ROUNDABOUT_TYPES_HPP_ */
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef OSRM_GUIDANCE_IO_HPP
|
||||
#define OSRM_GUIDANCE_IO_HPP
|
||||
|
||||
#include "guidance/turn_data_container.hpp"
|
||||
|
||||
#include "storage/io.hpp"
|
||||
#include "storage/serialization.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
namespace serialization
|
||||
{
|
||||
|
||||
// read/write for turn data file
|
||||
template <storage::Ownership Ownership>
|
||||
inline void read(storage::io::FileReader &reader,
|
||||
guidance::detail::TurnDataContainerImpl<Ownership> &turn_data_container)
|
||||
{
|
||||
storage::serialization::read(reader, turn_data_container.turn_instructions);
|
||||
storage::serialization::read(reader, turn_data_container.lane_data_ids);
|
||||
storage::serialization::read(reader, turn_data_container.entry_class_ids);
|
||||
storage::serialization::read(reader, turn_data_container.pre_turn_bearings);
|
||||
storage::serialization::read(reader, turn_data_container.post_turn_bearings);
|
||||
}
|
||||
|
||||
template <storage::Ownership Ownership>
|
||||
inline void write(storage::io::FileWriter &writer,
|
||||
const guidance::detail::TurnDataContainerImpl<Ownership> &turn_data_container)
|
||||
{
|
||||
storage::serialization::write(writer, turn_data_container.turn_instructions);
|
||||
storage::serialization::write(writer, turn_data_container.lane_data_ids);
|
||||
storage::serialization::write(writer, turn_data_container.entry_class_ids);
|
||||
storage::serialization::write(writer, turn_data_container.pre_turn_bearings);
|
||||
storage::serialization::write(writer, turn_data_container.post_turn_bearings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_SLIPROAD_HANDLER_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_SLIPROAD_HANDLER_HPP_
|
||||
#ifndef OSRM_GUIDANCE_SLIPROAD_HANDLER_HPP_
|
||||
#define OSRM_GUIDANCE_SLIPROAD_HANDLER_HPP_
|
||||
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "guidance/intersection.hpp"
|
||||
#include "guidance/intersection_handler.hpp"
|
||||
#include "guidance/is_through_street.hpp"
|
||||
@@ -15,8 +14,6 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
@@ -25,14 +22,14 @@ class SliproadHandler final : public IntersectionHandler
|
||||
{
|
||||
public:
|
||||
SliproadHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const extractor::EdgeBasedNodeDataContainer &node_data_container,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries,
|
||||
const RestrictionMap &node_restriction_map,
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
const extractor::SuffixTable &street_name_suffix_table);
|
||||
|
||||
~SliproadHandler() override final = default;
|
||||
|
||||
@@ -61,9 +58,9 @@ class SliproadHandler final : public IntersectionHandler
|
||||
bool isValidSliproadArea(const double max_area, const NodeID, const NodeID, const NodeID) const;
|
||||
|
||||
// Is the Sliproad a link the both roads it shortcuts must not be links
|
||||
bool isValidSliproadLink(const IntersectionViewData &sliproad,
|
||||
const IntersectionViewData &first,
|
||||
const IntersectionViewData &second) const;
|
||||
bool isValidSliproadLink(const extractor::intersection::IntersectionViewData &sliproad,
|
||||
const extractor::intersection::IntersectionViewData &first,
|
||||
const extractor::intersection::IntersectionViewData &second) const;
|
||||
|
||||
// check if no mode changes are involved
|
||||
bool allSameMode(const EdgeID in_road,
|
||||
@@ -71,19 +68,19 @@ class SliproadHandler final : public IntersectionHandler
|
||||
const EdgeID target_road) const;
|
||||
|
||||
// Could a Sliproad reach this intersection?
|
||||
static bool canBeTargetOfSliproad(const IntersectionView &intersection);
|
||||
static bool
|
||||
canBeTargetOfSliproad(const extractor::intersection::IntersectionView &intersection);
|
||||
|
||||
// Scales a threshold based on the underlying road classification.
|
||||
// Example: a 100 m threshold for a highway if different on living streets.
|
||||
// The return value is guaranteed to not be larger than `threshold`.
|
||||
static double scaledThresholdByRoadClass(const double max_threshold,
|
||||
const RoadClassification &classification);
|
||||
const extractor::RoadClassification &classification);
|
||||
|
||||
const CoordinateExtractor coordinate_extractor;
|
||||
const extractor::intersection::CoordinateExtractor coordinate_extractor;
|
||||
};
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /*OSRM_EXTRACTOR_GUIDANCE_SLIPROAD_HANDLER_HPP_*/
|
||||
#endif /*OSRM_GUIDANCE_SLIPROAD_HANDLER_HPP_*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_STATISTICS_HANDLER_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_STATISTICS_HANDLER_HPP_
|
||||
#ifndef OSRM_GUIDANCE_STATISTICS_HANDLER_HPP_
|
||||
#define OSRM_GUIDANCE_STATISTICS_HANDLER_HPP_
|
||||
|
||||
#include "guidance/intersection.hpp"
|
||||
#include "guidance/intersection_handler.hpp"
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
@@ -28,14 +26,14 @@ class StatisticsHandler final : public IntersectionHandler
|
||||
{
|
||||
public:
|
||||
StatisticsHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const extractor::EdgeBasedNodeDataContainer &node_data_container,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries,
|
||||
const RestrictionMap &node_restriction_map,
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table)
|
||||
const extractor::SuffixTable &street_name_suffix_table)
|
||||
: IntersectionHandler(node_based_graph,
|
||||
node_data_container,
|
||||
coordinates,
|
||||
@@ -110,7 +108,6 @@ class StatisticsHandler final : public IntersectionHandler
|
||||
};
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_EXTRACTOR_GUIDANCE_VALIDATION_HANDLER_HPP_
|
||||
#endif // OSRM_GUIDANCE_VALIDATION_HANDLER_HPP_
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_SUPPRESS_MODE_HANDLER_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_SUPPRESS_MODE_HANDLER_HPP_
|
||||
#ifndef OSRM_GUIDANCE_SUPPRESS_MODE_HANDLER_HPP_
|
||||
#define OSRM_GUIDANCE_SUPPRESS_MODE_HANDLER_HPP_
|
||||
|
||||
#include "extractor/travel_mode.hpp"
|
||||
#include "guidance/constants.hpp"
|
||||
#include "guidance/intersection.hpp"
|
||||
#include "guidance/intersection_handler.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
@@ -21,14 +17,14 @@ class SuppressModeHandler final : public IntersectionHandler
|
||||
{
|
||||
public:
|
||||
SuppressModeHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const extractor::EdgeBasedNodeDataContainer &node_data_container,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries,
|
||||
const RestrictionMap &node_restriction_map,
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
const extractor::SuffixTable &street_name_suffix_table);
|
||||
|
||||
~SuppressModeHandler() override final = default;
|
||||
|
||||
@@ -41,8 +37,7 @@ class SuppressModeHandler final : public IntersectionHandler
|
||||
Intersection intersection) const override final;
|
||||
};
|
||||
|
||||
} // namespace osrm
|
||||
} // namespace extractor
|
||||
} // namespace guidance
|
||||
} // namespace osrm
|
||||
|
||||
#endif /* OSRM_EXTRACTOR_GUIDANCE_SUPPRESS_MODE_HANDLER_HPP_ */
|
||||
#endif /* OSRM_GUIDANCE_SUPPRESS_MODE_HANDLER_HPP_ */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef OSRM_EXTRACTOR_TURN_ANALYSIS
|
||||
#define OSRM_EXTRACTOR_TURN_ANALYSIS
|
||||
#ifndef OSRM_GUIDANCE_TURN_ANALYSIS
|
||||
#define OSRM_GUIDANCE_TURN_ANALYSIS
|
||||
|
||||
#include "extractor/compressed_edge_container.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "extractor/intersection/intersection_view.hpp"
|
||||
#include "extractor/restriction_index.hpp"
|
||||
#include "extractor/suffix_table.hpp"
|
||||
#include "guidance/driveway_handler.hpp"
|
||||
@@ -30,8 +30,6 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
@@ -39,14 +37,14 @@ class TurnAnalysis
|
||||
{
|
||||
public:
|
||||
TurnAnalysis(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const extractor::EdgeBasedNodeDataContainer &node_data_container,
|
||||
const std::vector<util::Coordinate> &node_coordinates,
|
||||
const CompressedEdgeContainer &compressed_edge_container,
|
||||
const RestrictionMap &restriction_map,
|
||||
const extractor::CompressedEdgeContainer &compressed_edge_container,
|
||||
const extractor::RestrictionMap &restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
const extractor::SuffixTable &street_name_suffix_table);
|
||||
|
||||
/* Full Analysis Process for a single node/edge combination. Use with caution, as the process is
|
||||
* relatively expensive */
|
||||
@@ -56,9 +54,10 @@ class TurnAnalysis
|
||||
|
||||
// Select turn types based on the intersection shape
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
Intersection AssignTurnTypes(const NodeID from_node,
|
||||
const EdgeID via_eid,
|
||||
const IntersectionView &intersection) const;
|
||||
Intersection
|
||||
AssignTurnTypes(const NodeID from_node,
|
||||
const EdgeID via_eid,
|
||||
const extractor::intersection::IntersectionView &intersection) const;
|
||||
|
||||
private:
|
||||
const util::NodeBasedDynamicGraph &node_based_graph;
|
||||
@@ -76,7 +75,6 @@ class TurnAnalysis
|
||||
}; // class TurnAnalysis
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_EXTRACTOR_TURN_ANALYSIS
|
||||
#endif // OSRM_GUIDANCE_TURN_ANALYSIS
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
@@ -20,7 +18,6 @@ std::pair<util::guidance::EntryClass, util::guidance::BearingClass>
|
||||
classifyIntersection(Intersection intersection, const osrm::util::Coordinate &location);
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_GUIDANCE_TURN_CLASSIFICATION_HPP_
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
#ifndef OSRM_GUIDANCE_TURN_DATA_CONTAINER_HPP
|
||||
#define OSRM_GUIDANCE_TURN_DATA_CONTAINER_HPP
|
||||
|
||||
#include "extractor/travel_mode.hpp"
|
||||
#include "guidance/turn_instruction.hpp"
|
||||
|
||||
#include "storage/io_fwd.hpp"
|
||||
#include "storage/shared_memory_ownership.hpp"
|
||||
|
||||
#include "util/guidance/turn_bearing.hpp"
|
||||
#include "util/vector_view.hpp"
|
||||
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <storage::Ownership Ownership> class TurnDataContainerImpl;
|
||||
}
|
||||
|
||||
namespace serialization
|
||||
{
|
||||
template <storage::Ownership Ownership>
|
||||
void read(storage::io::FileReader &reader, detail::TurnDataContainerImpl<Ownership> &turn_data);
|
||||
|
||||
template <storage::Ownership Ownership>
|
||||
void write(storage::io::FileWriter &writer,
|
||||
const detail::TurnDataContainerImpl<Ownership> &turn_data);
|
||||
}
|
||||
|
||||
struct TurnData
|
||||
{
|
||||
guidance::TurnInstruction turn_instruction;
|
||||
LaneDataID lane_data_id;
|
||||
EntryClassID entry_class_id;
|
||||
util::guidance::TurnBearing pre_turn_bearing;
|
||||
util::guidance::TurnBearing post_turn_bearing;
|
||||
};
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <storage::Ownership Ownership> class TurnDataContainerImpl
|
||||
{
|
||||
template <typename T> using Vector = util::ViewOrVector<T, Ownership>;
|
||||
|
||||
public:
|
||||
TurnDataContainerImpl() = default;
|
||||
|
||||
TurnDataContainerImpl(Vector<guidance::TurnInstruction> turn_instructions,
|
||||
Vector<LaneDataID> lane_data_ids,
|
||||
Vector<EntryClassID> entry_class_ids,
|
||||
Vector<util::guidance::TurnBearing> pre_turn_bearings,
|
||||
Vector<util::guidance::TurnBearing> post_turn_bearings)
|
||||
: turn_instructions(std::move(turn_instructions)), lane_data_ids(std::move(lane_data_ids)),
|
||||
entry_class_ids(std::move(entry_class_ids)),
|
||||
pre_turn_bearings(std::move(pre_turn_bearings)),
|
||||
post_turn_bearings(std::move(post_turn_bearings))
|
||||
{
|
||||
}
|
||||
|
||||
EntryClassID GetEntryClassID(const EdgeID id) const { return entry_class_ids[id]; }
|
||||
|
||||
util::guidance::TurnBearing GetPreTurnBearing(const EdgeID id) const
|
||||
{
|
||||
return pre_turn_bearings[id];
|
||||
}
|
||||
|
||||
util::guidance::TurnBearing GetPostTurnBearing(const EdgeID id) const
|
||||
{
|
||||
return post_turn_bearings[id];
|
||||
}
|
||||
|
||||
LaneDataID GetLaneDataID(const EdgeID id) const { return lane_data_ids[id]; }
|
||||
|
||||
bool HasLaneData(const EdgeID id) const { return INVALID_LANE_DATAID != lane_data_ids[id]; }
|
||||
|
||||
guidance::TurnInstruction GetTurnInstruction(const EdgeID id) const
|
||||
{
|
||||
return turn_instructions[id];
|
||||
}
|
||||
|
||||
// Used by EdgeBasedGraphFactory to fill data structure
|
||||
template <typename = std::enable_if<Ownership == storage::Ownership::Container>>
|
||||
void push_back(const TurnData &data)
|
||||
{
|
||||
turn_instructions.push_back(data.turn_instruction);
|
||||
lane_data_ids.push_back(data.lane_data_id);
|
||||
entry_class_ids.push_back(data.entry_class_id);
|
||||
pre_turn_bearings.push_back(data.pre_turn_bearing);
|
||||
post_turn_bearings.push_back(data.post_turn_bearing);
|
||||
}
|
||||
|
||||
template <typename = std::enable_if<Ownership == storage::Ownership::Container>>
|
||||
void append(const std::vector<TurnData> &others)
|
||||
{
|
||||
std::for_each(
|
||||
others.begin(), others.end(), [this](const TurnData &other) { push_back(other); });
|
||||
}
|
||||
|
||||
friend void serialization::read<Ownership>(storage::io::FileReader &reader,
|
||||
TurnDataContainerImpl &turn_data_container);
|
||||
friend void serialization::write<Ownership>(storage::io::FileWriter &writer,
|
||||
const TurnDataContainerImpl &turn_data_container);
|
||||
|
||||
private:
|
||||
Vector<guidance::TurnInstruction> turn_instructions;
|
||||
Vector<LaneDataID> lane_data_ids;
|
||||
Vector<EntryClassID> entry_class_ids;
|
||||
Vector<util::guidance::TurnBearing> pre_turn_bearings;
|
||||
Vector<util::guidance::TurnBearing> post_turn_bearings;
|
||||
};
|
||||
}
|
||||
|
||||
using TurnDataExternalContainer = detail::TurnDataContainerImpl<storage::Ownership::External>;
|
||||
using TurnDataContainer = detail::TurnDataContainerImpl<storage::Ownership::Container>;
|
||||
using TurnDataView = detail::TurnDataContainerImpl<storage::Ownership::View>;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_TURN_DISCOVERY_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_TURN_DISCOVERY_HPP_
|
||||
#ifndef OSRM_GUIDANCE_TURN_DISCOVERY_HPP_
|
||||
#define OSRM_GUIDANCE_TURN_DISCOVERY_HPP_
|
||||
|
||||
#include "extractor/restriction_index.hpp"
|
||||
#include "guidance/intersection.hpp"
|
||||
@@ -17,8 +17,8 @@ struct Coordinate;
|
||||
|
||||
namespace extractor
|
||||
{
|
||||
|
||||
class CompressedEdgeContainer;
|
||||
}
|
||||
|
||||
namespace guidance
|
||||
{
|
||||
@@ -34,20 +34,19 @@ bool findPreviousIntersection(
|
||||
const EdgeID via_edge,
|
||||
const Intersection &intersection,
|
||||
const util::NodeBasedDynamicGraph &node_based_graph, // query edge data
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const extractor::EdgeBasedNodeDataContainer &node_data_container,
|
||||
const std::vector<util::Coordinate> &node_coordinates,
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries,
|
||||
const RestrictionMap &node_restriction_map,
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
// output parameters, will be in an arbitrary state on failure
|
||||
NodeID &result_node,
|
||||
EdgeID &result_via_edge,
|
||||
IntersectionView &result_intersection);
|
||||
extractor::intersection::IntersectionView &result_intersection);
|
||||
|
||||
} // namespace lanes
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /*OSRM_EXTRACTOR_GUIDANCE_TURN_DISCOVERY_HPP_*/
|
||||
#endif /*OSRM_GUIDANCE_TURN_DISCOVERY_HPP_*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_TURN_HANDLER_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_TURN_HANDLER_HPP_
|
||||
#ifndef OSRM_GUIDANCE_TURN_HANDLER_HPP_
|
||||
#define OSRM_GUIDANCE_TURN_HANDLER_HPP_
|
||||
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "guidance/intersection.hpp"
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
@@ -28,14 +26,14 @@ class TurnHandler : public IntersectionHandler
|
||||
{
|
||||
public:
|
||||
TurnHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const extractor::EdgeBasedNodeDataContainer &node_data_container,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries,
|
||||
const RestrictionMap &node_restriction_map,
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
const extractor::SuffixTable &street_name_suffix_table);
|
||||
|
||||
~TurnHandler() override final = default;
|
||||
|
||||
@@ -113,7 +111,6 @@ class TurnHandler : public IntersectionHandler
|
||||
};
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /*OSRM_EXTRACTOR_GUIDANCE_TURN_HANDLER_HPP_*/
|
||||
#endif /*OSRM_GUIDANCE_TURN_HANDLER_HPP_*/
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
@@ -157,7 +155,7 @@ inline bool operator==(const TurnInstruction lhs, const TurnInstruction rhs)
|
||||
// check if a instruction is associated in any form with a roundabout
|
||||
inline bool hasRoundaboutType(const TurnInstruction instruction)
|
||||
{
|
||||
using namespace extractor::guidance::TurnType;
|
||||
using namespace guidance::TurnType;
|
||||
const constexpr TurnType::Enum valid_types[] = {TurnType::EnterRoundabout,
|
||||
TurnType::EnterAndExitRoundabout,
|
||||
TurnType::EnterRotary,
|
||||
@@ -178,106 +176,106 @@ inline bool hasRoundaboutType(const TurnInstruction instruction)
|
||||
return std::find(first, last, instruction.type) != last;
|
||||
}
|
||||
|
||||
inline bool entersRoundabout(const extractor::guidance::TurnInstruction instruction)
|
||||
inline bool entersRoundabout(const guidance::TurnInstruction instruction)
|
||||
{
|
||||
return (instruction.type == extractor::guidance::TurnType::EnterRoundabout ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRotary ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRoundaboutIntersection ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRoundaboutAtExit ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRotaryAtExit ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRoundaboutIntersectionAtExit ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRoundabout ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRotary ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRoundaboutIntersection);
|
||||
return (instruction.type == guidance::TurnType::EnterRoundabout ||
|
||||
instruction.type == guidance::TurnType::EnterRotary ||
|
||||
instruction.type == guidance::TurnType::EnterRoundaboutIntersection ||
|
||||
instruction.type == guidance::TurnType::EnterRoundaboutAtExit ||
|
||||
instruction.type == guidance::TurnType::EnterRotaryAtExit ||
|
||||
instruction.type == guidance::TurnType::EnterRoundaboutIntersectionAtExit ||
|
||||
instruction.type == guidance::TurnType::EnterAndExitRoundabout ||
|
||||
instruction.type == guidance::TurnType::EnterAndExitRotary ||
|
||||
instruction.type == guidance::TurnType::EnterAndExitRoundaboutIntersection);
|
||||
}
|
||||
|
||||
inline bool leavesRoundabout(const extractor::guidance::TurnInstruction instruction)
|
||||
inline bool leavesRoundabout(const guidance::TurnInstruction instruction)
|
||||
{
|
||||
return (instruction.type == extractor::guidance::TurnType::ExitRoundabout ||
|
||||
instruction.type == extractor::guidance::TurnType::ExitRotary ||
|
||||
instruction.type == extractor::guidance::TurnType::ExitRoundaboutIntersection ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRoundabout ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRotary ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRoundaboutIntersection);
|
||||
return (instruction.type == guidance::TurnType::ExitRoundabout ||
|
||||
instruction.type == guidance::TurnType::ExitRotary ||
|
||||
instruction.type == guidance::TurnType::ExitRoundaboutIntersection ||
|
||||
instruction.type == guidance::TurnType::EnterAndExitRoundabout ||
|
||||
instruction.type == guidance::TurnType::EnterAndExitRotary ||
|
||||
instruction.type == guidance::TurnType::EnterAndExitRoundaboutIntersection);
|
||||
}
|
||||
|
||||
inline bool staysOnRoundabout(const extractor::guidance::TurnInstruction instruction)
|
||||
inline bool staysOnRoundabout(const guidance::TurnInstruction instruction)
|
||||
{
|
||||
return instruction.type == extractor::guidance::TurnType::StayOnRoundabout ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRoundaboutAtExit ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRotaryAtExit ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRoundaboutIntersectionAtExit;
|
||||
return instruction.type == guidance::TurnType::StayOnRoundabout ||
|
||||
instruction.type == guidance::TurnType::EnterRoundaboutAtExit ||
|
||||
instruction.type == guidance::TurnType::EnterRotaryAtExit ||
|
||||
instruction.type == guidance::TurnType::EnterRoundaboutIntersectionAtExit;
|
||||
}
|
||||
|
||||
// Silent Turn Instructions are not to be mentioned to the outside world but
|
||||
inline bool isSilent(const extractor::guidance::TurnInstruction instruction)
|
||||
inline bool isSilent(const guidance::TurnInstruction instruction)
|
||||
{
|
||||
return instruction.type == extractor::guidance::TurnType::NoTurn ||
|
||||
instruction.type == extractor::guidance::TurnType::Suppressed ||
|
||||
instruction.type == extractor::guidance::TurnType::StayOnRoundabout;
|
||||
return instruction.type == guidance::TurnType::NoTurn ||
|
||||
instruction.type == guidance::TurnType::Suppressed ||
|
||||
instruction.type == guidance::TurnType::StayOnRoundabout;
|
||||
}
|
||||
|
||||
inline bool hasRampType(const extractor::guidance::TurnInstruction instruction)
|
||||
inline bool hasRampType(const guidance::TurnInstruction instruction)
|
||||
{
|
||||
return instruction.type == extractor::guidance::TurnType::OffRamp ||
|
||||
instruction.type == extractor::guidance::TurnType::OnRamp;
|
||||
return instruction.type == guidance::TurnType::OffRamp ||
|
||||
instruction.type == guidance::TurnType::OnRamp;
|
||||
}
|
||||
|
||||
inline extractor::guidance::DirectionModifier::Enum getTurnDirection(const double angle)
|
||||
inline guidance::DirectionModifier::Enum getTurnDirection(const double angle)
|
||||
{
|
||||
// An angle of zero is a u-turn
|
||||
// 180 goes perfectly straight
|
||||
// 0-180 are right turns
|
||||
// 180-360 are left turns
|
||||
if (angle > 0 && angle < 60)
|
||||
return extractor::guidance::DirectionModifier::SharpRight;
|
||||
return guidance::DirectionModifier::SharpRight;
|
||||
if (angle >= 60 && angle < 140)
|
||||
return extractor::guidance::DirectionModifier::Right;
|
||||
return guidance::DirectionModifier::Right;
|
||||
if (angle >= 140 && angle < 160)
|
||||
return extractor::guidance::DirectionModifier::SlightRight;
|
||||
return guidance::DirectionModifier::SlightRight;
|
||||
if (angle >= 160 && angle <= 200)
|
||||
return extractor::guidance::DirectionModifier::Straight;
|
||||
return guidance::DirectionModifier::Straight;
|
||||
if (angle > 200 && angle <= 220)
|
||||
return extractor::guidance::DirectionModifier::SlightLeft;
|
||||
return guidance::DirectionModifier::SlightLeft;
|
||||
if (angle > 220 && angle <= 300)
|
||||
return extractor::guidance::DirectionModifier::Left;
|
||||
return guidance::DirectionModifier::Left;
|
||||
if (angle > 300 && angle < 360)
|
||||
return extractor::guidance::DirectionModifier::SharpLeft;
|
||||
return extractor::guidance::DirectionModifier::UTurn;
|
||||
return guidance::DirectionModifier::SharpLeft;
|
||||
return guidance::DirectionModifier::UTurn;
|
||||
}
|
||||
|
||||
// swaps left <-> right modifier types
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
inline extractor::guidance::DirectionModifier::Enum
|
||||
mirrorDirectionModifier(const extractor::guidance::DirectionModifier::Enum modifier)
|
||||
inline guidance::DirectionModifier::Enum
|
||||
mirrorDirectionModifier(const guidance::DirectionModifier::Enum modifier)
|
||||
{
|
||||
const constexpr extractor::guidance::DirectionModifier::Enum results[] = {
|
||||
extractor::guidance::DirectionModifier::UTurn,
|
||||
extractor::guidance::DirectionModifier::SharpLeft,
|
||||
extractor::guidance::DirectionModifier::Left,
|
||||
extractor::guidance::DirectionModifier::SlightLeft,
|
||||
extractor::guidance::DirectionModifier::Straight,
|
||||
extractor::guidance::DirectionModifier::SlightRight,
|
||||
extractor::guidance::DirectionModifier::Right,
|
||||
extractor::guidance::DirectionModifier::SharpRight};
|
||||
const constexpr guidance::DirectionModifier::Enum results[] = {
|
||||
guidance::DirectionModifier::UTurn,
|
||||
guidance::DirectionModifier::SharpLeft,
|
||||
guidance::DirectionModifier::Left,
|
||||
guidance::DirectionModifier::SlightLeft,
|
||||
guidance::DirectionModifier::Straight,
|
||||
guidance::DirectionModifier::SlightRight,
|
||||
guidance::DirectionModifier::Right,
|
||||
guidance::DirectionModifier::SharpRight};
|
||||
return results[modifier];
|
||||
}
|
||||
|
||||
inline bool hasLeftModifier(const extractor::guidance::TurnInstruction instruction)
|
||||
inline bool hasLeftModifier(const guidance::TurnInstruction instruction)
|
||||
{
|
||||
return instruction.direction_modifier == extractor::guidance::DirectionModifier::SharpLeft ||
|
||||
instruction.direction_modifier == extractor::guidance::DirectionModifier::Left ||
|
||||
instruction.direction_modifier == extractor::guidance::DirectionModifier::SlightLeft;
|
||||
return instruction.direction_modifier == guidance::DirectionModifier::SharpLeft ||
|
||||
instruction.direction_modifier == guidance::DirectionModifier::Left ||
|
||||
instruction.direction_modifier == guidance::DirectionModifier::SlightLeft;
|
||||
}
|
||||
|
||||
inline bool hasRightModifier(const extractor::guidance::TurnInstruction instruction)
|
||||
inline bool hasRightModifier(const guidance::TurnInstruction instruction)
|
||||
{
|
||||
return instruction.direction_modifier == extractor::guidance::DirectionModifier::SharpRight ||
|
||||
instruction.direction_modifier == extractor::guidance::DirectionModifier::Right ||
|
||||
instruction.direction_modifier == extractor::guidance::DirectionModifier::SlightRight;
|
||||
return instruction.direction_modifier == guidance::DirectionModifier::SharpRight ||
|
||||
instruction.direction_modifier == guidance::DirectionModifier::Right ||
|
||||
instruction.direction_modifier == guidance::DirectionModifier::SlightRight;
|
||||
}
|
||||
|
||||
inline bool isLeftTurn(const extractor::guidance::TurnInstruction instruction)
|
||||
inline bool isLeftTurn(const guidance::TurnInstruction instruction)
|
||||
{
|
||||
switch (instruction.type)
|
||||
{
|
||||
@@ -288,7 +286,7 @@ inline bool isLeftTurn(const extractor::guidance::TurnInstruction instruction)
|
||||
}
|
||||
}
|
||||
|
||||
inline bool isRightTurn(const extractor::guidance::TurnInstruction instruction)
|
||||
inline bool isRightTurn(const guidance::TurnInstruction instruction)
|
||||
{
|
||||
switch (instruction.type)
|
||||
{
|
||||
@@ -303,14 +301,14 @@ inline DirectionModifier::Enum bearingToDirectionModifier(const double bearing)
|
||||
{
|
||||
if (bearing < 135)
|
||||
{
|
||||
return extractor::guidance::DirectionModifier::Right;
|
||||
return guidance::DirectionModifier::Right;
|
||||
}
|
||||
|
||||
if (bearing <= 225)
|
||||
{
|
||||
return extractor::guidance::DirectionModifier::Straight;
|
||||
return guidance::DirectionModifier::Straight;
|
||||
}
|
||||
return extractor::guidance::DirectionModifier::Left;
|
||||
return guidance::DirectionModifier::Left;
|
||||
}
|
||||
|
||||
namespace detail
|
||||
@@ -337,7 +335,7 @@ struct TurnTypeName
|
||||
const char *internal_name;
|
||||
};
|
||||
|
||||
// Indexes in this list correspond to the Enum values of osrm::extractor::guidance::TurnType
|
||||
// Indexes in this list correspond to the Enum values of osrm::guidance::TurnType
|
||||
const constexpr TurnTypeName turn_type_names[] = {
|
||||
{"invalid", "(not set)"},
|
||||
{"new name", "new name"},
|
||||
@@ -394,7 +392,6 @@ inline std::string instructionModifierToString(const DirectionModifier::Enum mod
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_GUIDANCE_TURN_INSTRUCTION_HPP_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_AUGMENTATION_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_AUGMENTATION_HPP_
|
||||
#ifndef OSRM_GUIDANCE_TURN_LANE_AUGMENTATION_HPP_
|
||||
#define OSRM_GUIDANCE_TURN_LANE_AUGMENTATION_HPP_
|
||||
|
||||
#include "guidance/intersection.hpp"
|
||||
#include "guidance/turn_lane_data.hpp"
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
namespace lanes
|
||||
@@ -20,7 +18,6 @@ LaneDataVector handleNoneValueAtSimpleTurn(LaneDataVector lane_data,
|
||||
|
||||
} // namespace lanes
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /* OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_AUGMENTATION_HPP_ */
|
||||
#endif /* OSRM_GUIDANCE_TURN_LANE_AUGMENTATION_HPP_ */
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_DATA_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_DATA_HPP_
|
||||
#ifndef OSRM_GUIDANCE_TURN_LANE_DATA_HPP_
|
||||
#define OSRM_GUIDANCE_TURN_LANE_DATA_HPP_
|
||||
|
||||
#include "guidance/turn_lane_types.hpp"
|
||||
#include "extractor/turn_lane_types.hpp"
|
||||
#include "util/attributes.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
namespace lanes
|
||||
@@ -17,7 +15,7 @@ namespace lanes
|
||||
|
||||
struct TurnLaneData
|
||||
{
|
||||
TurnLaneType::Mask tag;
|
||||
extractor::TurnLaneType::Mask tag;
|
||||
LaneID from;
|
||||
LaneID to;
|
||||
|
||||
@@ -30,18 +28,18 @@ typedef std::vector<TurnLaneData> LaneDataVector;
|
||||
|
||||
// convertes a string given in the OSM format into a TurnLaneData vector
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
LaneDataVector laneDataFromDescription(TurnLaneDescription turn_lane_description);
|
||||
LaneDataVector laneDataFromDescription(extractor::TurnLaneDescription turn_lane_description);
|
||||
|
||||
// Locate A Tag in a lane data vector (if multiple tags are set, the first one found is returned)
|
||||
LaneDataVector::const_iterator findTag(const TurnLaneType::Mask tag, const LaneDataVector &data);
|
||||
LaneDataVector::iterator findTag(const TurnLaneType::Mask tag, LaneDataVector &data);
|
||||
LaneDataVector::const_iterator findTag(const extractor::TurnLaneType::Mask tag,
|
||||
const LaneDataVector &data);
|
||||
LaneDataVector::iterator findTag(const extractor::TurnLaneType::Mask tag, LaneDataVector &data);
|
||||
|
||||
// Returns true if any of the queried tags is contained
|
||||
bool hasTag(const TurnLaneType::Mask tag, const LaneDataVector &data);
|
||||
bool hasTag(const extractor::TurnLaneType::Mask tag, const LaneDataVector &data);
|
||||
} // namespace lane_data_generation
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /* OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_DATA_HPP_ */
|
||||
#endif /* OSRM_GUIDANCE_TURN_LANE_DATA_HPP_ */
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_HANDLER_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_HANDLER_HPP_
|
||||
#ifndef OSRM_GUIDANCE_TURN_LANE_HANDLER_HPP_
|
||||
#define OSRM_GUIDANCE_TURN_LANE_HANDLER_HPP_
|
||||
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "extractor/turn_lane_types.hpp"
|
||||
#include "guidance/intersection.hpp"
|
||||
#include "guidance/turn_analysis.hpp"
|
||||
#include "guidance/turn_lane_data.hpp"
|
||||
#include "guidance/turn_lane_types.hpp"
|
||||
|
||||
#include "util/attributes.hpp"
|
||||
#include "util/guidance/turn_lanes.hpp"
|
||||
@@ -23,8 +23,6 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
@@ -73,13 +71,13 @@ class TurnLaneHandler
|
||||
typedef std::vector<TurnLaneData> LaneDataVector;
|
||||
|
||||
TurnLaneHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const EdgeBasedNodeDataContainer &node_data_container,
|
||||
const extractor::EdgeBasedNodeDataContainer &node_data_container,
|
||||
const std::vector<util::Coordinate> &node_coordinates,
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries,
|
||||
const RestrictionMap &node_restriction_map,
|
||||
const extractor::RestrictionMap &node_restriction_map,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data,
|
||||
LaneDescriptionMap &lane_description_map,
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data,
|
||||
extractor::LaneDescriptionMap &lane_description_map,
|
||||
const TurnAnalysis &turn_analysis,
|
||||
util::guidance::LaneDataIdMap &id_map);
|
||||
|
||||
@@ -94,16 +92,16 @@ class TurnLaneHandler
|
||||
// we need to be able to look at previous intersections to, in some cases, find the correct turn
|
||||
// lanes for a turn
|
||||
const util::NodeBasedDynamicGraph &node_based_graph;
|
||||
const EdgeBasedNodeDataContainer &node_data_container;
|
||||
const extractor::EdgeBasedNodeDataContainer &node_data_container;
|
||||
const std::vector<util::Coordinate> &node_coordinates;
|
||||
const extractor::CompressedEdgeContainer &compressed_geometries;
|
||||
const RestrictionMap &node_restriction_map;
|
||||
const extractor::RestrictionMap &node_restriction_map;
|
||||
const std::unordered_set<NodeID> &barrier_nodes;
|
||||
const guidance::TurnLanesIndexedArray &turn_lanes_data;
|
||||
const extractor::TurnLanesIndexedArray &turn_lanes_data;
|
||||
|
||||
std::vector<std::uint32_t> turn_lane_offsets;
|
||||
std::vector<TurnLaneType::Mask> turn_lane_masks;
|
||||
LaneDescriptionMap &lane_description_map;
|
||||
std::vector<extractor::TurnLaneType::Mask> turn_lane_masks;
|
||||
extractor::LaneDescriptionMap &lane_description_map;
|
||||
const TurnAnalysis &turn_analysis;
|
||||
util::guidance::LaneDataIdMap &id_map;
|
||||
|
||||
@@ -155,7 +153,6 @@ static_assert(sizeof(scenario_names) / sizeof(*scenario_names) == TurnLaneScenar
|
||||
|
||||
} // namespace lanes
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_HANDLER_HPP_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_MATCHER_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_MATCHER_HPP_
|
||||
#ifndef OSRM_GUIDANCE_TURN_LANE_MATCHER_HPP_
|
||||
#define OSRM_GUIDANCE_TURN_LANE_MATCHER_HPP_
|
||||
|
||||
#include "guidance/intersection.hpp"
|
||||
#include "guidance/turn_instruction.hpp"
|
||||
@@ -11,28 +11,27 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
namespace lanes
|
||||
{
|
||||
|
||||
// Translate Turn Lane Tags into a matching modifier
|
||||
DirectionModifier::Enum getMatchingModifier(const TurnLaneType::Mask tag);
|
||||
DirectionModifier::Enum getMatchingModifier(const extractor::TurnLaneType::Mask tag);
|
||||
|
||||
// check whether a match of a given tag and a turn instruction can be seen as valid
|
||||
bool isValidMatch(const TurnLaneType::Mask tag, const TurnInstruction instruction);
|
||||
bool isValidMatch(const extractor::TurnLaneType::Mask tag, const TurnInstruction instruction);
|
||||
|
||||
// localisation of the best possible match for a tag
|
||||
typename Intersection::const_iterator findBestMatch(const TurnLaneType::Mask tag,
|
||||
typename Intersection::const_iterator findBestMatch(const extractor::TurnLaneType::Mask tag,
|
||||
const Intersection &intersection);
|
||||
|
||||
// the quality of a matching to decide between first/second possibility on segregated intersections
|
||||
double getMatchingQuality(const TurnLaneType::Mask tag, const ConnectedRoad &road);
|
||||
double getMatchingQuality(const extractor::TurnLaneType::Mask tag, const ConnectedRoad &road);
|
||||
|
||||
typename Intersection::const_iterator findBestMatchForReverse(const TurnLaneType::Mask leftmost_tag,
|
||||
const Intersection &intersection);
|
||||
typename Intersection::const_iterator
|
||||
findBestMatchForReverse(const extractor::TurnLaneType::Mask leftmost_tag,
|
||||
const Intersection &intersection);
|
||||
|
||||
// a match is trivial if all turns can be associated with their best match in a valid way and the
|
||||
// matches occur in order
|
||||
@@ -48,7 +47,6 @@ Intersection triviallyMatchLanesToTurns(Intersection intersection,
|
||||
|
||||
} // namespace lanes
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /*OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_MATCHER_HPP_*/
|
||||
#endif /*OSRM_GUIDANCE_TURN_LANE_MATCHER_HPP_*/
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
#ifndef OSRM_GUIDANCE_TURN_LANE_TYPES_HPP_
|
||||
#define OSRM_GUIDANCE_TURN_LANE_TYPES_HPP_
|
||||
|
||||
#include <bitset>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <numeric> //partial_sum
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
#include "util/concurrent_id_map.hpp"
|
||||
#include "util/json_container.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
namespace TurnLaneType
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
const constexpr std::size_t num_supported_lane_types = 11;
|
||||
|
||||
const constexpr char *translations[detail::num_supported_lane_types] = {"none",
|
||||
"straight",
|
||||
"sharp left",
|
||||
"left",
|
||||
"slight left",
|
||||
"slight right",
|
||||
"right",
|
||||
"sharp right",
|
||||
"uturn",
|
||||
"merge to left",
|
||||
"merge to right"};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
typedef std::uint16_t Mask;
|
||||
const constexpr Mask empty = 0u;
|
||||
const constexpr Mask none = 1u << 0u;
|
||||
const constexpr Mask straight = 1u << 1u;
|
||||
const constexpr Mask sharp_left = 1u << 2u;
|
||||
const constexpr Mask left = 1u << 3u;
|
||||
const constexpr Mask slight_left = 1u << 4u;
|
||||
const constexpr Mask slight_right = 1u << 5u;
|
||||
const constexpr Mask right = 1u << 6u;
|
||||
const constexpr Mask sharp_right = 1u << 7u;
|
||||
const constexpr Mask uturn = 1u << 8u;
|
||||
const constexpr Mask merge_to_left = 1u << 9u;
|
||||
const constexpr Mask merge_to_right = 1u << 10u;
|
||||
|
||||
inline std::string toString(const Mask lane_type)
|
||||
{
|
||||
if (lane_type == 0)
|
||||
return "none";
|
||||
|
||||
std::bitset<8 * sizeof(Mask)> mask(lane_type);
|
||||
std::string result = "";
|
||||
for (std::size_t lane_id_nr = 0; lane_id_nr < detail::num_supported_lane_types; ++lane_id_nr)
|
||||
if (mask[lane_id_nr])
|
||||
result += (result.empty() ? detail::translations[lane_id_nr]
|
||||
: (std::string(";") + detail::translations[lane_id_nr]));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
inline util::json::Array toJsonArray(const Mask lane_type)
|
||||
{
|
||||
util::json::Array result;
|
||||
std::bitset<8 * sizeof(Mask)> mask(lane_type);
|
||||
for (std::size_t lane_id_nr = 0; lane_id_nr < detail::num_supported_lane_types; ++lane_id_nr)
|
||||
if (mask[lane_id_nr])
|
||||
result.values.push_back(detail::translations[lane_id_nr]);
|
||||
return result;
|
||||
}
|
||||
} // TurnLaneType
|
||||
|
||||
typedef std::vector<TurnLaneType::Mask> TurnLaneDescription;
|
||||
|
||||
// hash function for TurnLaneDescription
|
||||
struct TurnLaneDescription_hash
|
||||
{
|
||||
std::size_t operator()(const TurnLaneDescription &lane_description) const
|
||||
{
|
||||
std::size_t seed = 0;
|
||||
boost::hash_range(seed, lane_description.begin(), lane_description.end());
|
||||
return seed;
|
||||
}
|
||||
};
|
||||
|
||||
typedef util::ConcurrentIDMap<guidance::TurnLaneDescription,
|
||||
LaneDescriptionID,
|
||||
guidance::TurnLaneDescription_hash>
|
||||
LaneDescriptionMap;
|
||||
|
||||
using TurnLanesIndexedArray =
|
||||
std::tuple<std::vector<std::uint32_t>, std::vector<TurnLaneType::Mask>>;
|
||||
|
||||
inline TurnLanesIndexedArray transformTurnLaneMapIntoArrays(const LaneDescriptionMap &turn_lane_map)
|
||||
{
|
||||
// could use some additional capacity? To avoid a copy during processing, though small data so
|
||||
// probably not that important.
|
||||
//
|
||||
// From the map, we construct an adjacency array that allows access from all IDs to the list of
|
||||
// associated Turn Lane Masks.
|
||||
//
|
||||
// turn lane offsets points into the locations of the turn_lane_masks array. We use a standard
|
||||
// adjacency array like structure to store the turn lane masks.
|
||||
std::vector<std::uint32_t> turn_lane_offsets(turn_lane_map.data.size() + 1); // + sentinel
|
||||
for (auto entry = turn_lane_map.data.begin(); entry != turn_lane_map.data.end(); ++entry)
|
||||
turn_lane_offsets[entry->second + 1] = entry->first.size();
|
||||
|
||||
// inplace prefix sum
|
||||
std::partial_sum(turn_lane_offsets.begin(), turn_lane_offsets.end(), turn_lane_offsets.begin());
|
||||
|
||||
// allocate the current masks
|
||||
std::vector<guidance::TurnLaneType::Mask> turn_lane_masks(turn_lane_offsets.back());
|
||||
for (auto entry = turn_lane_map.data.begin(); entry != turn_lane_map.data.end(); ++entry)
|
||||
std::copy(entry->first.begin(),
|
||||
entry->first.end(),
|
||||
turn_lane_masks.begin() + turn_lane_offsets[entry->second]);
|
||||
|
||||
return std::make_tuple(std::move(turn_lane_offsets), std::move(turn_lane_masks));
|
||||
}
|
||||
|
||||
} // guidance
|
||||
} // extractor
|
||||
} // osrm
|
||||
|
||||
#endif /* OSRM_GUIDANCE_TURN_LANE_TYPES_HPP_ */
|
||||
Reference in New Issue
Block a user