QGIS API Documentation
3.2.0-Bonn (bc43194)
|
A spatial index for QgsFeature objects. More...
#include <qgsspatialindex.h>
Public Member Functions | |
QgsSpatialIndex () | |
Constructor for QgsSpatialIndex. More... | |
QgsSpatialIndex (const QgsFeatureIterator &fi, QgsFeedback *feedback=nullptr) | |
Constructor - creates R-tree and bulk loads it with features from the iterator. More... | |
QgsSpatialIndex (const QgsFeatureSource &source, QgsFeedback *feedback=nullptr) | |
Constructor - creates R-tree and bulk loads it with features from the source. More... | |
QgsSpatialIndex (const QgsSpatialIndex &other) | |
Copy constructor. More... | |
~QgsSpatialIndex () | |
Destructor finalizes work with spatial index. More... | |
bool | deleteFeature (const QgsFeature &feature) |
Removes a feature from the index. More... | |
bool | insertFeature (const QgsFeature &feature) |
Adds a feature to the index. More... | |
bool | insertFeature (QgsFeatureId id, const QgsRectangle &bounds) |
Add a feature id to the index with a specified bounding box. More... | |
QList< QgsFeatureId > | intersects (const QgsRectangle &rectangle) const |
Returns a list of features with a bounding box which intersects the specified rectangle. More... | |
QList< QgsFeatureId > | nearestNeighbor (const QgsPointXY &point, int neighbors) const |
Returns nearest neighbors to a point. More... | |
QgsSpatialIndex & | operator= (const QgsSpatialIndex &other) |
Implement assignment operator. More... | |
QAtomicInt | refs () const |
Gets reference count - just for debugging! More... | |
Friends | |
class | QgsFeatureIteratorDataStream |
A spatial index for QgsFeature objects.
QgsSpatialIndex objects are implicitly shared and can be inexpensively copied.
Definition at line 64 of file qgsspatialindex.h.
QgsSpatialIndex::QgsSpatialIndex | ( | ) |
Constructor for QgsSpatialIndex.
Creates an empty R-tree index.
Definition at line 244 of file qgsspatialindex.cpp.
|
explicit |
Constructor - creates R-tree and bulk loads it with features from the iterator.
This is much faster approach than creating an empty index and then inserting features one by one.
The optional feedback object can be used to allow cancelation of bulk feature loading. Ownership of feedback is not transferred, and callers must take care that the lifetime of feedback exceeds that of the spatial index construction.
Definition at line 249 of file qgsspatialindex.cpp.
|
explicit |
Constructor - creates R-tree and bulk loads it with features from the source.
This is much faster approach than creating an empty index and then inserting features one by one.
The optional feedback object can be used to allow cancelation of bulk feature loading. Ownership of feedback is not transferred, and callers must take care that the lifetime of feedback exceeds that of the spatial index construction.
Definition at line 254 of file qgsspatialindex.cpp.
QgsSpatialIndex::QgsSpatialIndex | ( | const QgsSpatialIndex & | other | ) |
Copy constructor.
Definition at line 259 of file qgsspatialindex.cpp.
QgsSpatialIndex::~QgsSpatialIndex | ( | ) |
Destructor finalizes work with spatial index.
Definition at line 264 of file qgsspatialindex.cpp.
bool QgsSpatialIndex::deleteFeature | ( | const QgsFeature & | feature | ) |
Removes a feature from the index.
Definition at line 342 of file qgsspatialindex.cpp.
bool QgsSpatialIndex::insertFeature | ( | const QgsFeature & | feature | ) |
Adds a feature to the index.
Definition at line 302 of file qgsspatialindex.cpp.
bool QgsSpatialIndex::insertFeature | ( | QgsFeatureId | id, |
const QgsRectangle & | bounds | ||
) |
Add a feature id to the index with a specified bounding box.
Definition at line 312 of file qgsspatialindex.cpp.
QList< QgsFeatureId > QgsSpatialIndex::intersects | ( | const QgsRectangle & | rectangle | ) | const |
Returns a list of features with a bounding box which intersects the specified rectangle.
Definition at line 354 of file qgsspatialindex.cpp.
QList< QgsFeatureId > QgsSpatialIndex::nearestNeighbor | ( | const QgsPointXY & | point, |
int | neighbors | ||
) | const |
Returns nearest neighbors to a point.
The number of neighbours returned is specified by the neighbours argument.
Definition at line 367 of file qgsspatialindex.cpp.
QgsSpatialIndex & QgsSpatialIndex::operator= | ( | const QgsSpatialIndex & | other | ) |
Implement assignment operator.
Definition at line 268 of file qgsspatialindex.cpp.
QAtomicInt QgsSpatialIndex::refs | ( | ) | const |
Gets reference count - just for debugging!
Definition at line 381 of file qgsspatialindex.cpp.
|
friend |
Definition at line 180 of file qgsspatialindex.h.