QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
|
Internal feature iterator to be implemented within data providers. More...
#include <qgsfeatureiterator.h>
Public Types | |
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... | |
Public Member Functions | |
QgsAbstractFeatureIterator (const QgsFeatureRequest &request) | |
base class constructor - stores the iteration parameters | |
virtual | ~QgsAbstractFeatureIterator ()=default |
destructor makes sure that the iterator is closed properly | |
virtual bool | close ()=0 |
Call to end the iteration. | |
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 | isValid () const |
Returns if this iterator is valid. | |
virtual bool | nextFeature (QgsFeature &f) |
Fetch next feature and stores in f, returns true on success. | |
virtual bool | rewind ()=0 |
Resets the iterator to the starting position. | |
virtual void | setInterruptionChecker (QgsFeedback *interruptionChecker) |
Attach an object that can be queried regularly by the iterator to check if it must stopped. | |
Protected Member Functions | |
void | deref () |
Remove reference, delete if refs == 0. | |
virtual bool | fetchFeature (QgsFeature &f)=0 |
If you write a feature iterator for your provider, this is the method you need to implement!! | |
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 | nextFeatureFilterExpression (QgsFeature &f) |
By default, the iterator will fetch all features and check if the feature matches the expression. | |
virtual bool | nextFeatureFilterFids (QgsFeature &f) |
By default, the iterator will fetch all features and check if the id is in the request. | |
virtual bool | prepareSimplification (const QgsSimplifyMethod &simplifyMethod) |
Setup the simplification of geometries to fetch using the specified simplify method. | |
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 | |
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) | |
Friends | |
class | QgsFeatureIterator |
Internal feature iterator to be implemented within data providers.
Definition at line 28 of file qgsfeatureiterator.h.
Status of expression compilation for filter expression requests.
Definition at line 33 of file qgsfeatureiterator.h.
|
strong |
Possible results from the updateRequestToSourceCrs() method.
Definition at line 103 of file qgsfeatureiterator.h.
QgsAbstractFeatureIterator::QgsAbstractFeatureIterator | ( | const QgsFeatureRequest & | request | ) |
base class constructor - stores the iteration parameters
Definition at line 22 of file qgsfeatureiterator.cpp.
|
virtualdefault |
destructor makes sure that the iterator is closed properly
|
pure virtual |
Call to end the iteration.
This frees any resources used by the iterator.
Implemented in QgsCachedFeatureIterator, QgsCachedFeatureWriterIterator, and QgsVectorLayerFeatureIterator.
bool QgsAbstractFeatureIterator::compileFailed | ( | ) | const |
Indicator if there was an error when sending the compiled query to the server.
This indicates that there is something wrong with the expression compiler.
Definition at line 189 of file qgsfeatureiterator.cpp.
|
inline |
Returns the status of expression compilation for filter expression requests.
Definition at line 74 of file qgsfeatureiterator.h.
|
protected |
Remove reference, delete if refs == 0.
Definition at line 182 of file qgsfeatureiterator.cpp.
|
protectedpure virtual |
If you write a feature iterator for your provider, this is the method you need to implement!!
f | The feature to write to |
true
if a feature was written to f Implemented in QgsCachedFeatureIterator, QgsCachedFeatureWriterIterator, and QgsVectorLayerFeatureIterator.
|
protected |
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.
Definition at line 155 of file qgsfeatureiterator.cpp.
|
protected |
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.
Definition at line 98 of file qgsfeatureiterator.cpp.
|
inlinevirtual |
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 in QgsVectorLayerFeatureIterator.
Definition at line 85 of file qgsfeatureiterator.h.
|
virtual |
Fetch next feature and stores in f, returns true
on success.
Definition at line 27 of file qgsfeatureiterator.cpp.
|
protectedvirtual |
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.
f | The feature to write to |
true
if a feature was written to f Reimplemented in QgsVectorLayerFeatureIterator.
Definition at line 77 of file qgsfeatureiterator.cpp.
|
protectedvirtual |
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.
f | The feature to write to |
true
if a feature was written to f Reimplemented in QgsCachedFeatureIterator.
Definition at line 88 of file qgsfeatureiterator.cpp.
|
protectedvirtual |
Setup the simplification of geometries to fetch using the specified simplify method.
Reimplemented in QgsVectorLayerFeatureIterator.
Definition at line 194 of file qgsfeatureiterator.cpp.
|
protected |
Add reference.
Definition at line 165 of file qgsfeatureiterator.cpp.
|
pure virtual |
Resets the iterator to the starting position.
Implemented in QgsCachedFeatureIterator, QgsCachedFeatureWriterIterator, and QgsVectorLayerFeatureIterator.
|
virtual |
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.
Reimplemented in QgsVectorLayerFeatureIterator.
Definition at line 259 of file qgsfeatureiterator.cpp.
|
protected |
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 any QgsFeatureRequest::destinationCrs() set on the request is respected.
QgsCsException | if the rect cannot be transformed from the destination CRS. |
Definition at line 121 of file qgsfeatureiterator.cpp.
|
friend |
Definition at line 204 of file qgsfeatureiterator.h.
|
protected |
Sets to true
, as soon as the iterator is closed.
Definition at line 183 of file qgsfeatureiterator.h.
|
protected |
Definition at line 212 of file qgsfeatureiterator.h.
|
protected |
Status of compilation of filter expression.
Definition at line 210 of file qgsfeatureiterator.h.
|
protected |
Number of features already fetched by iterator.
Definition at line 207 of file qgsfeatureiterator.h.
|
protected |
A copy of the feature request.
Definition at line 180 of file qgsfeatureiterator.h.
|
protected |
An invalid state of a feature iterator indicates that there was a problem with even getting it up and running.
This should be set to false
by subclasses if they have problems connecting to the provider. Do NOT set this to false
when the feature iterator closes or has no features but we are sure, that it's just an empty dataset.
Definition at line 225 of file qgsfeatureiterator.h.
|
protected |
A feature iterator may be closed already but still be serving features from the cache.
This is done when we serve features which have been pre-fetched and the order by has been locally sorted. In such a scenario, all resources have been released (mClosed is true
) but the deads are still alive.
Definition at line 192 of file qgsfeatureiterator.h.
|
protected |
reference counting (to allow seamless copying of QgsFeatureIterator instances)
Definition at line 199 of file qgsfeatureiterator.h.