alaCarte Maps
Renderer for OpenStreetMap tiles
geodata.hpp
Go to the documentation of this file.
1 
21 #pragma once
22 #ifndef GEODATA_HPP
23 #define GEODATA_HPP
24 
25 
26 #include "settings.hpp"
27 #include <fstream>
28 #include <boost/archive/text_oarchive.hpp>
29 #include <boost/archive/text_iarchive.hpp>
30 #include <boost/serialization/vector.hpp>
31 #include <boost/serialization/shared_ptr.hpp>
32 #include <boost/serialization/shared_ptr_132.hpp>
33 
34 class Node;
35 class Way;
36 class Relation;
37 class NodeKdTree;
38 template<class id_t, class data_t>
39 class RTree;
40 
41 class Geodata
42 {
43 public:
44  Geodata() = default;
45  virtual ~Geodata() = default;
46 
47  TESTABLE void insertNodes(const shared_ptr<std::vector<Node> >& nodes);
48  TESTABLE void insertWays(const shared_ptr<std::vector<Way> >& ways);
49  TESTABLE void insertRelations(const shared_ptr<std::vector<Relation> >& relations);
50 
51  bool containsData(const FixedRect &rect) const;
52  TESTABLE shared_ptr<std::vector<NodeId> > getNodeIDs(const FixedRect& rect) const;
53 
54  TESTABLE shared_ptr<std::vector<WayId> > getWayIDs(const FixedRect& rect) const;
55  TESTABLE shared_ptr<std::vector<RelId> > getRelationIDs(const FixedRect& rect) const;
56 
57  TESTABLE Node* getNode(NodeId id) const;
58  TESTABLE Way* getWay(WayId id) const ;
60 
61  TESTABLE void load(const string& path);
62  TESTABLE void save(const string& path);
63 
64 protected:
65  shared_ptr<std::vector<Way> > ways;
66  shared_ptr<std::vector<Node> > nodes;
67  shared_ptr<std::vector<Relation> > relations;
68 
70  shared_ptr<RTree<NodeId, FixedPoint>> nodesTree;
71  shared_ptr<RTree<WayId, FixedRect>> waysTree;
72  shared_ptr<RTree<RelId, FixedRect>> relTree;
73 
74 private:
75  void buildTrees(const string& nodePath, const string& wayPath, const string& relationPath);
76  void serialize(const string& serPath) const;
77  TESTABLE FixedRect calculateBoundingBox(const Way& way) const;
78  TESTABLE FixedRect calculateBoundingBox(const Relation& relation) const;
79  FixedRect calculateBoundingBox(const std::vector<NodeId>& nodeIDs) const;
80  FixedRect calculateBoundingBox(const std::vector<WayId>& nodeIDs) const;
81 
83  template<typename Archive>
84  void serialize(Archive &ar, const unsigned int version){
85  ar & nodes;
86  ar & ways;
87  ar & relations;
88  ar & nodesTree;
89  ar & waysTree;
90  ar & relTree;
91  }
92 
93 };
94 
95 #endif
TESTABLE FixedRect calculateBoundingBox(const Way &way) const
Definition: geodata.cpp:218
shared_ptr< std::vector< Relation > > relations
Definition: geodata.hpp:67
TESTABLE shared_ptr< std::vector< WayId > > getWayIDs(const FixedRect &rect) const
Definition: geodata.cpp:115
Definition: node.hpp:28
Geodata()=default
virtual ~Geodata()=default
bool containsData(const FixedRect &rect) const
Definition: geodata.cpp:100
shared_ptr< std::vector< Way > > ways
Definition: geodata.hpp:65
TESTABLE void save(const string &path)
Definition: geodata.cpp:184
TESTABLE Way * getWay(WayId id) const
Definition: geodata.cpp:136
TESTABLE void insertWays(const shared_ptr< std::vector< Way > > &ways)
Definition: geodata.cpp:86
void serialize(Archive &ar, const unsigned int version)
Definition: geodata.hpp:84
shared_ptr< RTree< NodeId, FixedPoint > > nodesTree
note the trees are initialized by buildTree on serialisation
Definition: geodata.hpp:70
void buildTrees(const string &nodePath, const string &wayPath, const string &relationPath)
This file is part of alaCarte.
Definition: geodata.cpp:49
void serialize(const string &serPath) const
Definition: geodata.cpp:175
TESTABLE shared_ptr< std::vector< RelId > > getRelationIDs(const FixedRect &rect) const
Definition: geodata.cpp:123
shared_ptr< RTree< RelId, FixedRect > > relTree
Definition: geodata.hpp:72
TESTABLE void insertRelations(const shared_ptr< std::vector< Relation > > &relations)
Definition: geodata.cpp:93
shared_ptr< RTree< WayId, FixedRect > > waysTree
Definition: geodata.hpp:71
TESTABLE Node * getNode(NodeId id) const
Definition: geodata.cpp:131
shared_ptr< std::vector< Node > > nodes
Definition: geodata.hpp:66
friend class boost::serialization::access
Definition: geodata.hpp:82
#define TESTABLE
Definition: settings.hpp:85
TESTABLE void load(const string &path)
Definition: geodata.cpp:146
TESTABLE void insertNodes(const shared_ptr< std::vector< Node > > &nodes)
Definition: geodata.cpp:79
TESTABLE Relation * getRelation(RelId id) const
Definition: geodata.cpp:141
TESTABLE shared_ptr< std::vector< NodeId > > getNodeIDs(const FixedRect &rect) const
Definition: geodata.cpp:107
Definition: way.hpp:31