QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
35 if ( mUseCachedFeatures )
37 if ( mFeatureIterator != mCachedFeatures.constEnd() )
39 f = mFeatureIterator->mFeature;
157 Q_UNUSED( simplifyMethod )
161 void QgsAbstractFeatureIterator::setupOrderBy(
const QList<QgsFeatureRequest::OrderByClause> &orderBys )
164 if ( !orderBys.isEmpty() && !prepareOrderBy( orderBys ) )
169 QList<QgsFeatureRequest::OrderByClause> preparedOrderBys( orderBys );
170 QList<QgsFeatureRequest::OrderByClause>::iterator orderByIt( preparedOrderBys.begin() );
175 orderByIt->prepare( expressionContext );
177 while ( ++orderByIt != preparedOrderBys.end() );
181 indexedFeature.
mIndexes.resize( preparedOrderBys.size() );
185 expressionContext->setFeature( indexedFeature.
mFeature );
187 const auto constPreparedOrderBys = preparedOrderBys;
190 indexedFeature.
mIndexes.replace( i++, orderBy.expression().evaluate( expressionContext ) );
196 mCachedFeatures.append( indexedFeature );
199 std::sort( mCachedFeatures.begin(), mCachedFeatures.end(), QgsExpressionSorter( preparedOrderBys ) );
201 mFeatureIterator = mCachedFeatures.constBegin();
202 mUseCachedFeatures =
true;
210 Q_UNUSED( methodType )
214 bool QgsAbstractFeatureIterator::prepareOrderBy(
const QList<QgsFeatureRequest::OrderByClause> &orderBys )
228 if (
this != &other )
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
int refs
reference counting (to allow seamless copying of QgsFeatureIterator instances) TODO QGIS3: make this ...
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
const QgsFeatureIds & filterFids() const
Gets feature IDs that should be fetched.
virtual void setInterruptionChecker(QgsFeedback *interruptionChecker)
Attach an object that can be queried regularly by the iterator to check if it must stopped.
virtual bool isValid() const
Returns if this iterator is valid.
const QgsRectangle & filterRect() const
Returns the rectangle from which features will be taken.
FilterType filterType() const
Returns the filter type which is currently set on this request.
long mFetchedCount
Number of features already fetched by iterator.
@ FilterFids
Filter using feature IDs.
QgsFeatureRequest mRequest
A copy of the feature request.
virtual bool nextFeatureFilterExpression(QgsFeature &f)
By default, the iterator will fetch all features and check if the feature matches the expression.
virtual bool nextFeature(QgsFeature &f)
fetch next feature, return true on success
QgsExpressionContext * expressionContext()
Returns the expression context used to evaluate filter expressions.
void clearGeometry()
Removes any geometry associated with the feature.
QgsRectangle filterRectToSourceCrs(const QgsCoordinateTransform &transform) const SIP_THROW(QgsCsException)
Returns a rectangle representing the original request's QgsFeatureRequest::filterRect().
bool mZombie
A feature iterator may be closed already but still be serving features from the cache.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
QgsExpression * filterExpression() const
Returns the filter expression if set.
@ FilterExpression
Filter using expression.
void geometryToDestinationCrs(QgsFeature &feature, const QgsCoordinateTransform &transform) const
Transforms feature's geometry according to the specified coordinate transform.
QgsAbstractFeatureIterator(const QgsFeatureRequest &request)
base class constructor - stores the iteration parameters
QVariant evaluate()
Evaluate the feature and return the result.
virtual bool nextFeatureFilterFids(QgsFeature &f)
By default, the iterator will fetch all features and check if the id is in the request.
OrderBy orderBy() const
Returns a list of order by clauses specified for this feature request.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
virtual bool fetchFeature(QgsFeature &f)=0
If you write a feature iterator for your provider, this is the method you need to implement!...
void deref()
Remove reference, delete if refs == 0.
const QgsSimplifyMethod & simplifyMethod() const
Gets simplification method for geometries that will be fetched.
QgsFeatureIterator & operator=(const QgsFeatureIterator &other)
bool compileFailed() const
Indicator if there was an error when sending the compiled query to the server.
QVector< QVariant > mIndexes
std::function< void(const QgsFeature &) > transformErrorCallback() const
Returns the callback function to use when encountering a transform error when iterating features and ...
QgsAbstractFeatureIterator * mIter
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
bool isValid() const
Will return if this iterator is valid.
virtual bool prepareSimplification(const QgsSimplifyMethod &simplifyMethod)
Setup the simplification of geometries to fetch using the specified simplify method.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
long limit() const
Returns the maximum number of features to request, or -1 if no limit set.