Welcome to mirror list, hosted at ThFree Co, Russian Federation.

turns_generator.hpp « routing - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fbf80fa1c9b3c74449a5335cd78dbc41709ee77c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#pragma once

#include "routing/osrm2feature_map.hpp"
#include "routing/osrm_engine.hpp"
#include "routing/route.hpp"
#include "routing/turns.hpp"

#include "std/function.hpp"
#include "std/utility.hpp"
#include "std/vector.hpp"

struct PathData;
class Index;

namespace ftypes
{
enum class HighwayClass;
}

namespace routing
{
struct RoutingMapping;

namespace turns
{
/*!
 * \brief Returns a segment index by STL-like range [s, e) of segments indices for the passed node.
 */
typedef function<size_t(pair<size_t, size_t>)> TGetIndexFunction;

/*!
 * \brief The TurnInfo struct is an accumulator for all junction information.
 * During a junction (a turn) analysis a different subsets of fields in the structure
 * may be calculated. The main purpose of TurnInfo is to prevent recalculation the same fields.
 * The idea is if a field is required to check whether a field has been calculated.
 * If yes, just use it. If not, the field should be calculated, kept in the structure
 * and used.
 */
struct TurnInfo
{
  RoutingMapping & m_routeMapping;

  NodeID m_ingoingNodeID;
  OsrmMappingTypes::FtSeg m_ingoingSegment;
  ftypes::HighwayClass m_ingoingHighwayClass;
  bool m_isIngoingEdgeRoundabout;

  NodeID m_outgoingNodeID;
  OsrmMappingTypes::FtSeg m_outgoingSegment;
  ftypes::HighwayClass m_outgoingHighwayClass;
  bool m_isOutgoingEdgeRoundabout;

  TurnInfo(RoutingMapping & routeMapping, NodeID ingoingNodeID, NodeID outgoingNodeID);

  bool IsSegmentsValid() const;
};

size_t GetLastSegmentPointIndex(pair<size_t, size_t> const & p);
vector<SingleLaneInfo> GetLanesInfo(NodeID node, RoutingMapping const & routingMapping,
                                    TGetIndexFunction GetIndex, Index const & index);

/*!
 * \brief Returns geometry for all the turns. It means that for every turn CalculateTurnGeometry
 * calculates a sequence of points.
 */
void CalculateTurnGeometry(vector<m2::PointD> const & points, Route::TTurns const & turnsDir,
                           TTurnsGeom & turnsGeom);
/*!
 * \brief Selects lanes which are recommended for an end user.
 */
void SelectRecommendedLanes(Route::TTurns & turnsDir);
void FixupTurns(vector<m2::PointD> const & points, Route::TTurns & turnsDir);
inline size_t GetFirstSegmentPointIndex(pair<size_t, size_t> const & p) { return p.first; }

TurnDirection InvertDirection(TurnDirection dir);

/*!
 * \param angle is an angle of a turn. It belongs to a range [-180, 180].
 * \return correct direction if the route follows along the rightmost possible way.
 */
TurnDirection RightmostDirection(double angle);
TurnDirection LeftmostDirection(double angle);

/*!
 * \param angle is an angle of a turn. It belongs to a range [-180, 180].
 * \return correct direction if the route follows not along one of two outermost ways
 * or if there is only one possible way.
 */
TurnDirection IntermediateDirection(double angle);

/*!
 * \return Returns true if the route enters a roundabout.
 * That means isIngoingEdgeRoundabout is false and isOutgoingEdgeRoundabout is true.
 */
bool CheckRoundaboutEntrance(bool isIngoingEdgeRoundabout, bool isOutgoingEdgeRoundabout);

/*!
 * \return Returns true if the route leaves a roundabout.
 * That means isIngoingEdgeRoundabout is true and isOutgoingEdgeRoundabout is false.
 */
bool CheckRoundaboutExit(bool isIngoingEdgeRoundabout, bool isOutgoingEdgeRoundabout);

/*!
 * \brief Calculates a turn instruction if the ingoing edge or (and) the outgoing edge belongs to a
 * roundabout.
 * \return Returns one of the following results:
 * - TurnDirection::EnterRoundAbout if the ingoing edge does not belong to a roundabout
 *   and the outgoing edge belongs to a roundabout.
 * - TurnDirection::StayOnRoundAbout if the ingoing edge and the outgoing edge belong to a
 * roundabout
 *   and there is a reasonalbe way to leave the junction besides the outgoing edge.
 *   This function does not return TurnDirection::StayOnRoundAbout for small ways to leave the
 * roundabout.
 * - TurnDirection::NoTurn if the ingoing edge and the outgoing edge belong to a roundabout
 *   (a) and there is a single way (outgoing edge) to leave the junction.
 *   (b) and there is a way(s) besides outgoing edge to leave the junction (the roundabout)
 *       but it is (they are) relevantly small.
 */
TurnDirection GetRoundaboutDirection(bool isIngoingEdgeRoundabout, bool isOutgoingEdgeRoundabout,
                                     bool isMultiTurnJunction, bool keepTurnByHighwayClass);
/*!
 * \brief GetTurnDirection makes a primary decision about turns on the route.
 * \param turnInfo is used for cashing some information while turn calculation.
 * \param turn is used for keeping the result of turn calculation.
 */
void GetTurnDirection(Index const & index, turns::TurnInfo & turnInfo, TurnItem & turn);

}  // namespace routing
}  // namespace turns