27 #include <terralib_buildconfig.h> 51 for(std::size_t i = 0; i < n; ++i)
57 for(std::size_t i = 0; i < n; ++i)
59 std::vector<KD_NODE*> reports;
61 te::gm::Envelope e(static_cast<double>(i), static_cast<double>(i), static_cast<double>(i), static_cast<double>(i));
72 std::vector<std::pair<te::gm::Coord2D, te::gm::Point> > dataset;
78 for(std::size_t i = 0; i < n; ++i)
85 dataset.push_back(std::pair<te::gm::Coord2D, te::gm::Point>(coord, point));
88 KD_ADAPTATIVE_TREE adaptativeTree(e);
89 adaptativeTree.
build(dataset);
92 std::vector<KD_ADAPTATIVE_NODE*> reports;
93 adaptativeTree.
search(e, reports);
96 std::vector<te::gm::Point> reports2;
97 adaptativeTree.
search(e, reports2);
101 std::vector<te::gm::Point> points;
102 points.push_back(
te::gm::Point(std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
103 std::vector<double> sqrDists;
void insert(const kdKey &key, const kdDataItem &item)
It inserts the data with a given key in tree.
This file contains include headers for TerraLib Spatial Access Methods module.
Several examples on how to use Spatial Access Methods in TerraLib.
void search(const te::gm::Envelope &e, std::vector< KdTreeNode * > &report) const
Range search query.
A class that represents a two dimensional K-d Tree (2-d Tree) that store data-elements into the leafs...
An utility struct for representing 2D coordinates.
te::sam::kdtree::AdaptativeNode< te::gm::Coord2D, std::vector< te::gm::Point >, te::gm::Point > KD_ADAPTATIVE_NODE
void Union(const Envelope &rhs)
It updates the envelop with coordinates of another envelope.
A point with x and y coordinate values.
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
An Envelope defines a 2D rectangular region.
void build(std::vector< std::pair< kdKey, kdDataItem > > &dataSet)
It inserts the data set into the tree.
te::sam::kdtree::AdaptativeIndex< KD_ADAPTATIVE_NODE > KD_ADAPTATIVE_TREE
A class that represents a two dimensional K-d Tree (2-d Tree).
te::sam::kdtree::Index< KD_NODE > KD_TREE
A class that represents an Kd-tree node.
te::sam::kdtree::Node< te::gm::Coord2D, std::pair< int32_t, int32_t >, std::pair< int32_t, int32_t > > KD_NODE
This file contains include headers for the TerraLib Common Runtime module.
This file contains include headers for the Vector Geometry model of TerraLib.
void search(const te::gm::Envelope &e, std::vector< KdTreeNode * > &report) const
Range search query.
A class that represents an Kd-tree node.
void nearestNeighborSearch(const kdKey &key, std::vector< kdDataItem > &report, std::vector< double > &sqrDists, const std::size_t &k) const
It searches the nearest data in nodes: you must pass an array of kdDataItem of size "k" with coordina...
void IndexPointUsingKdTree()
This example shows how to index a set of points using the K-d tree spatial access method...