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
|
#pragma once
#include "routing/checkpoints.hpp"
#include "routing/route.hpp"
#include "routing/router_delegate.hpp"
#include "geometry/point2d.hpp"
#include "geometry/rect2d.hpp"
#include "base/cancellable.hpp"
#include <functional>
#include <string>
namespace routing
{
using TCountryFileFn = std::function<std::string(m2::PointD const &)>;
using CourntryRectFn = std::function<m2::RectD(std::string const & countryId)>;
using CountryParentNameGetterFn = std::function<std::string(std::string const &)>;
class Route;
/// Routing engine type.
enum class RouterType
{
// @TODO It's necessary to rename Vehicle value to Car.
Vehicle = 0, /// For Car routing.
Pedestrian, /// For A star pedestrian routing.
Bicycle, /// For A star bicycle routing.
Taxi, /// For taxi route calculation Vehicle routing is used.
Transit, /// For A star pedestrian + transit routing.
Count /// Number of router types.
};
std::string ToString(RouterType type);
RouterType FromString(std::string const & str);
std::string DebugPrint(RouterType type);
class IRouter
{
public:
/// Routing possible statuses enumeration.
/// \warning this enum has JNI mirror!
/// \see android/src/com/mapswithme/maps/routing/ResultCodesHelper.java
// TODO(gardster): Please check what items become obsolete now
enum ResultCode // TODO(mgsergio) enum class
{
NoError = 0,
Cancelled = 1,
NoCurrentPosition = 2,
InconsistentMWMandRoute = 3,
RouteFileNotExist = 4,
StartPointNotFound = 5,
EndPointNotFound = 6,
PointsInDifferentMWM = 7,
RouteNotFound = 8,
NeedMoreMaps = 9,
InternalError = 10,
FileTooOld = 11,
IntermediatePointNotFound = 12,
TransitRouteNotFoundNoNetwork = 13,
TransitRouteNotFoundTooLongPedestrian = 14,
RouteNotFoundRedressRouteError = 15,
};
virtual ~IRouter() {}
/// Return unique name of a router implementation.
virtual std::string GetName() const = 0;
/// Clear all temporary buffers.
virtual void ClearState() {}
/// Override this function with routing implementation.
/// It will be called in separate thread and only one function will processed in same time.
/// @warning please support Cancellable interface calls. You must stop processing when it is true.
///
/// @param startPoint point to start routing
/// @param startDirection start direction for routers with high cost of the turnarounds
/// @param finalPoint target point for route
/// @param adjust adjust route to the previous one if possible
/// @param delegate callback functions and cancellation flag
/// @param route result route
/// @return ResultCode error code or NoError if route was initialised
/// @see Cancellable
virtual ResultCode CalculateRoute(Checkpoints const & checkpoints,
m2::PointD const & startDirection, bool adjust,
RouterDelegate const & delegate, Route & route) = 0;
};
} // namespace routing
|