24 , mVectorLayerCache( vlCache )
53 mDistanceWithinEngine->prepareGeometry();
59 if ( !mFilterRect.
isNull() )
68 mFeatureIds = QList< QgsFeatureId >( qgis::setToList( featureRequest.
filterFids() ) );
72 mFeatureIds = QList< QgsFeatureId >() << featureRequest.
filterFid();
76 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
78 mFeatureIds.reserve(
static_cast< int >( mVectorLayerCache->mCacheOrderedKeys.size() ) );
79 for (
auto it = mVectorLayerCache->mCacheOrderedKeys.begin(); it != mVectorLayerCache->mCacheOrderedKeys.end(); ++it )
82 mFeatureIds = QList( mVectorLayerCache->mCacheOrderedKeys.begin(), mVectorLayerCache->mCacheOrderedKeys.end() );
87 mFeatureIdIterator = mFeatureIds.constBegin();
89 if ( mFeatureIdIterator == mFeatureIds.constEnd() )
102 while ( mFeatureIdIterator != mFeatureIds.constEnd() )
104 if ( !mVectorLayerCache->mCache.contains( *mFeatureIdIterator ) )
106 ++mFeatureIdIterator;
110 f =
QgsFeature( *mVectorLayerCache->mCache[*mFeatureIdIterator]->feature() );
111 ++mFeatureIdIterator;
118 if ( mDistanceWithinEngine && mDistanceWithinEngine->distance( f.
geometry().
constGet() ) > mDistanceWithin )
134 mFeatureIdIterator = mFeatureIds.constBegin();
147 , mVectorLayerCache( vlCache )
163 if ( !mFilterRect.
isNull() )
182 mVectorLayerCache->cacheFeature( f );
183 mFids.insert( f.
id() );
205 return mFeatIt.
close();
@ DistanceWithin
Filter by distance to reference geometry.
@ BoundingBox
Filter using a bounding box.
@ NoFilter
No spatial filtering of features.
Internal feature iterator to be implemented within data providers.
void geometryToDestinationCrs(QgsFeature &feature, const QgsCoordinateTransform &transform) const
Transforms feature's geometry according to the specified coordinate transform.
QgsRectangle filterRectToSourceCrs(const QgsCoordinateTransform &transform) const SIP_THROW(QgsCsException)
Returns a rectangle representing the original request's QgsFeatureRequest::filterRect().
QgsFeatureRequest mRequest
A copy of the feature request.
bool mClosed
Sets to true, as soon as the iterator is closed.
bool fetchFeature(QgsFeature &f) override
Implementation for fetching a feature.
QgsCachedFeatureIterator(QgsVectorLayerCache *vlCache, const QgsFeatureRequest &featureRequest)
This constructor creates a feature iterator, that delivers all cached features.
bool close() override
Close this iterator.
bool rewind() override
Rewind to the beginning of the iterator.
~QgsCachedFeatureIterator() override
bool fetchFeature(QgsFeature &f) override
Implementation for fetching a feature.
bool close() override
Close this iterator.
QgsCachedFeatureWriterIterator(QgsVectorLayerCache *vlCache, const QgsFeatureRequest &featureRequest)
This constructor creates a feature iterator, which queries the backend and caches retrieved features.
bool rewind() override
Rewind to the beginning of the iterator.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Custom exception class for Coordinate Reference System related exceptions.
bool nextFeature(QgsFeature &f)
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsGeometry referenceGeometry() const
Returns the reference geometry used for spatial filtering of features.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for feature's geometries, or an invalid QgsCoordi...
bool acceptFeature(const QgsFeature &feature)
Check if a feature is accepted by this requests filter.
QgsCoordinateTransformContext transformContext() const
Returns the transform context, for use when a destinationCrs() has been set and reprojection is requi...
Qgis::SpatialFilterType spatialFilterType() const
Returns the spatial filter type which is currently set on this request.
double distanceWithin() const
Returns the maximum distance from the referenceGeometry() of fetched features, if spatialFilterType()...
FilterType filterType() const
Returns the attribute/ID filter type which is currently set on this request.
const QgsFeatureIds & filterFids() const
Returns the feature IDs that should be fetched.
@ FilterFid
Filter using feature ID.
@ FilterFids
Filter using feature IDs.
QgsFeatureId filterFid() const
Returns the feature ID that should be fetched.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void setValid(bool validity)
Sets the validity of the feature.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine representing the specified geometry.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
This class caches features of a given QgsVectorLayer.
void requestCompleted(const QgsFeatureRequest &featureRequest, const QgsFeatureIds &fids)
Gets called, whenever the full list of feature ids for a certain request is known.
QgsVectorLayer * layer()
Returns the layer to which this cache belongs.
QgsCoordinateReferenceSystem sourceCrs() const
Returns the coordinate reference system for features in the cache.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.