libosmscout 1.1.1
Loading...
Searching...
No Matches
SimpleRoutingService.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_SIMPLEROUTINGSERVICE_H
2#define OSMSCOUT_SIMPLEROUTINGSERVICE_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2012 Tim Teulings
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21*/
22
23#include <atomic>
24#include <functional>
25#include <list>
26#include <memory>
27#include <set>
28#include <unordered_map>
29#include <unordered_set>
30
31#include <osmscout/lib/CoreFeatures.h>
32
33#include <osmscout/Point.h>
34
35#include <osmscout/TypeConfig.h>
36
38
39// Datafiles
41
44
45// Routing
53
55#include <osmscout/util/Cache.h>
56
58
59namespace osmscout {
60
62
64 {
65 private:
66 ObjectFileRef object;
67 Distance distance;
68 WayRef way;
69 AreaRef area;
70 std::string name;
71
72 public:
74
75 ObjectFileRef GetObject() const
76 {
77 return object;
78 }
79
80 Distance GetDistance() const
81 {
82 return distance;
83 }
84
85 WayRef GetWay() const
86 {
87 return way;
88 }
89
91 {
92 return area;
93 }
94
95 std::string GetName() const
96 {
97 return name;
98 }
99 };
100
114 {
115
116 private:
117 DatabaseRef database;
118 std::string filenamebase;
119 AccessFeatureValueReader accessReader;
120 bool isOpen;
121
122 std::string path;
123
124 RoutingDatabase routingDatabase;
125
126 private:
127 bool HasNodeWithId(const std::vector<Point>& nodes) const;
128
129 protected:
130 Vehicle GetVehicle(const RoutingProfile& profile) override;
131
132 bool CanUse(const RoutingProfile& profile,
133 DatabaseId database,
134 const RouteNode& routeNode,
135 size_t pathIndex) override;
136
137 bool CanUseForward(const RoutingProfile& profile,
138 const DatabaseId& database,
139 const WayRef& way) override;
140
141 bool CanUseBackward(const RoutingProfile& profile,
142 const DatabaseId& database,
143 const WayRef& way) override;
144
145 double GetCosts(const RoutingProfile& profile,
146 DatabaseId database,
147 const RouteNode& routeNode,
148 size_t inPathIndex,
149 size_t outPathIndex) override;
150
151 double GetCosts(const RoutingProfile& profile,
152 DatabaseId database,
153 const WayRef &way,
154 const Distance &wayLength) override;
155
156 double GetUTurnCost(const RoutingProfile& profile, const DatabaseId databaseId) override;
157
158 double GetEstimateCosts(const RoutingProfile& profile,
159 DatabaseId database,
160 const Distance &targetDistance) override;
161
162 double GetCostLimit(const RoutingProfile& profile,
163 DatabaseId database,
164 const Distance &targetDistance) override;
165
166 std::string GetCostString(const RoutingProfile& profile,
167 DatabaseId database,
168 double cost) const override;
169
170 bool GetRouteNodes(const std::set<DBId> &routeNodeIds,
171 std::unordered_map<DBId,RouteNodeRef> &routeNodeMap) override;
172
173 bool GetRouteNode(const DBId &id,
174 RouteNodeRef &node) override;
175
176 bool GetWayByOffset(const DBFileOffset &offset,
177 WayRef &way) override;
178
179 bool GetWaysByOffset(const std::set<DBFileOffset> &wayOffsets,
180 std::unordered_map<DBFileOffset,WayRef> &wayMap) override;
181
182 bool GetAreaByOffset(const DBFileOffset &offset,
183 AreaRef &area) override;
184
185 bool GetAreasByOffset(const std::set<DBFileOffset> &areaOffsets,
186 std::unordered_map<DBFileOffset,AreaRef> &areaMap) override;
187
189
190 std::vector<DBId> GetNodeTwins(const RoutingProfile& state,
191 DatabaseId database,
192 Id id) override;
193
194 public:
196 const RouterParameter& parameter,
197 const std::string& filenamebase);
199
200 bool Open();
201 bool IsOpen() const;
202 void Close();
203
205
207 const std::vector<GeoCoord>& via,
208 const Distance &radius,
209 const RoutingParameter& parameter);
210
220 RoutePositionResult GetRoutableNode(const ObjectFileRef& objRef,
221 const RoutingProfile& profile) const;
222
246 RoutePositionResult GetClosestRoutableNode(const GeoCoord& coord,
247 const RoutingProfile& profile,
248 const Distance &radius) const;
249
251 Vehicle vehicle,
252 const Distance &maxRadius);
253
254 std::map<DatabaseId, std::string> GetDatabaseMapping() const override;
255
257 };
258
261 using SimpleRoutingServiceRef = std::shared_ptr<SimpleRoutingService>;
262
267}
268
269#endif
#define OSMSCOUT_API
Definition CoreImportExport.h:45
AbstractRoutingService(const RouterParameter &parameter)
Definition SimpleRoutingService.h:64
friend SimpleRoutingService
Definition SimpleRoutingService.h:73
std::string GetName() const
Definition SimpleRoutingService.h:95
AreaRef GetArea() const
Definition SimpleRoutingService.h:90
WayRef GetWay() const
Definition SimpleRoutingService.h:85
ObjectFileRef GetObject() const
Definition SimpleRoutingService.h:75
Distance GetDistance() const
Definition SimpleRoutingService.h:80
Definition RouteData.h:36
Definition RouteNode.h:62
Definition RoutingProfile.h:127
Definition SimpleRoutingService.h:114
double GetUTurnCost(const RoutingProfile &profile, const DatabaseId databaseId) override
bool CanUse(const RoutingProfile &profile, DatabaseId database, const RouteNode &routeNode, size_t pathIndex) override
bool CanUseForward(const RoutingProfile &profile, const DatabaseId &database, const WayRef &way) override
double GetCostLimit(const RoutingProfile &profile, DatabaseId database, const Distance &targetDistance) override
bool GetWaysByOffset(const std::set< DBFileOffset > &wayOffsets, std::unordered_map< DBFileOffset, WayRef > &wayMap) override
std::string GetCostString(const RoutingProfile &profile, DatabaseId database, double cost) const override
double GetCosts(const RoutingProfile &profile, DatabaseId database, const WayRef &way, const Distance &wayLength) override
bool CanUseBackward(const RoutingProfile &profile, const DatabaseId &database, const WayRef &way) override
double GetEstimateCosts(const RoutingProfile &profile, DatabaseId database, const Distance &targetDistance) override
bool GetRouteNodes(const std::set< DBId > &routeNodeIds, std::unordered_map< DBId, RouteNodeRef > &routeNodeMap) override
double GetCosts(const RoutingProfile &profile, DatabaseId database, const RouteNode &routeNode, size_t inPathIndex, size_t outPathIndex) override
bool GetAreasByOffset(const std::set< DBFileOffset > &areaOffsets, std::unordered_map< DBFileOffset, AreaRef > &areaMap) override
bool GetAreaByOffset(const DBFileOffset &offset, AreaRef &area) override
RoutingResult CalculateRouteViaCoords(RoutingProfile &profile, const std::vector< GeoCoord > &via, const Distance &radius, const RoutingParameter &parameter)
TypeConfigRef GetTypeConfig() const
ClosestRoutableObjectResult GetClosestRoutableObject(const GeoCoord &location, Vehicle vehicle, const Distance &maxRadius)
RoutePositionResult GetRoutableNode(const ObjectFileRef &objRef, const RoutingProfile &profile) const
RoutePositionResult GetClosestRoutableNode(const GeoCoord &coord, const RoutingProfile &profile, const Distance &radius) const
std::map< DatabaseId, std::string > GetDatabaseMapping() const override
SimpleRoutingService(const DatabaseRef &database, const RouterParameter &parameter, const std::string &filenamebase)
bool GetWayByOffset(const DBFileOffset &offset, WayRef &way) override
bool GetRouteNode(const DBId &id, RouteNodeRef &node) override
Vehicle GetVehicle(const RoutingProfile &profile) override
std::vector< DBId > GetNodeTwins(const RoutingProfile &state, DatabaseId database, Id id) override
bool ResolveRouteDataJunctions(RouteData &route) override
std::shared_ptr< SimpleRoutingService > SimpleRoutingServiceRef
Definition SimpleRoutingService.h:261
uint64_t Id
Definition OSMScoutTypes.h:40
std::shared_ptr< TypeConfig > TypeConfigRef
Definition TypeConfig.h:1396
Definition Area.h:39
std::shared_ptr< Way > WayRef
Definition Way.h:213
std::shared_ptr< Area > AreaRef
Definition Area.h:360
uint32_t DatabaseId
Definition DBFileOffset.h:30
std::shared_ptr< RouteNode > RouteNodeRef
Definition RouteNode.h:177
std::shared_ptr< Database > DatabaseRef
Reference counted reference to an Database instance.
Definition Database.h:555
Vehicle
Definition OSMScoutTypes.h:55
FeatureValueReader< AccessFeature, AccessFeatureValue > AccessFeatureValueReader
Definition AccessFeature.h:276
Definition DBFileOffset.h:93
Definition DBFileOffset.h:39