alaCarte Maps
Renderer for OpenStreetMap tiles
RTree< id_t, data_t > Class Template Reference

#include <geodata.hpp>

Classes

class  RLeaf
 
class  RNode
 

Public Member Functions

 RTree ()=default
 
void build (std::vector< data_t > &data, const string &leafPath)
 starts to build the tree for the given data More...
 
bool search (boost::shared_ptr< std::vector< id_t > > &result, const FixedRect &rect, bool returnOnFirst=false) const
 if returnOnFirst is set it return true if it found data in the querry rectangle More...
 
bool contains (const FixedRect &rect) const
 
void setLeafFile (const string &path, uint64_t offset, uint64_t length)
 is called after deserialisation to set offets in the archive More...
 

Private Member Functions

void buildLeaves (const std::vector< data_t > &rects, const string &leafPath)
 
void writeLeaves (const std::vector< id_t > &ids, const std::vector< data_t > &rects, const string &leafPath)
 Fills first tree layer for leaf RNode objects an saves RLeaf objects to file. More...
 
void buildLevels ()
 builds all levels above leafs More...
 
RLeaf< id_t, data_t > * readLeaf (uint32_t nodeIdx, uint32_t childIdx) const
 reads a leaf from file More...
 
void getSubTree (uint32_t rootIdx, boost::shared_ptr< std::vector< id_t > > &ids) const
 used when a sub-tree is fully contained in the search rectangle More...
 
FixedRect getBoundingBox (const FixedRect keys[], size_t size) const
 size muste be greater than 0 More...
 
FixedRect getBoundingBox (const FixedPoint keys[], size_t size) const
 size muste be greater than 0 More...
 
coord_t getX (const FixedPoint &p)
 get x coordinate of point based types More...
 
coord_t getX (const FixedRect &r)
 for bounding box based types use the center More...
 
coord_t getY (const FixedPoint &p)
 get x coordinate of point based types More...
 
coord_t getY (const FixedRect &r)
 for bounding box based types use the center More...
 
bool searchLeaf (const RLeaf< id_t, FixedPoint > *leaf, boost::shared_ptr< std::vector< id_t > > &result, const FixedRect &rect, bool returnOnFirst) const
 Specialisation for point based data. More...
 
bool searchLeaf (const RLeaf< id_t, FixedRect > *leaf, boost::shared_ptr< std::vector< id_t > > &result, const FixedRect &rect, bool returnOnFirst) const
 Specialisation for bounding box based data. More...
 
bool validate () const
 debugging function to check validity of bounding boxes More...
 
void printTree () const
 For debugging. More...
 
void printLeaves (const string &leafPath) const
 For debugging. More...
 
template<typename Archive >
void load (Archive &ar, const unsigned int version)
 
template<typename Archive >
void save (Archive &ar, const unsigned int version) const
 

Private Attributes

std::vector< RNodetree
 
boost::iostreams::mapped_file_source input
 
uint64_t offset
 
uint64_t length
 

Friends

class boost::serialization::access
 

Detailed Description

template<class id_t, class data_t>
class RTree< id_t, data_t >

Definition at line 39 of file geodata.hpp.

Constructor & Destructor Documentation

template<class id_t , class data_t >
RTree< id_t, data_t >::RTree ( )
default

Member Function Documentation

template<class id_t , class data_t >
void RTree< id_t, data_t >::build ( std::vector< data_t > &  data,
const string leafPath 
)

starts to build the tree for the given data

Definition at line 169 of file rtree.hpp.

template<class id_t , class data_t >
void RTree< id_t, data_t >::buildLeaves ( const std::vector< data_t > &  rects,
const string leafPath 
)
private

Definition at line 224 of file rtree.hpp.

template<class id_t , class data_t >
void RTree< id_t, data_t >::buildLevels ( )
private

builds all levels above leafs

Definition at line 318 of file rtree.hpp.

template<class id_t , class data_t >
bool RTree< id_t, data_t >::contains ( const FixedRect rect) const
inline

Definition at line 107 of file rtree.hpp.

template<class id_t , class data_t >
FixedRect RTree< id_t, data_t >::getBoundingBox ( const FixedRect  keys[],
size_t  size 
) const
private

size muste be greater than 0

Definition at line 542 of file rtree.hpp.

template<class id_t , class data_t >
FixedRect RTree< id_t, data_t >::getBoundingBox ( const FixedPoint  keys[],
size_t  size 
) const
private

size muste be greater than 0

Definition at line 554 of file rtree.hpp.

template<class id_t , class data_t >
void RTree< id_t, data_t >::getSubTree ( uint32_t  rootIdx,
boost::shared_ptr< std::vector< id_t > > &  ids 
) const
private

