QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsVectorLayerFeatureIterator Class Reference

A feature iterator which iterates over features from a QgsVectorLayer. More...

#include <qgsvectorlayerfeatureiterator.h>

Inheritance diagram for QgsVectorLayerFeatureIterator:
Inheritance graph
[legend]

Classes

struct  FetchJoinInfo
 Join information prepared for fast attribute id mapping in QgsVectorLayerJoinBuffer::updateFeatureAttributes(). More...
 

Public Member Functions

 QgsVectorLayerFeatureIterator (QgsVectorLayerFeatureSource *source, bool ownSource, const QgsFeatureRequest &request)
 
 ~QgsVectorLayerFeatureIterator () override
 
bool close () override
 end of iterating: free the resources / lock
 
bool isValid () const override
 Returns if this iterator is valid.
 
bool rewind () override
 reset the iterator to the starting position
 
void setInterruptionChecker (QgsFeedback *interruptionChecker) override
 Attach an object that can be queried regularly by the iterator to check if it must stopped.
 
- Public Member Functions inherited from QgsAbstractFeatureIteratorFromSource< QgsVectorLayerFeatureSource >
 QgsAbstractFeatureIteratorFromSource (QgsVectorLayerFeatureSource *source, bool ownSource, const QgsFeatureRequest &request)
 
 ~QgsAbstractFeatureIteratorFromSource () override
 
- Public Member Functions inherited from QgsAbstractFeatureIterator
 QgsAbstractFeatureIterator (const QgsFeatureRequest &request)
 base class constructor - stores the iteration parameters
 
virtual ~QgsAbstractFeatureIterator ()=default
 destructor makes sure that the iterator is closed properly
 
bool compileFailed () const
 Indicator if there was an error when sending the compiled query to the server.
 
CompileStatus compileStatus () const
 Returns the status of expression compilation for filter expression requests.
 
virtual bool nextFeature (QgsFeature &f)
 Fetch next feature and stores in f, returns true on success.
 

Protected Member Functions

void addExpressionAttribute (QgsFeature &f, int attrIndex)
 Adds an expression based attribute to a feature.
 
void addJoinedAttributes (QgsFeature &f)
 
void addVirtualAttributes (QgsFeature &f)
 Adds attributes that don't source from the provider but are added inside QGIS Includes.
 
bool fetchFeature (QgsFeature &feature) override
 fetch next feature, return true on success
 
bool fetchNextAddedFeature (QgsFeature &f)
 
bool fetchNextChangedAttributeFeature (QgsFeature &f)
 
bool fetchNextChangedGeomFeature (QgsFeature &f)
 
bool nextFeatureFid (QgsFeature &f)
 
bool nextFeatureFilterExpression (QgsFeature &f) override
 Overrides default method as we only need to filter features in the edit buffer while for others filtering is left to the provider implementation.
 
void prepareExpression (int fieldIdx)
 
void prepareField (int fieldIdx)
 
void prepareFields ()
 
void prepareJoin (int fieldIdx)
 
bool prepareSimplification (const QgsSimplifyMethod &simplifyMethod) override
 Setup the simplification of geometries to fetch using the specified simplify method.
 
void rewindEditBuffer ()
 
void updateChangedAttributes (QgsFeature &f)
 Update feature with uncommitted attribute updates.
 
void updateFeatureGeometry (QgsFeature &f)
 Update feature with uncommitted geometry updates.
 
void useAddedFeature (const QgsFeature &src, QgsFeature &f)
 
void useChangedAttributeFeature (QgsFeatureId fid, const QgsGeometry &geom, QgsFeature &f)
 
- Protected Member Functions inherited from QgsAbstractFeatureIteratorFromSource< QgsVectorLayerFeatureSource >
void iteratorClosed ()
 to be called by from subclass in close()
 
- Protected Member Functions inherited from QgsAbstractFeatureIterator
void deref ()
 Remove reference, delete if refs == 0.
 
QgsRectangle filterRectToSourceCrs (const QgsCoordinateTransform &transform) const
 Returns a rectangle representing the original request's QgsFeatureRequest::filterRect().
 
void geometryToDestinationCrs (QgsFeature &feature, const QgsCoordinateTransform &transform) const
 Transforms feature's geometry according to the specified coordinate transform.
 
virtual bool nextFeatureFilterFids (QgsFeature &f)
 By default, the iterator will fetch all features and check if the id is in the request.
 
void ref ()
 Add reference.
 
RequestToSourceCrsResult updateRequestToSourceCrs (QgsFeatureRequest &request, const QgsCoordinateTransform &transform) const
 Update a QgsFeatureRequest so that spatial filters are transformed to the source's coordinate reference system.
 

Protected Attributes

