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
130
131
132
133
134
135
|
#pragma once
#include "routing/osrm2feature_map.hpp"
#include "routing/osrm_data_facade.hpp"
#include "routing/osrm_engine.hpp"
#include "routing/route.hpp"
#include "routing/router.hpp"
#include "routing/routing_mapping.h"
#include "indexer/index.hpp"
#include "base/mutex.hpp"
#include "std/atomic.hpp"
#include "std/function.hpp"
#include "std/numeric.hpp"
#include "std/queue.hpp"
namespace feature { class TypesHolder; }
struct RawRouteData;
struct PhantomNode;
struct PathData;
class FeatureType;
namespace routing
{
struct RoutePathCross;
using TCheckedPath = vector<RoutePathCross>;
typedef OsrmDataFacade<QueryEdge::EdgeData> TDataFacade;
/// All edges available for start route while routing
typedef vector<FeatureGraphNode> TFeatureGraphNodeVec;
class OsrmRouter : public IRouter
{
public:
typedef vector<double> GeomTurnCandidateT;
OsrmRouter(Index const * index, TCountryFileFn const & fn, RoutingVisualizerFn routingVisualization = nullptr);
virtual string GetName() const;
ResultCode CalculateRoute(m2::PointD const & startPoint, m2::PointD const & startDirection,
m2::PointD const & finalPoint, Route & route) override;
virtual void ClearState();
/*! Find single shortest path in a single MWM between 2 sets of edges
* \param source: vector of source edges to make path
* \param taget: vector of target edges to make path
* \param facade: OSRM routing data facade to recover graph information
* \param rawRoutingResult: routing result store
* \return true when path exists, false otherwise.
*/
static bool FindRouteFromCases(TFeatureGraphNodeVec const & source,
TFeatureGraphNodeVec const & target, TDataFacade & facade,
RawRoutingResult & rawRoutingResult);
protected:
IRouter::ResultCode FindPhantomNodes(string const & mapName, m2::PointD const & point,
m2::PointD const & direction, TFeatureGraphNodeVec & res,
size_t maxCount, TRoutingMappingPtr const & mapping);
/*!
* \brief Compute turn and time estimation structs for OSRM raw route.
* \param routingResult OSRM routing result structure to annotate.
* \param mapping Feature mappings.
* \param points Storage for unpacked points of the path.
* \param turnsDir output turns annotation storage.
* \param times output times annotation storage.
* \param turnsGeom output turns geometry.
* \return routing operation result code.
*/
ResultCode MakeTurnAnnotation(RawRoutingResult const & routingResult,
TRoutingMappingPtr const & mapping, vector<m2::PointD> & points,
Route::TurnsT & turnsDir, Route::TimesT & times,
turns::TurnsGeomT & turnsGeom);
private:
/*!
* \brief Makes route (points turns and other annotations) from the map cross structs and submits
* them to @route class
* \warning monitors m_requestCancel flag for process interrupting.
* \param path vector of pathes through mwms
* \param route class to render final route
* \return NoError or error code
*/
ResultCode MakeRouteFromCrossesPath(TCheckedPath const & path, Route & route);
NodeID GetTurnTargetNode(NodeID src, NodeID trg, QueryEdge::EdgeData const & edgeData, TRoutingMappingPtr const & routingMapping);
void GetPossibleTurns(NodeID node, m2::PointD const & p1, m2::PointD const & p,
TRoutingMappingPtr const & routingMapping,
turns::TTurnCandidates & candidates);
void GetTurnDirection(RawPathData const & node1, RawPathData const & node2,
TRoutingMappingPtr const & routingMapping, TurnItem & turn);
m2::PointD GetPointForTurnAngle(OsrmMappingTypes::FtSeg const & seg,
FeatureType const & ft, m2::PointD const & turnPnt,
size_t (*GetPndInd)(const size_t, const size_t, const size_t)) const;
/*!
* \param junctionPoint is a point of the junction.
* \param ingoingPointOneSegment is a point one segment before the junction along the route.
* \param mapping is a route mapping.
* \return number of all the segments which joins junctionPoint. That means
* the number of ingoing segments plus the number of outgoing segments.
* \warning NumberOfIngoingAndOutgoingSegments should be used carefully because
* it's a time-consuming function.
* \warning In multilevel crossroads there is an insignificant possibility that the returned value
* contains redundant segments of roads of different levels.
*/
size_t NumberOfIngoingAndOutgoingSegments(m2::PointD const & junctionPoint,
m2::PointD const & ingoingPointOneSegment,
TRoutingMappingPtr const & mapping) const;
/*!
* \brief GetTurnGeometry looks for all the road network edges near ingoingPoint.
* GetTurnGeometry fills candidates with angles of all the incoming and outgoint segments.
* \warning GetTurnGeometry should be used carefully because it's a time-consuming function.
* \warning In multilevel crossroads there is an insignificant possibility that candidates
* is filled with redundant segments of roads of different levels.
*/
void GetTurnGeometry(m2::PointD const & junctionPoint, m2::PointD const & ingoingPoint,
GeomTurnCandidateT & candidates, TRoutingMappingPtr const & mapping) const;
Index const * m_pIndex;
TFeatureGraphNodeVec m_CachedTargetTask;
m2::PointD m_CachedTargetPoint;
RoutingIndexManager m_indexManager;
RoutingVisualizerFn m_routingVisualization;
};
} // namespace routing
|