QGIS API Documentation  3.6.0-Noosa (5873452)
Public Member Functions | Protected Member Functions | List of all members
QgsFeaturePool Class Referenceabstract

A feature pool is based on a vector layer and caches features. More...

#include <qgsfeaturepool.h>

Inheritance diagram for QgsFeaturePool:
Inheritance graph
[legend]

Public Member Functions

 QgsFeaturePool (QgsVectorLayer *layer)
 Creates a new feature pool for layer. More...
 
virtual ~QgsFeaturePool ()=default
 
QgsFeatureIds allFeatureIds () const
 Returns the complete set of feature ids in this pool. More...
 
QgsCoordinateReferenceSystem crs () const
 The coordinate reference system of this layer. More...
 
virtual void deleteFeature (QgsFeatureId fid)=0
 Removes a feature from this pool. More...
 
QgsWkbTypes::GeometryType geometryType () const
 The geometry type of this layer. More...
 
bool getFeature (QgsFeatureId id, QgsFeature &feature, QgsFeedback *feedback=nullptr)
 Retrieves the feature with the specified id into feature. More...
 
QgsFeatureIds getFeatures (const QgsFeatureRequest &request, QgsFeedback *feedback=nullptr)
 Gets features for the provided request. More...
 
QgsFeatureIds getIntersects (const QgsRectangle &rect) const
 Gets all feature ids in the bounding box rect. More...
 
QgsVectorLayerlayer () const
 Gets a pointer to the underlying layer. More...
 
QString layerId () const
 The layer id of the layer. More...
 
QPointer< QgsVectorLayerlayerPtr () const
 Gets a QPointer to the underlying layer. More...
 
virtual void updateFeature (QgsFeature &feature)=0
 Updates a feature in this pool. More...
 
- Public Member Functions inherited from QgsFeatureSink
virtual ~QgsFeatureSink ()=default
 
virtual bool addFeature (QgsFeature &feature, QgsFeatureSink::Flags flags=nullptr)
 Adds a single feature to the sink. More...
 
virtual bool addFeatures (QgsFeatureList &features, QgsFeatureSink::Flags flags=nullptr)=0
 Adds a list of features to the sink. More...
 
virtual bool addFeatures (QgsFeatureIterator &iterator, QgsFeatureSink::Flags flags=nullptr)
 Adds all features from the specified iterator to the sink. More...
 
virtual bool flushBuffer ()
 Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to the sink's destination. More...
 

Protected Member Functions

void insertFeature (const QgsFeature &feature)
 Inserts a feature into the cache and the spatial index. More...
 
bool isFeatureCached (QgsFeatureId fid)
 Checks if the feature fid is cached. More...
 
void refreshCache (const QgsFeature &feature)
 Changes a feature in the cache and the spatial index. More...
 
void removeFeature (const QgsFeatureId featureId)
 Removes a feature from the cache and the spatial index. More...
 
void setFeatureIds (const QgsFeatureIds &ids)
 Sets all the feature ids governed by this feature pool. More...
 

Additional Inherited Members

- Public Types inherited from QgsFeatureSink
enum  Flag { FastInsert = 1 << 1 }
 Flags controlling how features are added to a sink. More...
 
enum  SinkFlag { RegeneratePrimaryKey = 1 << 1 }
 Flags that can be set on a QgsFeatureSink. More...
 

Detailed Description

A feature pool is based on a vector layer and caches features.

Note
This class is a technology preview and unstable API.
Since
QGIS 3.4

Definition at line 38 of file qgsfeaturepool.h.

Constructor & Destructor Documentation

◆ QgsFeaturePool()

QgsFeaturePool::QgsFeaturePool ( QgsVectorLayer layer)

Creates a new feature pool for layer.

Definition at line 29 of file qgsfeaturepool.cpp.

◆ ~QgsFeaturePool()

virtual QgsFeaturePool::~QgsFeaturePool ( )
virtualdefault

Member Function Documentation

◆ allFeatureIds()

QgsFeatureIds QgsFeaturePool::allFeatureIds ( ) const

Returns the complete set of feature ids in this pool.

Note that this concerns the features governed by this pool, which are not necessarily all cached.

Note
not available in Python bindings

Definition at line 82 of file qgsfeaturepool.cpp.

◆ crs()

QgsCoordinateReferenceSystem QgsFeaturePool::crs ( ) const

