GEOS
3.9.1dev
|
#include <KdTree.h>
Classes | |
class | AccumulatingVisitor |
class | BestMatchVisitor |
Public Member Functions | |
KdTree () | |
KdTree (double p_tolerance) | |
bool | isEmpty () |
KdNode * | insert (const geom::Coordinate &p) |
KdNode * | insert (const geom::Coordinate &p, void *data) |
void | query (const geom::Envelope &queryEnv, KdNodeVisitor &visitor) |
std::unique_ptr< std::vector< KdNode * > > | query (const geom::Envelope &queryEnv) |
void | query (const geom::Envelope &queryEnv, std::vector< KdNode * > &result) |
KdNode * | query (const geom::Coordinate &queryPt) |
Static Public Member Functions | |
static std::unique_ptr< std::vector< geom::Coordinate > > | toCoordinates (std::vector< KdNode * > &kdnodes) |
static std::unique_ptr< std::vector< geom::Coordinate > > | toCoordinates (std::vector< KdNode * > &kdnodes, bool includeRepeated) |
Private Member Functions | |
KdNode * | findBestMatchNode (const geom::Coordinate &p) |
KdNode * | insertExact (const geom::Coordinate &p, void *data) |
void | queryNode (KdNode *currentNode, const geom::Envelope &queryEnv, bool odd, KdNodeVisitor &visitor) |
KdNode * | queryNodePoint (KdNode *currentNode, const geom::Coordinate &queryPt, bool odd) |
KdNode * | createNode (const geom::Coordinate &p, void *data) |
Private Attributes | |
std::deque< KdNode > | nodeQue |
KdNode * | root |
size_t | numberOfNodes |
double | tolerance |
An implementation of a 2-D KD-Tree. KD-trees provide fast range searching on point data.
This implementation supports detecting and snapping points which are closer than a given distance tolerance. If the same point (up to tolerance) is inserted more than once, it is snapped to the existing node. In other words, if a point is inserted which lies within the tolerance of a node already in the index, it is snapped to that node. When a point is snapped to a node then a new node is not created but the count of the existing node is incremented. If more than one node in the tree is within tolerance of an inserted point, the closest and then lowest node is snapped to.
|
inline |
|
private |
Create a node on a locally managed deque to allow easy disposal and hopefully faster allocation as well.
|
private |
KdNode* geos::index::kdtree::KdTree::insert | ( | const geom::Coordinate & | p | ) |
Inserts a new point in the kd-tree.
KdNode* geos::index::kdtree::KdTree::insert | ( | const geom::Coordinate & | p, |
void * | data | ||
) |
|
private |
void geos::index::kdtree::KdTree::query | ( | const geom::Envelope & | queryEnv, |
KdNodeVisitor & | visitor | ||
) |
Performs a range search of the points in the index and visits all nodes found.
std::unique_ptr<std::vector<KdNode*> > geos::index::kdtree::KdTree::query | ( | const geom::Envelope & | queryEnv | ) |
Performs a range search of the points in the index.
void geos::index::kdtree::KdTree::query | ( | const geom::Envelope & | queryEnv, |
std::vector< KdNode * > & | result | ||
) |
Performs a range search of the points in the index.
KdNode* geos::index::kdtree::KdTree::query | ( | const geom::Coordinate & | queryPt | ) |
Searches for a given point in the index and returns its node if found.
|
private |
|
private |
|
static |
Converts a collection of KdNodes to an vector of geom::Coordinates.
kdnodes | a collection of nodes |
|
static |
Converts a collection of KdNodes to an vector of geom::Coordinates, specifying whether repeated nodes should be represented by multiple coordinates.
kdnodes | a collection of nodes |
includeRepeated | true if repeated nodes should be included multiple times |
|
private |