QGIS API Documentation  2.99.0-Master (b058df7)
Public Member Functions | Friends | List of all members
QgsSpatialIndex Class Reference

#include <qgsspatialindex.h>

Public Member Functions

 QgsSpatialIndex ()
 Constructor - creates R-tree. 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 &f)
 Remove feature from index. More...
 
bool insertFeature (const QgsFeature &f)
 Add feature to index. More...
 
bool insertFeature (QgsFeatureId id, const QgsRectangle &bounds)
 Add a feature id to the index with a specified bounding box. More...
 
QList< QgsFeatureIdintersects (const QgsRectangle &rect) const
 Returns features that intersect the specified rectangle. More...
 
QList< QgsFeatureIdnearestNeighbor (const QgsPointXY &point, int neighbors) const
 Returns nearest neighbors (their count is specified by second parameter) More...
 
QgsSpatialIndexoperator= (const QgsSpatialIndex &other)
 Implement assignment operator. More...
 
QAtomicInt refs () const
 get reference count - just for debugging! More...
 

Friends

class QgsFeatureIteratorDataStream
 

Detailed Description

Definition at line 56 of file qgsspatialindex.h.

Constructor & Destructor Documentation

◆ QgsSpatialIndex() [1/4]

QgsSpatialIndex::QgsSpatialIndex ( )

Constructor - creates R-tree.

Definition at line 238 of file qgsspatialindex.cpp.

◆ QgsSpatialIndex() [2/4]

QgsSpatialIndex::QgsSpatialIndex ( const QgsFeatureIterator fi,
QgsFeedback feedback = nullptr 
)
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.

Since
QGIS 2.8

Definition at line 243 of file qgsspatialindex.cpp.

◆ QgsSpatialIndex() [3/4]

QgsSpatialIndex::QgsSpatialIndex ( const QgsFeatureSource source,
QgsFeedback feedback = nullptr 
)
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.

Since
QGIS 3.0

Definition at line 248 of file qgsspatialindex.cpp.

◆ QgsSpatialIndex() [4/4]

QgsSpatialIndex::QgsSpatialIndex ( const QgsSpatialIndex other)

Copy constructor.

Definition at line 253 of file qgsspatialindex.cpp.

◆ ~QgsSpatialIndex()

QgsSpatialIndex::~QgsSpatialIndex ( )

Destructor finalizes work with spatial index.

Definition at line 258 of file qgsspatialindex.cpp.

Member Function Documentation

◆ deleteFeature()

bool QgsSpatialIndex::deleteFeature ( const QgsFeature f)

Remove feature from index.

Definition at line 334 of file qgsspatialindex.cpp.

◆ insertFeature() [1/2]

bool QgsSpatialIndex::insertFeature ( const QgsFeature f)

Add feature to index.

Definition at line 296 of file qgsspatialindex.cpp.

◆ insertFeature() [2/2]

bool QgsSpatialIndex::insertFeature ( QgsFeatureId  id,
const QgsRectangle bounds 
)

Add a feature id to the index with a specified bounding box.

Returns
true if feature was successfully added to index.
Since
QGIS 3.0

Definition at line 306 of file qgsspatialindex.cpp.

◆ intersects()

QList< QgsFeatureId > QgsSpatialIndex::intersects ( const QgsRectangle rect) const

Returns features that intersect the specified rectangle.

Definition at line 345 of file qgsspatialindex.cpp.

◆ nearestNeighbor()

QList< QgsFeatureId > QgsSpatialIndex::nearestNeighbor ( const QgsPointXY point,
int  neighbors 
) const

Returns nearest neighbors (their count is specified by second parameter)

Definition at line 357 of file qgsspatialindex.cpp.

◆ operator=()

QgsSpatialIndex & QgsSpatialIndex::operator= ( const QgsSpatialIndex other)

Implement assignment operator.

Definition at line 262 of file qgsspatialindex.cpp.

◆ refs()

QAtomicInt QgsSpatialIndex::refs ( ) const

get reference count - just for debugging!

Definition at line 370 of file qgsspatialindex.cpp.

Friends And Related Function Documentation

◆ QgsFeatureIteratorDataStream

friend class QgsFeatureIteratorDataStream
friend

Definition at line 154 of file qgsspatialindex.h.


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