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

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

#include "base/cancellable.hpp"

#include "routing/road_graph.hpp"
#include "routing/router.hpp"

#include "std/functional.hpp"
#include "std/string.hpp"
#include "std/vector.hpp"

namespace routing
{

// IRoutingAlgorithm is an abstract interface of a routing algorithm,
// which searches the optimal way between two junctions on the graph
class IRoutingAlgorithm : public my::Cancellable
{
public:
  enum class Result
  {
    OK,
    NoPath,
    Cancelled
  };

  virtual Result CalculateRoute(IRoadGraph const &  graph,
                                Junction const & startPos, Junction const & finalPos,
                                vector<Junction> & path) = 0;
};

string DebugPrint(IRoutingAlgorithm::Result const & result);

// Base class for AStar-based routing algorithms
class AStarRoutingAlgorithmBase : public IRoutingAlgorithm
{
protected:
  AStarRoutingAlgorithmBase(TRoutingVisualizerFn routingVisualizerFn);

  std::function<void(Junction const &)> m_onVisitJunctionFn;
};

// AStar routing algorithm implementation
class AStarRoutingAlgorithm : public AStarRoutingAlgorithmBase
{
public:
  explicit AStarRoutingAlgorithm(TRoutingVisualizerFn routingVisualizerFn = nullptr);

  // IRoutingAlgorithm overrides:
  Result CalculateRoute(IRoadGraph const &  graph,
                        Junction const & startPos, Junction const & finalPos,
                        vector<Junction> & path) override;
};

// AStar-bidirectional routing algorithm implementation
class AStarBidirectionalRoutingAlgorithm : public AStarRoutingAlgorithmBase
{
public:
  explicit AStarBidirectionalRoutingAlgorithm(TRoutingVisualizerFn routingVisualizerFn = nullptr);

  // IRoutingAlgorithm overrides:
  Result CalculateRoute(IRoadGraph const &  graph,
                        Junction const & startPos, Junction const & finalPos,
                        vector<Junction> & path) override;
};

}  // namespace routing