QGIS API Documentation  3.37.0-Master (a5b4d9743e8)
Public Member Functions | List of all members
QgsMeshSpatialIndex Class Reference

A spatial index for QgsMeshFace or QgsMeshEdge objects. More...

#include <qgsmeshspatialindex.h>

Public Member Functions

 QgsMeshSpatialIndex ()
 Constructor for QgsSpatialIndex. More...
 
 QgsMeshSpatialIndex (const QgsMesh &mesh, QgsFeedback *feedback=nullptr, QgsMesh::ElementType elementType=QgsMesh::ElementType::Face)
 Constructor - creates R-tree and bulk loads faces or edges from the specified mesh. More...
 
 QgsMeshSpatialIndex (const QgsMeshSpatialIndex &other)
 Copy constructor. More...
 
 ~QgsMeshSpatialIndex ()
 Destructor finalizes work with spatial index. More...
 
void addFace (int faceIndex, const QgsMesh &mesh)
 Adds a face with faceIndex from the mesh in the spatial index. More...
 
QgsMesh::ElementType elementType () const
 Returns the type of mesh elements that are indexed. More...
 
QList< int > intersects (const QgsRectangle &rectangle) const
 Returns a list of face ids with a bounding box which intersects the specified rectangle. More...
 
QList< int > nearestNeighbor (const QgsPointXY &point, int neighbors) const
 Returns nearest neighbors to a point. More...
 
QgsMeshSpatialIndexoperator= (const QgsMeshSpatialIndex &other)
 Implement assignment operator. More...
 
void removeFace (int faceIndex, const QgsMesh &mesh)
 Removes a face with faceIndex from the mesh in the spatial index. More...
 

Detailed Description

A spatial index for QgsMeshFace or QgsMeshEdge objects.

QgsMeshSpatialIndex objects are implicitly shared and can be inexpensively copied.

Note
While the underlying libspatialindex is not thread safe on some platforms, the QgsMeshSpatialIndex class implements its own locks and accordingly, a single QgsMeshSpatialIndex object can safely be used across multiple threads
See also
QgsSpatialIndex, which is for vector features
Since
QGIS 3.6

Definition at line 49 of file qgsmeshspatialindex.h.

Constructor & Destructor Documentation

◆ QgsMeshSpatialIndex() [1/3]

QgsMeshSpatialIndex::QgsMeshSpatialIndex ( )

Constructor for QgsSpatialIndex.

Creates an empty R-tree index.

Definition at line 345 of file qgsmeshspatialindex.cpp.

◆ QgsMeshSpatialIndex() [2/3]

QgsMeshSpatialIndex::QgsMeshSpatialIndex ( const QgsMesh mesh,
QgsFeedback feedback = nullptr,
QgsMesh::ElementType  elementType = QgsMesh::ElementType::Face 
)
explicit

Constructor - creates R-tree and bulk loads faces or edges from the specified mesh.

Not implemented to construct R-tree for vertices Since QGIS 3.14 possibility to create R-tree for edges

The optional feedback object can be used to allow cancellation of bulk face 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 350 of file qgsmeshspatialindex.cpp.

◆ QgsMeshSpatialIndex() [3/3]

QgsMeshSpatialIndex::QgsMeshSpatialIndex ( const QgsMeshSpatialIndex other)

Copy constructor.

Definition at line 356 of file qgsmeshspatialindex.cpp.

◆ ~QgsMeshSpatialIndex()

QgsMeshSpatialIndex::~QgsMeshSpatialIndex ( )
default

Destructor finalizes work with spatial index.

Member Function Documentation

◆ addFace()

void QgsMeshSpatialIndex::addFace ( int  faceIndex,
const QgsMesh mesh 
)

Adds a face with faceIndex from the mesh in the spatial index.

Definition at line 406 of file qgsmeshspatialindex.cpp.

◆ elementType()

QgsMesh::ElementType QgsMeshSpatialIndex::elementType ( ) const

Returns the type of mesh elements that are indexed.

Since
QGIS 3.14

Definition at line 401 of file qgsmeshspatialindex.cpp.

◆ intersects()

QList< int > QgsMeshSpatialIndex::intersects ( const QgsRectangle rectangle) const

Returns a list of face ids with a bounding box which intersects the specified rectangle.

Note
The intersection test is performed based on the face bounding boxes only, so it is necessary to manually test the returned faces for exact geometry intersection when required.

Definition at line 374 of file qgsmeshspatialindex.cpp.

◆ nearestNeighbor()

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

Returns nearest neighbors to a point.

The number of neighbours returned is specified by the neighbours argument.

Note
The nearest neighbour test is performed based on the face bounding boxes only, so this method is not guaranteed to return the actual closest neighbours.

Definition at line 387 of file qgsmeshspatialindex.cpp.

◆ operator=()

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

Implement assignment operator.

Definition at line 364 of file qgsmeshspatialindex.cpp.

◆ removeFace()

void QgsMeshSpatialIndex::removeFace ( int  faceIndex,
const QgsMesh mesh 
)

Removes a face with faceIndex from the mesh in the spatial index.

Definition at line 438 of file qgsmeshspatialindex.cpp.


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