libosmscout 1.1.1
Loading...
Searching...
No Matches
RoutingDB.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_ROUTINGDB_H
2#define OSMSCOUT_ROUTINGDB_H
3
4/*
5 This source is part of the libosmscout library
6 Copyright (C) 2018 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 <memory>
24
26
28
31
34
35namespace osmscout {
36
42 class RoutingDatabase CLASS_FINAL
43 {
44 private:
45 TypeConfigRef typeConfig;
46 std::string path;
47 RouteNodeDataFile routeNodeDataFile;
48 IndexedDataFile<Id,Intersection> junctionDataFile;
49 ObjectVariantDataFile objectVariantDataFile;
50
51 public:
53
54 bool Open(const DatabaseRef& database);
55 void Close();
56
57 inline bool GetRouteNode(const Id& id,
58 RouteNodeRef& node) const
59 {
60 return routeNodeDataFile.Get(id,
61 node);
62 }
63
64 template<typename IteratorIn>
65 inline bool GetRouteNodes(IteratorIn begin, IteratorIn end, size_t size,
66 std::unordered_map<Id,RouteNodeRef>& routeNodeMap)
67 {
68 return routeNodeDataFile.Get(begin,
69 end,
70 size,
71 routeNodeMap);
72 }
73
74 template<typename IteratorIn>
75 inline bool GetRouteNodes(IteratorIn begin, IteratorIn end, size_t size,
76 std::vector<RouteNodeRef>& routeNodes)
77 {
78 return routeNodeDataFile.Get(begin,
79 end,
80 size,
81 routeNodes);
82 }
83
84 bool GetJunctions(const std::set<Id>& ids,
85 std::vector<JunctionRef>& junctions);
86
87 inline const std::vector<ObjectVariantData>& GetObjectVariantData() const
88 {
89 return objectVariantDataFile.GetData();
90 }
91
92 inline bool ContainsNode(const Id id) const
93 {
94 RouteNodeRef node;
95 routeNodeDataFile.Get(id, node);
96 return (bool)node;
97 }
98 };
99
103 using RoutingDatabaseRef = std::shared_ptr<RoutingDatabase>;
104}
105
106#endif
Definition Area.h:88
const std::vector< ObjectVariantData > & GetObjectVariantData() const
Definition RoutingDB.h:87
bool GetRouteNodes(IteratorIn begin, IteratorIn end, size_t size, std::vector< RouteNodeRef > &routeNodes)
Definition RoutingDB.h:75
bool GetRouteNodes(IteratorIn begin, IteratorIn end, size_t size, std::unordered_map< Id, RouteNodeRef > &routeNodeMap)
Definition RoutingDB.h:65
TypeInfoSetConstIterator begin() const
Definition TypeInfoSet.h:180
bool GetJunctions(const std::set< Id > &ids, std::vector< JunctionRef > &junctions)
bool GetRouteNode(const Id &id, RouteNodeRef &node) const
Definition RoutingDB.h:57
bool Open(const DatabaseRef &database)
bool ContainsNode(const Id id) const
Definition RoutingDB.h:92
std::shared_ptr< RoutingDatabase > RoutingDatabaseRef
Definition RoutingDB.h:103
uint64_t Id
Definition OSMScoutTypes.h:40
std::shared_ptr< TypeConfig > TypeConfigRef
Definition TypeConfig.h:1396
Definition Area.h:39
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