Class: QgsVectorLayerFeatureIterator¶
- class qgis.core.QgsVectorLayerFeatureIterator(source: QgsVectorLayerFeatureSource, ownSource: bool, request: QgsFeatureRequest)¶
Bases:
QgsAbstractFeatureIteratorFromSourceQgsVectorLayerFeatureSourceBase
Methods
end of iterating: free the resources / lock
Remove reference, delete if refs == 0
fetch next feature, return
True
on successReturns a rectangle representing the original request's
QgsFeatureRequest.filterRect()
.Transforms
feature
's geometry according to the specified coordinatetransform
.- rtype
bool
to be called by from subclass in
close()
Overrides default method as we only need to filter features in the edit buffer while for others filtering is left to the provider implementation.
By default, the iterator will fetch all features and check if the id is in the request.
Setup the simplification of geometries to fetch using the specified simplify method
Add reference
reset the iterator to the starting position
Update a
QgsFeatureRequest
so that spatial filters are transformed to the source's coordinate reference system.- class FetchJoinInfo¶
- class FetchJoinInfo(QgsVectorLayerFeatureIterator.FetchJoinInfo)
Bases:
sip.wrapper
- addJoinedAttributesCached(self, f: QgsFeature, joinValue: Any)¶
- Parameters
f (QgsFeature) –
joinValue (Any) –
- addJoinedAttributesDirect(self, f: QgsFeature, joinValue: Any)¶
- Parameters
f (QgsFeature) –
joinValue (Any) –
- attributes¶
- indexOffset¶
- joinField¶
- joinInfo¶
- targetField¶
- close(self) bool ¶
end of iterating: free the resources / lock
- Return type
bool
- deref(self)¶
Remove reference, delete if refs == 0
- fetchFeature(self, feature: QgsFeature) bool ¶
fetch next feature, return
True
on success- Parameters
feature (QgsFeature) –
- Return type
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.
- isValid(self) bool ¶
- Return type
bool
- iteratorClosed(self)¶
to be called by from subclass in
close()
- nextFeatureFilterExpression(self, f: QgsFeature) bool ¶
Overrides default method as we only need to filter features in the edit buffer while for others filtering is left to the provider implementation.
- Parameters
f (QgsFeature) –
- Return type
bool
- 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
- Parameters
simplifyMethod (QgsSimplifyMethod) –
- Return type
bool
- ref(self)¶
Add reference
- rewind(self) bool ¶
reset the iterator to the starting position
- Return type
bool
- 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.