QgsFeatureIterator mChangedFeaturesIterator
 
QgsFeatureRequest mChangedFeaturesRequest
 
double mDistanceWithin = 0
 
std::shared_ptr< QgsGeometryEnginemDistanceWithinEngine
 
QgsGeometry mDistanceWithinGeom
 
QMap< int, QgsExpression * > mExpressionFieldInfo
 
QgsFeatureMap::ConstIterator mFetchAddedFeaturesIt
 
QgsGeometryMap::ConstIterator mFetchChangedGeomIt
 
QSet< QgsFeatureIdmFetchConsidered
 
bool mFetchedFid
 
QMap< const QgsVectorLayerJoinInfo *, QgsVectorLayerFeatureIterator::FetchJoinInfomFetchJoinInfo
 Information about joins used in the current select() statement.
 
QgsRectangle mFilterRect
 
bool mHasValidTransform = false
 
bool mHasVirtualAttributes
 
QgsFeatureIterator mProviderIterator
 
QgsFeatureRequest mProviderRequest
 
QgsCoordinateTransform mTransform
 
- Protected Attributes inherited from QgsAbstractFeatureIteratorFromSource< QgsVectorLayerFeatureSource >
bool mOwnSource
 
QgsVectorLayerFeatureSourcemSource
 
- Protected Attributes inherited from QgsAbstractFeatureIterator
bool mClosed = false
 Sets to true, as soon as the iterator is closed.
 
bool mCompileFailed = false
 
CompileStatus mCompileStatus = NoCompilation
 Status of compilation of filter expression.
 
long long mFetchedCount = 0
 Number of features already fetched by iterator.
 
QgsFeatureRequest mRequest
 A copy of the feature request.
 
bool mValid = true
 An invalid state of a feature iterator indicates that there was a problem with even getting it up and running.
 
bool mZombie = false
 A feature iterator may be closed already but still be serving features from the cache.
 
int refs = 0
 reference counting (to allow seamless copying of QgsFeatureIterator instances)
 

Additional Inherited Members

- Public Types inherited from QgsAbstractFeatureIterator
enum  CompileStatus { NoCompilation , PartiallyCompiled , Compiled }
 Status of expression compilation for filter expression requests. More...
 
enum class  RequestToSourceCrsResult : int { Success , DistanceWithinMustBeCheckedManually }
 Possible results from the updateRequestToSourceCrs() method. More...
 

Detailed Description

A feature iterator which iterates over features from a QgsVectorLayer.

Definition at line 154 of file qgsvectorlayerfeatureiterator.h.

Constructor & Destructor Documentation

◆ QgsVectorLayerFeatureIterator()

QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator ( QgsVectorLayerFeatureSource source,
bool  ownSource,
const QgsFeatureRequest request 
)

Definition at line 137 of file qgsvectorlayerfeatureiterator.cpp.

◆ ~QgsVectorLayerFeatureIterator()

QgsVectorLayerFeatureIterator::~QgsVectorLayerFeatureIterator ( )
override

Definition at line 368 of file qgsvectorlayerfeatureiterator.cpp.

Member Function Documentation

◆ addExpressionAttribute()

void QgsVectorLayerFeatureIterator::addExpressionAttribute ( QgsFeature f,
int  attrIndex 
)
protected

Adds an expression based attribute to a feature.

Parameters
ffeature
attrIndexattribute index
Note
not available in Python bindings

Definition at line 1120 of file qgsvectorlayerfeatureiterator.cpp.

◆ addJoinedAttributes()

void QgsVectorLayerFeatureIterator::addJoinedAttributes ( QgsFeature f)
protected
Note
not available in Python bindings

Definition at line 1063 of file qgsvectorlayerfeatureiterator.cpp.

◆ addVirtualAttributes()

void QgsVectorLayerFeatureIterator::addVirtualAttributes ( QgsFeature f)
protected

Adds attributes that don't source from the provider but are added inside QGIS Includes.

  • Joined fields
  • Expression fields
Parameters
fThe feature will be modified
Note
not available in Python bindings

Definition at line 1080 of file qgsvectorlayerfeatureiterator.cpp.

◆ close()

bool QgsVectorLayerFeatureIterator::close ( )
overridevirtual

end of iterating: free the resources / lock

Implements QgsAbstractFeatureIterator.

Definition at line 602 of file qgsvectorlayerfeatureiterator.cpp.

◆ fetchFeature()

bool QgsVectorLayerFeatureIterator::fetchFeature ( QgsFeature feature)
overrideprotectedvirtual

fetch next feature, return true on success

Implements QgsAbstractFeatureIterator.

Definition at line 466 of file qgsvectorlayerfeatureiterator.cpp.