used when a sub-tree is fully contained in the search rectangle

Definition at line 513 of file rtree.hpp.

template<class id_t , class data_t >
coord_t RTree< id_t, data_t >::getX ( const FixedPoint p)
private

get x coordinate of point based types

Definition at line 203 of file rtree.hpp.

template<class id_t , class data_t >
coord_t RTree< id_t, data_t >::getX ( const FixedRect r)
private

for bounding box based types use the center

Definition at line 195 of file rtree.hpp.

template<class id_t , class data_t >
coord_t RTree< id_t, data_t >::getY ( const FixedPoint p)
private

get x coordinate of point based types

Definition at line 218 of file rtree.hpp.

template<class id_t , class data_t >
coord_t RTree< id_t, data_t >::getY ( const FixedRect r)
private

for bounding box based types use the center

Definition at line 210 of file rtree.hpp.

template<class id_t , class data_t >
template<typename Archive >
void RTree< id_t, data_t >::load ( Archive ar,
const unsigned int  version 
)
inlineprivate

Definition at line 156 of file rtree.hpp.

template<class id_t , class data_t >
void RTree< id_t, data_t >::printLeaves ( const string leafPath) const
private

For debugging.

Definition at line 566 of file rtree.hpp.

template<class id_t , class data_t >
void RTree< id_t, data_t >::printTree ( ) const
private

For debugging.

Definition at line 584 of file rtree.hpp.

template<class id_t , class data_t >
RTree< id_t, data_t >::RLeaf< id_t, data_t > * RTree< id_t, data_t >::readLeaf ( uint32_t  nodeIdx,
uint32_t  childIdx 
) const
private

reads a leaf from file

Definition at line 361 of file rtree.hpp.

template<class id_t , class data_t >
template<typename Archive >
void RTree< id_t, data_t >::save ( Archive ar,
const unsigned int  version 
) const
inlineprivate

Definition at line 160 of file rtree.hpp.

template<class id_t , class data_t >
bool RTree< id_t, data_t >::search ( boost::shared_ptr< std::vector< id_t > > &  result,
const FixedRect rect,
bool  returnOnFirst = false 
) const

if returnOnFirst is set it return true if it found data in the querry rectangle

Definition at line 443 of file rtree.hpp.

template<class id_t , class data_t >
bool RTree< id_t, data_t >::searchLeaf ( const RLeaf< id_t, FixedPoint > *  leaf,
boost::shared_ptr< std::vector< id_t > > &  result,
const FixedRect rect,
bool  returnOnFirst 
) const
private

Specialisation for point based data.

Definition at line 423 of file rtree.hpp.

template<class id_t , class data_t >
bool RTree< id_t, data_t >::searchLeaf ( const RLeaf< id_t, FixedRect > *  leaf,
boost::shared_ptr< std::vector< id_t > > &  result,
const FixedRect rect,
bool  returnOnFirst 
) const
private

Specialisation for bounding box based data.

Definition at line 403 of file rtree.hpp.

template<class id_t , class data_t >
void RTree< id_t, data_t >::setLeafFile ( const string path,
uint64_t  offset,
uint64_t  length 
)
inline

is called after deserialisation to set offets in the archive

Definition at line 114 of file rtree.hpp.

template<class id_t , class data_t >
bool RTree< id_t, data_t >::validate ( ) const
private

debugging function to check validity of bounding boxes

Definition at line 370 of file rtree.hpp.

template<class id_t , class data_t >
void RTree< id_t, data_t >::writeLeaves ( const std::vector< id_t > &  ids,
const std::vector< data_t > &  rects,
const string leafPath 
)
private

Fills first tree layer for leaf RNode objects an saves RLeaf objects to file.

Definition at line 268 of file rtree.hpp.

Friends And Related Function Documentation

template<class id_t , class data_t >
friend class boost::serialization::access
friend

Definition at line 154 of file rtree.hpp.

Member Data Documentation

template<class id_t , class data_t >
boost::iostreams::mapped_file_source RTree< id_t, data_t >::input
private

Definition at line 125 of file rtree.hpp.

template<class id_t , class data_t >
uint64_t RTree< id_t, data_t >::length
private

Definition at line 127 of file rtree.hpp.

template<class id_t , class data_t >
uint64_t RTree< id_t, data_t >::offset
private

Definition at line 126 of file rtree.hpp.

template<class id_t , class data_t >
std::vector<RNode> RTree< id_t, data_t >::tree
private

Definition at line 124 of file rtree.hpp.


The documentation for this class was generated from the following files: