35 if ( mUseCachedFeatures )
37 if ( mFeatureIterator != mCachedFeatures.constEnd() )
39 f = mFeatureIterator->mFeature;
152 Q_UNUSED( simplifyMethod );
156 void QgsAbstractFeatureIterator::setupOrderBy(
const QList<QgsFeatureRequest::OrderByClause> &orderBys )
159 if ( !orderBys.isEmpty() && !prepareOrderBy( orderBys ) )
164 QList<QgsFeatureRequest::OrderByClause> preparedOrderBys( orderBys );
165 QList<QgsFeatureRequest::OrderByClause>::iterator orderByIt( preparedOrderBys.begin() );
170 orderByIt->prepare( expressionContext );
172 while ( ++orderByIt != preparedOrderBys.end() );
176 indexedFeature.
mIndexes.resize( preparedOrderBys.size() );
180 expressionContext->setFeature( indexedFeature.
mFeature );
184 indexedFeature.
mIndexes.replace( i++, orderBy.
expression().evaluate( expressionContext ) );
190 mCachedFeatures.append( indexedFeature );
193 std::sort( mCachedFeatures.begin(), mCachedFeatures.end(), QgsExpressionSorter( preparedOrderBys ) );
195 mFeatureIterator = mCachedFeatures.constBegin();
196 mUseCachedFeatures =
true;
204 Q_UNUSED( methodType )
208 bool QgsAbstractFeatureIterator::prepareOrderBy(
const QList<QgsFeatureRequest::OrderByClause> &orderBys )
222 if (
this != &other )
235 return mIter && mIter->isValid();
Wrapper for iterator of features from vector data provider or vector layer.
A rectangle specified with double values.
long limit() const
Returns the maximum number of features to request, or -1 if no limit set.
void geometryToDestinationCrs(QgsFeature &feature, const QgsCoordinateTransform &transform) const
Transforms feature's geometry according to the specified coordinate transform.
Filter using feature IDs.
long mFetchedCount
Number of features already fetched by iterator.
virtual bool fetchFeature(QgsFeature &f)=0
If you write a feature iterator for your provider, this is the method you need to implement!! ...
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
QgsExpressionContext * expressionContext()
Returns the expression context used to evaluate filter expressions.
QgsRectangle filterRectToSourceCrs(const QgsCoordinateTransform &transform) const
Returns a rectangle representing the original request's QgsFeatureRequest::filterRect().
FilterType filterType() const
Return the filter type which is currently set on this request.
const QgsFeatureIds & filterFids() const
Get feature IDs that should be fetched.
A geometry is the spatial representation of a feature.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
bool hasGeometry() const
Returns true if the feature has an associated geometry.
const QgsRectangle & filterRect() const
Returns the rectangle from which features will be taken.
QgsExpression * filterExpression() const
Returns the filter expression if set.
Base class for feedback objects to be used for cancelation of something running in a worker thread...
virtual bool nextFeature(QgsFeature &f)
fetch next feature, return true on success
Temporarily used structure to cache order by information.
QgsFeatureIterator & operator=(const QgsFeatureIterator &other)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
virtual bool nextFeatureFilterExpression(QgsFeature &f)
By default, the iterator will fetch all features and check if the feature matches the expression...
bool mZombie
A feature iterator may be closed already but still be serving features from the cache.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
void deref()
Remove reference, delete if refs == 0.
QgsGeometry geometry() const
Returns the geometry associated with this feature.
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
virtual bool nextFeatureFilterFids(QgsFeature &f)
By default, the iterator will fetch all features and check if the id is in the request.
The OrderByClause class represents an order by clause for a QgsFeatureRequest.
QgsFeatureRequest mRequest
A copy of the feature request.
void clearGeometry()
Removes any geometry associated with the feature.
QgsExpression expression() const
The expression.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
QgsAbstractFeatureIterator * mIter
virtual void setInterruptionChecker(QgsFeedback *interruptionChecker)
Attach an object that can be queried regularly by the iterator to check if it must stopped...
QVector< QVariant > mIndexes
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
Custom exception class for Coordinate Reference System related exceptions.
int refs
reference counting (to allow seamless copying of QgsFeatureIterator instances) TODO QGIS3: make this ...
OrderBy orderBy() const
Return a list of order by clauses specified for this feature request.
std::function< void(const QgsFeature &) > transformErrorCallback() const
Returns the callback function to use when encountering a transform error when iterating features and ...
virtual bool prepareSimplification(const QgsSimplifyMethod &simplifyMethod)
Setup the simplification of geometries to fetch using the specified simplify method.
virtual bool isValid() const
Will return if this iterator is valid.
const QgsSimplifyMethod & simplifyMethod() const
Get simplification method for geometries that will be fetched.
QgsAbstractFeatureIterator(const QgsFeatureRequest &request)
base class constructor - stores the iteration parameters