QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
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();
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
@ FilterFid
Filter using feature ID.
~QgsCachedFeatureIterator() override
const QgsFeatureIds & filterFids() const
Returns the feature IDs that should be fetched.
This class caches features of a given QgsVectorLayer.
@ NoFilter
No spatial filtering of features.
QgsCoordinateTransformContext transformContext() const
Returns the transform context, for use when a destinationCrs() has been set and reprojection is requi...
bool acceptFeature(const QgsFeature &feature)
Check if a feature is accepted by this requests filter.
void requestCompleted(const QgsFeatureRequest &featureRequest, const QgsFeatureIds &fids)
Gets called, whenever the full list of feature ids for a certain request is known.
QgsFeatureId filterFid() const
Returns the feature ID that should be fetched.
FilterType filterType() const
Returns the attribute/ID filter type which is currently set on this request.
bool mClosed
Sets to true, as soon as the iterator is closed.
@ FilterFids
Filter using feature IDs.
QgsCoordinateReferenceSystem sourceCrs() const
Returns the coordinate reference system for features in the cache.
void setValid(bool validity)
Sets the validity of the feature.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for feature's geometries, or an invalid QgsCoordi...
QgsFeatureRequest mRequest
A copy of the feature request.
bool close() override
Close this iterator.
bool fetchFeature(QgsFeature &f) override
Implementation for fetching a feature.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
QgsRectangle filterRectToSourceCrs(const QgsCoordinateTransform &transform) const SIP_THROW(QgsCsException)
Returns a rectangle representing the original request's QgsFeatureRequest::filterRect().
This class wraps a request for features to a vector layer (or directly its vector data provider).
Custom exception class for Coordinate Reference System related exceptions.
bool close() override
Close this iterator.
double distanceWithin() const
Returns the maximum distance from the referenceGeometry() of fetched features, if spatialFilterType()...
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
QgsVectorLayer * layer()
Returns the layer to which this cache belongs.
void geometryToDestinationCrs(QgsFeature &feature, const QgsCoordinateTransform &transform) const
Transforms feature's geometry according to the specified coordinate transform.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
Qgis::SpatialFilterType spatialFilterType() const
Returns the spatial filter type which is currently set on this request.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine representing the specified geometry.
bool nextFeature(QgsFeature &f)
bool rewind() override
Rewind to the beginning of the iterator.
@ BoundingBox
Filter using a bounding box.
bool fetchFeature(QgsFeature &f) override
Implementation for fetching a feature.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
bool rewind() override
Rewind to the beginning of the iterator.
Internal feature iterator to be implemented within data providers.
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
@ DistanceWithin
Filter by distance to reference geometry.
QgsGeometry referenceGeometry() const
Returns the reference geometry used for spatial filtering of features.
QgsCachedFeatureWriterIterator(QgsVectorLayerCache *vlCache, const QgsFeatureRequest &featureRequest)
This constructor creates a feature iterator, which queries the backend and caches retrieved features.
QgsCachedFeatureIterator(QgsVectorLayerCache *vlCache, const QgsFeatureRequest &featureRequest)
This constructor creates a feature iterator, that delivers all cached features.