QGIS API Documentation 3.41.0-Master (af5edcb665c)
|
A feature pool is based on a vector layer and caches features. More...
#include <qgsfeaturepool.h>
Public Member Functions | |
QgsFeaturePool (QgsVectorLayer *layer) | |
Creates a new feature pool for layer. | |
virtual | ~QgsFeaturePool ()=default |
QgsFeatureIds | allFeatureIds () const |
Returns the complete set of feature ids in this pool. | |
QgsCoordinateReferenceSystem | crs () const |
The coordinate reference system of this layer. | |
virtual void | deleteFeature (QgsFeatureId fid)=0 |
Removes a feature from this pool. | |
Qgis::GeometryType | geometryType () const |
The geometry type of this layer. | |
bool | getFeature (QgsFeatureId id, QgsFeature &feature) |
Retrieves the feature with the specified id into feature. | |
QgsFeatureIds | getFeatures (const QgsFeatureRequest &request, QgsFeedback *feedback=nullptr) |
Gets features for the provided request. | |
QgsFeatureIds | getIntersects (const QgsRectangle &rect) const |
Gets all feature ids in the bounding box rect. | |
QgsVectorLayer * | layer () const |
Gets a pointer to the underlying layer. | |
QString | layerId () const |
The layer id of the layer. | |
QString | layerName () const |
Returns the name of the layer. | |
QPointer< QgsVectorLayer > | layerPtr () const |
Gets a QPointer to the underlying layer. | |
virtual void | updateFeature (QgsFeature &feature)=0 |
Updates a feature in this pool. | |
Public Member Functions inherited from QgsFeatureSink | |
virtual | ~QgsFeatureSink ()=default |
virtual bool | addFeature (QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) |
Adds a single feature to the sink. | |
virtual bool | addFeatures (QgsFeatureIterator &iterator, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) |
Adds all features from the specified iterator to the sink. | |
virtual bool | addFeatures (QgsFeatureList &features, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags())=0 |
Adds a list of features to the sink. | |
virtual void | finalize () |
Finalizes the sink, flushing any buffered features to the destination. | |
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. | |
virtual QString | lastError () const |
Returns the most recent error encountered by the sink, e.g. | |
Protected Member Functions | |
void | insertFeature (const QgsFeature &feature, bool skipLock=false) |
Inserts a feature into the cache and the spatial index. | |
bool | isFeatureCached (QgsFeatureId fid) |
Checks if the feature fid is cached. | |
void | refreshCache (QgsFeature feature, const QgsFeature &origFeature) |
Changes a feature in the cache and the spatial index. | |
void | removeFeature (const QgsFeatureId featureId) |
Removes a feature from the cache and the spatial index. | |
void | setFeatureIds (const QgsFeatureIds &ids) |
Sets all the feature ids governed by this feature pool. | |
Friends | |
class | TestQgsVectorLayerFeaturePool |
Additional Inherited Members | |
Public Types inherited from QgsFeatureSink | |
enum | Flag { FastInsert = 1 << 1 , RollBackOnErrors = 1 << 2 } |
Flags controlling how features are added to a sink. More... | |
typedef QFlags< Flag > | Flags |
enum | SinkFlag { RegeneratePrimaryKey = 1 << 1 } |
Flags that can be set on a QgsFeatureSink. More... | |
typedef QFlags< SinkFlag > | SinkFlags |
A feature pool is based on a vector layer and caches features.
Definition at line 37 of file qgsfeaturepool.h.
QgsFeaturePool::QgsFeaturePool | ( | QgsVectorLayer * | layer | ) |
Creates a new feature pool for layer.
Must be created on the same thread as layer.
Definition at line 29 of file qgsfeaturepool.cpp.
|
virtualdefault |
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.
Definition at line 110 of file qgsfeaturepool.cpp.
QgsCoordinateReferenceSystem QgsFeaturePool::crs | ( | ) | const |
The coordinate reference system of this layer.
Definition at line 187 of file qgsfeaturepool.cpp.
|
pure virtual |
Removes a feature from this pool.
Implementations will remove the feature from the layer or from the data provider.
Implemented in QgsVectorDataProviderFeaturePool, and QgsVectorLayerFeaturePool.
Qgis::GeometryType QgsFeaturePool::geometryType | ( | ) | const |
The geometry type of this layer.
Definition at line 192 of file qgsfeaturepool.cpp.
bool QgsFeaturePool::getFeature | ( | QgsFeatureId | id, |
QgsFeature & | feature | ||
) |
Retrieves the feature with the specified id into feature.
It will be retrieved from the cache or from the underlying feature source if unavailable. If the feature is neither available from the cache nor from the source it will return false
.
Definition at line 41 of file qgsfeaturepool.cpp.
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 is used to warm the cache for a particular area of interest (bounding box) or other set of features. This will get a new feature source from the source vector layer.
If feedback is specified, the call may return if the feedback is canceled.
Definition at line 84 of file qgsfeaturepool.cpp.
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.
Definition at line 115 of file qgsfeaturepool.cpp.
|
protected |
Inserts a feature into the cache and the spatial index.
To be used by implementations of addFeature
.
Definition at line 135 of file qgsfeaturepool.cpp.
|
protected |
Checks if the feature fid is cached.
Definition at line 176 of file qgsfeaturepool.cpp.
QgsVectorLayer * QgsFeaturePool::layer | ( | ) | const |
Gets a pointer to the underlying layer.
May return a \c nullptr
if the layer has been deleted.
Definition at line 122 of file qgsfeaturepool.cpp.
QString QgsFeaturePool::layerId | ( | ) | const |
The layer id of the layer.
Definition at line 197 of file qgsfeaturepool.cpp.
QString QgsFeaturePool::layerName | ( | ) | const |
Returns the name of the layer.
Should be preferred over layer().name() because it can directly be run on the background thread.
Definition at line 182 of file qgsfeaturepool.cpp.
QPointer< QgsVectorLayer > QgsFeaturePool::layerPtr | ( | ) | const |
Gets a QPointer to the underlying layer.
Definition at line 130 of file qgsfeaturepool.cpp.
|
protected |
Changes a feature in the cache and the spatial index.
To be used by implementations of updateFeature
.
feature | the new feature to put in the cache and index |
origFeature | the original feature to remove from the index |
Definition at line 145 of file qgsfeaturepool.cpp.
|
protected |
Removes a feature from the cache and the spatial index.
To be used by implementations of deleteFeature
.
Definition at line 157 of file qgsfeaturepool.cpp.
|
protected |
Sets all the feature ids governed by this feature pool.
Should be called by subclasses constructor and whenever they insert a new feature.
Definition at line 171 of file qgsfeaturepool.cpp.
|
pure virtual |
Updates a feature in this pool.
Implementations will update the feature on the layer or on the data provider.
Implemented in QgsVectorDataProviderFeaturePool, and QgsVectorLayerFeaturePool.
|
friend |
Definition at line 236 of file qgsfeaturepool.h.