The coordinate reference system of this layer.

Definition at line 148 of file qgsfeaturepool.cpp.

◆ deleteFeature()

virtual void QgsFeaturePool::deleteFeature ( QgsFeatureId  fid)
pure virtual

Removes a feature from this pool.

Implementations will remove the feature from the layer or from the data provider.

Implemented in QgsVectorLayerFeaturePool, and QgsVectorDataProviderFeaturePool.

◆ geometryType()

QgsWkbTypes::GeometryType QgsFeaturePool::geometryType ( ) const

The geometry type of this layer.

Definition at line 153 of file qgsfeaturepool.cpp.

◆ getFeature()

bool QgsFeaturePool::getFeature ( QgsFeatureId  id,
QgsFeature feature,
QgsFeedback feedback = nullptr 
)

Retrieves the feature with the specified id into feature.

It will be retrieved from the cache or from the underlying layer if unavailable. If the feature is neither available from the cache nor from the layer it will return false. If feedback is specified, the call may return if the feedback is canceled.

Definition at line 39 of file qgsfeaturepool.cpp.

◆ getFeatures()

QgsFeatureIds QgsFeaturePool::getFeatures ( const QgsFeatureRequest request,
QgsFeedback feedback = nullptr 
)

Gets features for the provided request.

No features will be fetched from the cache and the request is sent directly to the underlying feature source. Results of the request are cached in the pool and the ids of all the features are returned. This can be used to warm the cache for a particular area of interest (bounding box) or other set of features. If feedback is specified, the call may return if the feedback is canceled.

Definition at line 65 of file qgsfeaturepool.cpp.

◆ getIntersects()

QgsFeatureIds QgsFeaturePool::getIntersects ( const QgsRectangle rect) const

Gets all feature ids in the bounding box rect.

It will use a spatial index to determine the ids.

Note
not available in Python bindings

Definition at line 87 of file qgsfeaturepool.cpp.

◆ insertFeature()

void QgsFeaturePool::insertFeature ( const QgsFeature feature)
protected

Inserts a feature into the cache and the spatial index.

To be used by implementations of addFeature.

Definition at line 106 of file qgsfeaturepool.cpp.

◆ isFeatureCached()

bool QgsFeaturePool::isFeatureCached ( QgsFeatureId  fid)
protected

Checks if the feature fid is cached.

Note
not available in Python bindings
Since
QGIS 3.4

Definition at line 143 of file qgsfeaturepool.cpp.

◆ layer()

QgsVectorLayer * QgsFeaturePool::layer ( ) const

Gets a pointer to the underlying layer.

May return a nullptr if the layer has been deleted. This must only be called from the main thread.

Definition at line 94 of file qgsfeaturepool.cpp.

◆ layerId()

QString QgsFeaturePool::layerId ( ) const

The layer id of the layer.

Definition at line 158 of file qgsfeaturepool.cpp.

◆ layerPtr()

QPointer< QgsVectorLayer > QgsFeaturePool::layerPtr ( ) const

Gets a QPointer to the underlying layer.

Note that access to any methods of the object will need to be done on the main thread and the pointer will need to be checked for validity before usage.

Note
not available in Python bindings

Definition at line 101 of file qgsfeaturepool.cpp.

◆ refreshCache()

void QgsFeaturePool::refreshCache ( const QgsFeature feature)
protected

Changes a feature in the cache and the spatial index.

To be used by implementations of updateFeature.

Definition at line 114 of file qgsfeaturepool.cpp.

◆ removeFeature()

void QgsFeaturePool::removeFeature ( const QgsFeatureId  featureId)
protected

Removes a feature from the cache and the spatial index.

To be used by implementations of deleteFeature.

Definition at line 125 of file qgsfeaturepool.cpp.

◆ setFeatureIds()

void QgsFeaturePool::setFeatureIds ( const QgsFeatureIds ids)
protected

Sets all the feature ids governed by this feature pool.

Should be called by subclasses constructor and whenever they insert a new feature.

Note
not available in Python bindings

Definition at line 138 of file qgsfeaturepool.cpp.

◆ updateFeature()

virtual void QgsFeaturePool::updateFeature ( QgsFeature feature)
pure virtual

Updates a feature in this pool.

Implementations will update the feature on the layer or on the data provider.

Implemented in QgsVectorLayerFeaturePool, and QgsVectorDataProviderFeaturePool.


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