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

car_router.hpp « routing - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d32fc9252a687effc3e929227b0184ef889fb24e (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
#pragma once

#include "routing/index_router.hpp"
#include "routing/osrm_data_facade.hpp"
#include "routing/osrm_engine.hpp"
#include "routing/route.hpp"
#include "routing/router.hpp"
#include "routing/routing_mapping.hpp"

#include "std/unique_ptr.hpp"
#include "std/vector.hpp"

namespace feature
{
class TypesHolder;
}

class Index;
struct RawRouteData;
struct PhantomNode;
struct PathData;
class FeatureType;

namespace routing
{
class RoadGraphRouter;
struct RoutePathCross;
using TCheckedPath = vector<RoutePathCross>;

typedef vector<FeatureGraphNode> TFeatureGraphNodeVec;

class CarRouter : public IRouter
{
public:
  typedef vector<double> GeomTurnCandidateT;

  CarRouter(Index & index, TCountryFileFn const & countryFileFn,
            unique_ptr<IndexRouter> localRouter);

  virtual string GetName() const override;

  ResultCode CalculateRoute(m2::PointD const & startPoint, m2::PointD const & startDirection,
                            m2::PointD const & finalPoint, RouterDelegate const & delegate,
                            Route & route) override;

  virtual void ClearState() override;

  /*! Fast checking ability of route construction
   *  @param startPoint starting road point
   *  @param finalPoint final road point
   *  @param countryFileFn function for getting filename from point
   *  @param index mwmSet index
   *  @returns true if we can start routing process with a given data.
   */
  static bool CheckRoutingAbility(m2::PointD const & startPoint, m2::PointD const & finalPoint,
                                  TCountryFileFn const & countryFileFn, Index & index);

protected:
  /*!
   * \brief FindPhantomNodes finds OSRM graph nodes by point and graph name.
   * \param mapName Name of the map without data file extension.
   * \param point Point in lon/lat coordinates.
   * \param direction Movement direction vector in planar coordinates.
   * \param res Result graph nodes.
   * \param maxCount Maximum count of graph nodes in the result vector.
   * \param mapping Reference to routing indexes.
   * \return NoError if there are any nodes in res. RouteNotFound otherwise.
   */
  IRouter::ResultCode FindPhantomNodes(m2::PointD const & point, m2::PointD const & direction,
                                       TFeatureGraphNodeVec & res, size_t maxCount,
                                       TRoutingMappingPtr const & mapping);

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, RouterDelegate const & delegate,
                                      Route & route);

  // @TODO(bykoianko) When routing section implementation is merged to master
  // this method should be moved to routing loader.
  bool DoesEdgeIndexExist(Index::MwmId const & mwmId);
  bool AllMwmsHaveRoutingIndex() const;

  /*!
   * \brief Builds a route within one mwm using A* if edge index section is available and osrm
   * otherwise.
   * Then reconstructs the route and restores all route attributes.
   * \param route The found route is added to the |route| if the method returns true.
   */
  IRouter::ResultCode FindSingleRouteDispatcher(FeatureGraphNode const & source,
                                                FeatureGraphNode const & target,
                                                RouterDelegate const & delegate,
                                                TRoutingMappingPtr & mapping, Route & route);

  /*! Finds single shortest path in a single MWM between 2 sets of edges.
     * It's a route from multiple sources to multiple targets (MSMT).
     * \param source: vector of source edges to make path
     * \param target: 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.
     */
  IRouter::ResultCode FindRouteMSMT(TFeatureGraphNodeVec const & source, TFeatureGraphNodeVec const & target,
                                    RouterDelegate const & delegate, TRoutingMappingPtr & mapping, Route & route);

  Index & m_index;

  TFeatureGraphNodeVec m_cachedTargets;
  m2::PointD m_cachedTargetPoint;

  RoutingIndexManager m_indexManager;

  unique_ptr<IndexRouter> m_router;
};
}  // namespace routing