◆ fetchNextAddedFeature()

bool QgsVectorLayerFeatureIterator::fetchNextAddedFeature ( QgsFeature f)
protected
Note
not available in Python bindings

Definition at line 626 of file qgsvectorlayerfeatureiterator.cpp.

◆ fetchNextChangedAttributeFeature()

bool QgsVectorLayerFeatureIterator::fetchNextChangedAttributeFeature ( QgsFeature f)
protected
Note
not available in Python bindings

Definition at line 712 of file qgsvectorlayerfeatureiterator.cpp.

◆ fetchNextChangedGeomFeature()

bool QgsVectorLayerFeatureIterator::fetchNextChangedGeomFeature ( QgsFeature f)
protected
Note
not available in Python bindings

Definition at line 673 of file qgsvectorlayerfeatureiterator.cpp.

◆ isValid()

bool QgsVectorLayerFeatureIterator::isValid ( ) const
overridevirtual

Returns if this iterator is valid.

An invalid feature iterator is not able to provide a reliable source for data. If an iterator is invalid, either give up or try to send the request again (preferably after a timeout to give the system some time to stay responsive).

If you want to check if the iterator successfully completed, better use QgsFeatureIterator::isClosed().

Reimplemented from QgsAbstractFeatureIterator.

Definition at line 621 of file qgsvectorlayerfeatureiterator.cpp.

◆ nextFeatureFid()

bool QgsVectorLayerFeatureIterator::nextFeatureFid ( QgsFeature f)
protected
Note
not available in Python bindings

Definition at line 1262 of file qgsvectorlayerfeatureiterator.cpp.

◆ nextFeatureFilterExpression()

bool QgsVectorLayerFeatureIterator::nextFeatureFilterExpression ( QgsFeature f)
inlineoverrideprotectedvirtual

Overrides default method as we only need to filter features in the edit buffer while for others filtering is left to the provider implementation.

Reimplemented from QgsAbstractFeatureIterator.

Definition at line 223 of file qgsvectorlayerfeatureiterator.h.

◆ prepareExpression()

void QgsVectorLayerFeatureIterator::prepareExpression ( int  fieldIdx)
protected
Note
not available in Python bindings

Definition at line 836 of file qgsvectorlayerfeatureiterator.cpp.

◆ prepareField()

void QgsVectorLayerFeatureIterator::prepareField ( int  fieldIdx)
protected
Note
not available in Python bindings

Definition at line 1041 of file qgsvectorlayerfeatureiterator.cpp.

◆ prepareFields()

void QgsVectorLayerFeatureIterator::prepareFields ( )
protected
Note
not available in Python bindings

Definition at line 895 of file qgsvectorlayerfeatureiterator.cpp.

◆ prepareJoin()

void QgsVectorLayerFeatureIterator::prepareJoin ( int  fieldIdx)
protected
Note
not available in Python bindings

Definition at line 794 of file qgsvectorlayerfeatureiterator.cpp.

◆ prepareSimplification()

bool QgsVectorLayerFeatureIterator::prepareSimplification ( const QgsSimplifyMethod simplifyMethod)
overrideprotectedvirtual

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

Reimplemented from QgsAbstractFeatureIterator.

Definition at line 1139 of file qgsvectorlayerfeatureiterator.cpp.

◆ rewind()

bool QgsVectorLayerFeatureIterator::rewind ( )
overridevirtual

reset the iterator to the starting position

Implements QgsAbstractFeatureIterator.

Definition at line 584 of file qgsvectorlayerfeatureiterator.cpp.

◆ rewindEditBuffer()

void QgsVectorLayerFeatureIterator::rewindEditBuffer ( )
protected
Note
not available in Python bindings

Definition at line 786 of file qgsvectorlayerfeatureiterator.cpp.

◆ setInterruptionChecker()

void QgsVectorLayerFeatureIterator::setInterruptionChecker ( QgsFeedback interruptionChecker)
overridevirtual

Attach an object that can be queried regularly by the iterator to check if it must stopped.

This is mostly useful for iterators where a single nextFeature()/fetchFeature() iteration might be very long. A typical use case is the WFS provider. When nextFeature()/fetchFeature() is reasonably fast, it is not necessary to implement this method. The default implementation does nothing.

Note
not available in Python bindings

Reimplemented from QgsAbstractFeatureIterator.

Definition at line 615 of file qgsvectorlayerfeatureiterator.cpp.

◆ updateChangedAttributes()

void QgsVectorLayerFeatureIterator::updateChangedAttributes ( QgsFeature f)
protected

Update feature with uncommitted attribute updates.

Note
not available in Python bindings

Definition at line 1307 of file qgsvectorlayerfeatureiterator.cpp.

◆ updateFeatureGeometry()

