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

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

#include "routing/osrm2feature_map.hpp"
#include "routing/osrm_data_facade.hpp"

#include "indexer/index.hpp"

#include "geometry/point2d.hpp"

#include "std/vector.hpp"

#include "3party/osrm/osrm-backend/data_structures/query_edge.hpp"

namespace routing
{
/// Single graph node representation for routing task
struct FeatureGraphNode
{
  PhantomNode node;
  OsrmMappingTypes::FtSeg segment;
  m2::PointD segmentPoint;
  Index::MwmId mwmId;

  /*!
  * \brief fill FeatureGraphNode with values.
  * \param nodeId osrm node idetifier.
  * \param isStartNode true if this node will first in the path.
  * \param mwmName @nodeId refers node on the graph of this map.
  */
  FeatureGraphNode(NodeID const nodeId, bool const isStartNode, Index::MwmId const & id);

  FeatureGraphNode(NodeID const nodeId, NodeID const reverseNodeId, bool const isStartNode,
                   Index::MwmId const & id);

  /// \brief Invalid graph node constructor
  FeatureGraphNode();
};

/*!
 * \brief The RawPathData struct is our representation of OSRM PathData struct.
 * I use it for excluding dependency from OSRM. Contains OSRM node ID and it's weight.
 */
struct RawPathData
{
  NodeID node;
  EdgeWeight segmentWeight;

  RawPathData() : node(SPECIAL_NODEID), segmentWeight(INVALID_EDGE_WEIGHT) {}

  RawPathData(NodeID node, EdgeWeight segmentWeight)
      : node(node), segmentWeight(segmentWeight)
  {
  }
};

/*!
 * \brief The OSRM routing result struct. Contains the routing result, it's cost and source and
 * target edges.
 * \property shortestPathLength Length of a founded route.
 * \property unpackedPathSegments Segments of a founded route.
 * \property sourceEdge Source graph node of a route.
 * \property targetEdge Target graph node of a route.
 */
struct RawRoutingResult
{
  int shortestPathLength;
  vector<vector<RawPathData>> unpackedPathSegments;
  FeatureGraphNode sourceEdge;
  FeatureGraphNode targetEdge;
};

//@todo (dragunov) make proper name
using TRoutingNodes = vector<FeatureGraphNode>;
using TRawDataFacade = OsrmRawDataFacade<QueryEdge::EdgeData>;

/*!
   * \brief FindWeightsMatrix Find weights matrix from sources to targets. WARNING it finds only
 * weights, not pathes.
   * \param sources Sources graph nodes vector. Each source is the representation of a start OSRM
 * node.
   * \param targets Targets graph nodes vector. Each target is the representation of a finish OSRM
 * node.
   * \param facade Osrm data facade reference.
   * \param packed Result vector with weights. Source nodes are rows.
   * cost(source1 -> target1) cost(source1 -> target2) cost(source2 -> target1) cost(source2 ->
 * target2)
   */
void FindWeightsMatrix(TRoutingNodes const & sources, TRoutingNodes const & targets,
                       TRawDataFacade & facade, vector<EdgeWeight> & result);

/*! Finds single shortest path in a single MWM between 2 OSRM nodes
   * \param source Source OSRM graph node to make path.
   * \param taget Target OSRM graph node to make path.
   * \param facade OSRM routing data facade to recover graph information.
   * \param rawRoutingResult Routing result structure.
   * \return true when path exists, false otherwise.
   */
bool FindSingleRoute(FeatureGraphNode const & source, FeatureGraphNode const & target,
                     TRawDataFacade & facade, RawRoutingResult & rawRoutingResult);

}  // namespace routing