2016-04-08 06:49:14 -04:00
|
|
|
#ifndef OSRM_EXTRACTOR_GUIDANCE_INTERSECTION_GENERATOR_HPP_
|
|
|
|
#define OSRM_EXTRACTOR_GUIDANCE_INTERSECTION_GENERATOR_HPP_
|
|
|
|
|
|
|
|
#include "extractor/compressed_edge_container.hpp"
|
2016-08-17 03:49:19 -04:00
|
|
|
#include "extractor/guidance/coordinate_extractor.hpp"
|
2016-04-08 06:49:14 -04:00
|
|
|
#include "extractor/guidance/intersection.hpp"
|
|
|
|
#include "extractor/query_node.hpp"
|
|
|
|
#include "extractor/restriction_map.hpp"
|
2016-08-02 09:43:29 -04:00
|
|
|
#include "util/attributes.hpp"
|
2016-06-15 08:38:24 -04:00
|
|
|
#include "util/name_table.hpp"
|
2016-04-08 06:49:14 -04:00
|
|
|
#include "util/node_based_graph.hpp"
|
|
|
|
#include "util/typedefs.hpp"
|
|
|
|
|
|
|
|
#include <unordered_set>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace extractor
|
|
|
|
{
|
|
|
|
namespace guidance
|
|
|
|
{
|
|
|
|
// The Intersection Generator is given a turn location and generates an intersection representation
|
|
|
|
// from it. For this all turn possibilities are analysed.
|
|
|
|
// We consider turn restrictions to indicate possible turns. U-turns are generated based on profile
|
|
|
|
// decisions.
|
|
|
|
|
|
|
|
class IntersectionGenerator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
IntersectionGenerator(const util::NodeBasedDynamicGraph &node_based_graph,
|
|
|
|
const RestrictionMap &restriction_map,
|
|
|
|
const std::unordered_set<NodeID> &barrier_nodes,
|
|
|
|
const std::vector<QueryNode> &node_info_list,
|
|
|
|
const CompressedEdgeContainer &compressed_edge_container);
|
|
|
|
|
|
|
|
Intersection operator()(const NodeID nid, const EdgeID via_eid) const;
|
|
|
|
|
2016-08-15 06:43:26 -04:00
|
|
|
// Graph Compression cannot compress every setting. For example any barrier/traffic light cannot
|
|
|
|
// be compressed. As a result, a simple road of the form `a ----- b` might end up as having an
|
|
|
|
// intermediate intersection, if there is a traffic light in between. If we want to look farther
|
|
|
|
// down a road, finding the next actual decision requires the look at multiple intersections.
|
|
|
|
// Here we follow the road until we either reach a dead end or find the next intersection with
|
|
|
|
// more than a single next road.
|
|
|
|
Intersection GetActualNextIntersection(const NodeID starting_node,
|
|
|
|
const EdgeID via_edge,
|
|
|
|
NodeID *resulting_from_node,
|
|
|
|
EdgeID *resulting_via_edge) const;
|
|
|
|
|
2016-10-20 06:15:36 -04:00
|
|
|
// Allow access to the coordinate extractor for all owners
|
|
|
|
const CoordinateExtractor &GetCoordinateExtractor() const;
|
|
|
|
|
2016-04-08 06:49:14 -04:00
|
|
|
// Check for restrictions/barriers and generate a list of valid and invalid turns present at
|
|
|
|
// the
|
|
|
|
// node reached
|
|
|
|
// from `from_node` via `via_eid`
|
|
|
|
// The resulting candidates have to be analysed for their actual instructions later on.
|
2016-08-02 09:43:29 -04:00
|
|
|
OSRM_ATTR_WARN_UNUSED
|
2016-08-11 08:21:34 -04:00
|
|
|
Intersection GetConnectedRoads(const NodeID from_node, const EdgeID via_eid) const;
|
2016-04-08 06:49:14 -04:00
|
|
|
|
2016-10-29 15:38:10 -04:00
|
|
|
private:
|
|
|
|
const util::NodeBasedDynamicGraph &node_based_graph;
|
|
|
|
const RestrictionMap &restriction_map;
|
|
|
|
const std::unordered_set<NodeID> &barrier_nodes;
|
|
|
|
const std::vector<QueryNode> &node_info_list;
|
|
|
|
const CoordinateExtractor coordinate_extractor;
|
|
|
|
|
2016-08-11 06:44:10 -04:00
|
|
|
// check if two indices in an intersection can be seen as a single road in the perceived
|
2016-08-08 09:46:33 -04:00
|
|
|
// intersection representation. See below for an example. Utility function for
|
2016-08-15 10:55:03 -04:00
|
|
|
// MergeSegregatedRoads
|
2016-08-11 08:21:34 -04:00
|
|
|
bool CanMerge(const NodeID intersection_node,
|
|
|
|
const Intersection &intersection,
|
2016-08-11 06:44:10 -04:00
|
|
|
std::size_t first_index,
|
|
|
|
std::size_t second_index) const;
|
|
|
|
|
2016-04-08 06:49:14 -04:00
|
|
|
// Merge segregated roads to omit invalid turns in favor of treating segregated roads as
|
|
|
|
// one.
|
|
|
|
// This function combines roads the following way:
|
|
|
|
//
|
|
|
|
// * *
|
|
|
|
// * is converted to *
|
|
|
|
// v ^ +
|
|
|
|
// v ^ +
|
|
|
|
//
|
|
|
|
// The treatment results in a straight turn angle of 180º rather than a turn angle of approx
|
|
|
|
// 160
|
2016-08-02 09:43:29 -04:00
|
|
|
OSRM_ATTR_WARN_UNUSED
|
2016-08-11 08:21:34 -04:00
|
|
|
Intersection MergeSegregatedRoads(const NodeID intersection_node,
|
|
|
|
Intersection intersection) const;
|
2016-08-11 06:44:10 -04:00
|
|
|
|
|
|
|
// The counterpiece to mergeSegregatedRoads. While we can adjust roads that split up at the
|
|
|
|
// intersection itself, it can also happen that intersections are connected to joining roads.
|
|
|
|
//
|
|
|
|
// * *
|
|
|
|
// * is converted to *
|
|
|
|
// v a --- a ---
|
|
|
|
// v ^ +
|
|
|
|
// v ^ +
|
|
|
|
// b
|
|
|
|
//
|
|
|
|
// for the local view of b at a.
|
2016-08-11 08:21:34 -04:00
|
|
|
OSRM_ATTR_WARN_UNUSED
|
|
|
|
Intersection AdjustForJoiningRoads(const NodeID node_at_intersection,
|
2016-08-11 06:44:10 -04:00
|
|
|
Intersection intersection) const;
|
2016-04-08 06:49:14 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace guidance
|
|
|
|
} // namespace extractor
|
|
|
|
} // namespace osrm
|
|
|
|
|
|
|
|
#endif /* OSRM_EXTRACTOR_GUIDANCE_INTERSECTION_GENERATOR_HPP_ */
|