libosmscout  1.1.1
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 
25 #include <osmscout/Database.h>
26 #include <osmscout/DataFile.h>
27 #include <osmscout/Intersection.h>
29 
32 
33 namespace osmscout {
34 
40  class RoutingDatabase CLASS_FINAL
41  {
42  private:
43  TypeConfigRef typeConfig;
44  std::string path;
45  RouteNodeDataFile routeNodeDataFile;
46  IndexedDataFile<Id,Intersection> junctionDataFile;
47  ObjectVariantDataFile objectVariantDataFile;
48 
49  public:
50  RoutingDatabase();
51 
52  bool Open(const DatabaseRef& database);
53  void Close();
54 
55  inline bool GetRouteNode(const Id& id,
56  RouteNodeRef& node) const
57  {
58  return routeNodeDataFile.Get(id,
59  node);
60  }
61 
62  template<typename IteratorIn>
63  inline bool GetRouteNodes(IteratorIn begin, IteratorIn end, size_t size,
64  std::unordered_map<Id,RouteNodeRef>& routeNodeMap)
65  {
66  return routeNodeDataFile.Get(begin,
67  end,
68  size,
69  routeNodeMap);
70  }
71 
72  template<typename IteratorIn>
73  inline bool GetRouteNodes(IteratorIn begin, IteratorIn end, size_t size,
74  std::vector<RouteNodeRef>& routeNodes)
75  {
76  return routeNodeDataFile.Get(begin,
77  end,
78  size,
79  routeNodes);
80  }
81 
82  bool GetJunctions(const std::set<Id>& ids,
83  std::vector<JunctionRef>& junctions);
84 
85  inline const std::vector<ObjectVariantData>& GetObjectVariantData() const
86  {
87  return objectVariantDataFile.GetData();
88  }
89 
90  inline bool ContainsNode(const Id id) const
91  {
92  RouteNodeRef node;
93  routeNodeDataFile.Get(id, node);
94  return (bool)node;
95  }
96  };
97 
101  using RoutingDatabaseRef = std::shared_ptr<RoutingDatabase>;
102 }
103 
104 #endif
uint64_t Id
Definition: OSMScoutTypes.h:41
bool GetRouteNodes(IteratorIn begin, IteratorIn end, size_t size, std::unordered_map< Id, RouteNodeRef > &routeNodeMap)
Definition: RoutingDB.h:63
bool GetRouteNode(const Id &id, RouteNodeRef &node) const
Definition: RoutingDB.h:55
std::shared_ptr< Database > DatabaseRef
Reference counted reference to an Database instance.
Definition: Database.h:555
Definition: Area.h:38
std::shared_ptr< RoutingDatabase > RoutingDatabaseRef
Definition: RoutingDB.h:101
#define CLASS_FINAL
Definition: Compiler.h:26
bool ContainsNode(const Id id) const
Definition: RoutingDB.h:90
std::shared_ptr< RouteNode > RouteNodeRef
Definition: RouteNode.h:160
const std::vector< ObjectVariantData > & GetObjectVariantData() const
Definition: RoutingDB.h:85
bool GetRouteNodes(IteratorIn begin, IteratorIn end, size_t size, std::vector< RouteNodeRef > &routeNodes)
Definition: RoutingDB.h:73
std::shared_ptr< TypeConfig > TypeConfigRef
Definition: TypeConfig.h:1227