Class: QgsFeaturePool¶
A feature pool is based on a vector layer and caches features.
Note
This class is a technology preview and unstable API.
Added in version 3.4.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: QgsFeatureSink.addFeatures()
, deleteFeature()
, updateFeature()
Class Hierarchy¶
Base classes¶
An interface for objects which accept features via addFeature(s) methods. |
Abstract Methods
Removes a feature from this pool. |
|
Updates a feature in this pool. |
Methods
The coordinate reference system of this layer. |
|
The geometry type of this layer. |
|
Retrieves the feature with the specified id into feature. |
|
Gets a pointer to the underlying layer. |
|
The layer id of the layer. |
|
Returns the name of the layer. |
- class qgis.analysis.QgsFeaturePool[source]¶
Bases:
QgsFeatureSink
- __init__(layer: QgsVectorLayer | None)
Creates a new feature pool for
layer
.Must be created on the same thread as
layer
.- Parameters:
layer (Optional[QgsVectorLayer])
- crs(self) QgsCoordinateReferenceSystem [source]¶
The coordinate reference system of this layer.
- Return type:
- abstract deleteFeature(self, fid: int)[source]¶
Removes a feature from this pool. Implementations will remove the feature from the layer or from the data provider.
Warning
This method can safely be called from a different thread vs the object’s creation thread or the original layer’s thread. The update will be delegated to run in the main thread, and care must be taken to avoid deadlocks if the main thread is busy.
- Parameters:
fid (int)
- geometryType(self) Qgis.GeometryType [source]¶
The geometry type of this layer.
- Return type:
- getFeature(self, id: int, feature: QgsFeature) bool [source]¶
Retrieves the feature with the specified
id
intofeature
. 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 returnFalse
.Note
This method can safely be called from a different thread vs the object’s creation thread or the original layer’s thread.
- Parameters:
id (int)
feature (QgsFeature)
- Return type:
bool
- layer(self) QgsVectorLayer | None [source]¶
Gets a pointer to the underlying layer. May return a
``None``
if the layer has been deleted.Warning
This must be called from the same thread as the vector layer belongs to.
- Return type:
Optional[QgsVectorLayer]
- layerName(self) str [source]¶
Returns the name of the layer.
Should be preferred over
layer()
.name() because it can directly be run on the background thread.- Return type:
str
- abstract updateFeature(self, feature: QgsFeature)[source]¶
Updates a feature in this pool. Implementations will update the feature on the layer or on the data provider.
Warning
This method can safely be called from a different thread vs the object’s creation thread or the original layer’s thread. The update will be delegated to run in the main thread, and care must be taken to avoid deadlocks if the main thread is busy.
- Parameters:
feature (QgsFeature)