Class: QgsCachedFeatureIterator¶
- class qgis.core.QgsCachedFeatureIterator¶
Bases:
QgsAbstractFeatureIterator
Delivers features from the cache
QgsCachedFeatureIterator(vlCache:
QgsVectorLayerCache
, featureRequest:QgsFeatureRequest
) This constructor creates a feature iterator, that delivers all cached features. No request is made to the backend.- Parameters:
vlCache – The vector layer cache to use
featureRequest –
The feature request to answer
Methods
Close this iterator.
Remove reference, delete if refs == 0
Implementation for fetching a feature.
Returns a rectangle representing the original request's
QgsFeatureRequest.filterRect()
.Transforms
feature
's geometry according to the specified coordinatetransform
.By default, the iterator will fetch all features and check if the feature matches the expression.
We have a local special iterator for FilterFids, no need to run the generic.
Setup the simplification of geometries to fetch using the specified simplify method
Add reference
Rewind to the beginning of the iterator
Update a
QgsFeatureRequest
so that spatial filters are transformed to the source's coordinate reference system.
- close(self) bool ¶
Close this iterator. No further features will be available.
- Return type:
bool
- Returns:
True
if successful
- deref(self)¶
Remove reference, delete if refs == 0
- fetchFeature(self, f: QgsFeature) bool ¶
Implementation for fetching a feature.
- Parameters:
f (QgsFeature) – Will write to this feature
- Return type:
bool
- Returns:
bool
True
if the operation was OK
See also
bool()
- filterRectToSourceCrs(self, transform: QgsCoordinateTransform) QgsRectangle ¶
Returns a rectangle representing the original request’s
QgsFeatureRequest.filterRect()
. Iftransform
is a valid coordinate transform, the return rectangle will represent the requestedfilterRect()
transformed to the source’s coordinate reference system. Iterators should call this method and use the returned rectangle for filtering features to ensure that anyQgsFeatureRequest.destinationCrs()
set on the request is respected. Will throw aQgsCsException
if the rect cannot be transformed from the destination CRS.New in version 3.0.
- geometryToDestinationCrs(self, feature: QgsFeature, transform: QgsCoordinateTransform)¶
Transforms
feature
’s geometry according to the specified coordinatetransform
. Iffeature
has no geometry ortransform
is invalid then calling this method has no effect and will be shortcut. Iterators should call this method before returning features to ensure that anyQgsFeatureRequest.destinationCrs()
set on the request is respected.New in version 3.0.
- nextFeatureFilterExpression(self, f: QgsFeature) bool ¶
By default, the iterator will fetch all features and check if the feature matches the expression. If you have a more sophisticated metodology (SQL request for the features…) and you check for the expression in your fetchFeature method, you can just redirect this call to fetchFeature so the default check will be omitted.
- Parameters:
f – The feature to write to
- Returns:
True
if a feature was written to f
- nextFeatureFilterFids(self, f: QgsFeature) bool ¶
We have a local special iterator for FilterFids, no need to run the generic.
- Parameters:
f (QgsFeature) – Will write to this feature
- Return type:
bool
- Returns:
bool
True
if the operation was OK
- prepareSimplification(self, simplifyMethod: QgsSimplifyMethod) bool ¶
Setup the simplification of geometries to fetch using the specified simplify method
- ref(self)¶
Add reference
- rewind(self) bool ¶
Rewind to the beginning of the iterator
- Return type:
bool
- Returns:
bool
True
if the operation was OK
- updateRequestToSourceCrs(self, request: QgsFeatureRequest, transform: QgsCoordinateTransform) QgsAbstractFeatureIterator.RequestToSourceCrsResult ¶
Update a
QgsFeatureRequest
so that spatial filters are transformed to the source’s coordinate reference system. Iterators should call this method against the request used for filtering features to ensure that anyQgsFeatureRequest.destinationCrs()
set on the request is respected.- Returns:
result of operation. See QgsAbstractFeatureIterator.RequestToSourceCrsResult for interpretation.
- Raises:
QgsCsException – if the rect cannot be transformed from the destination CRS.
New in version 3.22.