void QgsVectorLayerFeatureIterator::updateFeatureGeometry ( QgsFeature f)
protected

Update feature with uncommitted geometry updates.

Note
not available in Python bindings

Definition at line 1330 of file qgsvectorlayerfeatureiterator.cpp.

◆ useAddedFeature()

void QgsVectorLayerFeatureIterator::useAddedFeature ( const QgsFeature src,
QgsFeature f 
)
protected
Note
not available in Python bindings

Definition at line 656 of file qgsvectorlayerfeatureiterator.cpp.

◆ useChangedAttributeFeature()

void QgsVectorLayerFeatureIterator::useChangedAttributeFeature ( QgsFeatureId  fid,
const QgsGeometry geom,
QgsFeature f 
)
protected
Note
not available in Python bindings

Definition at line 748 of file qgsvectorlayerfeatureiterator.cpp.

Member Data Documentation

◆ mChangedFeaturesIterator

QgsFeatureIterator QgsVectorLayerFeatureIterator::mChangedFeaturesIterator
protected

Definition at line 293 of file qgsvectorlayerfeatureiterator.h.

◆ mChangedFeaturesRequest

QgsFeatureRequest QgsVectorLayerFeatureIterator::mChangedFeaturesRequest
protected

Definition at line 292 of file qgsvectorlayerfeatureiterator.h.

◆ mDistanceWithin

double QgsVectorLayerFeatureIterator::mDistanceWithin = 0
protected

Definition at line 303 of file qgsvectorlayerfeatureiterator.h.

◆ mDistanceWithinEngine

std::shared_ptr< QgsGeometryEngine > QgsVectorLayerFeatureIterator::mDistanceWithinEngine
protected

Definition at line 302 of file qgsvectorlayerfeatureiterator.h.

◆ mDistanceWithinGeom

QgsGeometry QgsVectorLayerFeatureIterator::mDistanceWithinGeom
protected

Definition at line 301 of file qgsvectorlayerfeatureiterator.h.

◆ mExpressionFieldInfo

QMap<int, QgsExpression *> QgsVectorLayerFeatureIterator::mExpressionFieldInfo
protected

Definition at line 318 of file qgsvectorlayerfeatureiterator.h.

◆ mFetchAddedFeaturesIt

QgsFeatureMap::ConstIterator QgsVectorLayerFeatureIterator::mFetchAddedFeaturesIt
protected

Definition at line 308 of file qgsvectorlayerfeatureiterator.h.

◆ mFetchChangedGeomIt

QgsGeometryMap::ConstIterator QgsVectorLayerFeatureIterator::mFetchChangedGeomIt
protected

Definition at line 307 of file qgsvectorlayerfeatureiterator.h.

◆ mFetchConsidered

QSet<QgsFeatureId> QgsVectorLayerFeatureIterator::mFetchConsidered
protected

Definition at line 306 of file qgsvectorlayerfeatureiterator.h.

◆ mFetchedFid

bool QgsVectorLayerFeatureIterator::mFetchedFid
protected

Definition at line 310 of file qgsvectorlayerfeatureiterator.h.

◆ mFetchJoinInfo

QMap<const QgsVectorLayerJoinInfo *, QgsVectorLayerFeatureIterator::FetchJoinInfo> QgsVectorLayerFeatureIterator::mFetchJoinInfo
protected

Information about joins used in the current select() statement.

Allows faster mapping of attribute ids compared to mVectorJoins.

Definition at line 316 of file qgsvectorlayerfeatureiterator.h.

◆ mFilterRect

QgsRectangle QgsVectorLayerFeatureIterator::mFilterRect
protected

Definition at line 296 of file qgsvectorlayerfeatureiterator.h.

◆ mHasValidTransform

bool QgsVectorLayerFeatureIterator::mHasValidTransform = false
protected

Definition at line 297 of file qgsvectorlayerfeatureiterator.h.

◆ mHasVirtualAttributes

bool QgsVectorLayerFeatureIterator::mHasVirtualAttributes
protected

Definition at line 320 of file qgsvectorlayerfeatureiterator.h.

◆ mProviderIterator

QgsFeatureIterator QgsVectorLayerFeatureIterator::mProviderIterator
protected

Definition at line 291 of file qgsvectorlayerfeatureiterator.h.

◆ mProviderRequest

QgsFeatureRequest QgsVectorLayerFeatureIterator::mProviderRequest
protected

Definition at line 290 of file qgsvectorlayerfeatureiterator.h.

◆ mTransform

QgsCoordinateTransform QgsVectorLayerFeatureIterator::mTransform
protected

Definition at line 298 of file qgsvectorlayerfeatureiterator.h.


The documentation for this class was generated from the following files: