Class: QgsCachedFeatureWriterIterator

class qgis.core.QgsCachedFeatureWriterIterator(vlCache: QgsVectorLayerCache, featureRequest: QgsFeatureRequest)

Bases: QgsAbstractFeatureIterator

This constructor creates a feature iterator, which queries the backend and caches retrieved features.

Parameters

QgsCachedFeatureWriterIterator(QgsCachedFeatureWriterIterator)

Uses another iterator as backend and writes features to the cache

Methods

close

Close this iterator.

deref

Remove reference, delete if refs == 0

fetchFeature

Implementation for fetching a feature.

filterRectToSourceCrs

Returns a rectangle representing the original request’s QgsFeatureRequest.filterRect() If transform is a valid coordinate transform, the return rectangle will represent the requested filterRect() transformed to the source’s coordinate reference system.

geometryToDestinationCrs

Transforms feature’s geometry according to the specified coordinate transform.

nextFeatureFilterExpression

By default, the iterator will fetch all features and check if the feature matches the expression.

nextFeatureFilterFids

By default, the iterator will fetch all features and check if the id is in the request.

prepareSimplification

Setup the simplification of geometries to fetch using the specified simplify method

ref

Add reference

rewind

Rewind to the beginning of the iterator

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() If transform is a valid coordinate transform, the return rectangle will represent the requested filterRect() transformed to the source’s coordinate reference system. Iterators should call this method and use the returned rectangle for filtering features to ensure that any QgsFeatureRequest.destinationCrs() set on the request is respected. Will throw a QgsCsException 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 coordinate transform. If feature has no geometry or transform is invalid then calling this method has no effect and will be shortcut. Iterators should call this method before returning features to ensure that any QgsFeatureRequest.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

By default, the iterator will fetch all features and check if the id is in the request. If you have a more sophisticated metodology (SQL request for the features…) and you are sure, that any feature you return from fetchFeature will match if the request was FilterFids 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

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