QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
19 #ifndef QgsVectorLayerCache_H
20 #define QgsVectorLayerCache_H
22 #include "qgis_core.h"
56 class QgsCachedFeature
76 mCache->featureRemoved( mFeature->id() );
80 inline const QgsFeature *feature() {
return mFeature; }
280 sipRes = sipCpp->featureCount();
284 int __bool__()
const;
378 void onAttributeValueChanged(
QgsFeatureId fid,
int field,
const QVariant &value );
379 void onJoinAttributeValueChanged(
QgsFeatureId fid,
int field,
const QVariant &value );
382 void attributeAdded(
int field );
383 void attributeDeleted(
int field );
390 void connectJoinedLayers()
const;
395 mCache.insert( feat.
id(), cachedFeature );
399 QCache< QgsFeatureId, QgsCachedFeature > mCache;
401 bool mCacheGeometry =
true;
402 bool mFullCache =
false;
403 QList<QgsAbstractCacheIndex *> mCacheIndices;
409 friend class QgsCachedFeature;
421 friend class TestVectorLayerCache;
423 #endif // QgsVectorLayerCache_H
Uses another iterator as backend and writes features to the cache.
void setCacheSubsetOfAttributes(const QgsAttributeList &attributes)
Set the subset of attributes to be cached.
The cached features can be indexed by QgsAbstractCacheIndex.
void requestCompleted(const QgsFeatureRequest &featureRequest, const QgsFeatureIds &fids)
Gets called, whenever the full list of feature ids for a certain request is known.
QgsWkbTypes::Type wkbType() const
Returns the geometry type for features in the cache.
void setCacheAddedAttributes(bool cacheAddedAttributes)
If this is enabled, the subset of cached attributes will automatically be extended to also include ne...
QgsVectorLayerCache(QgsVectorLayer *layer, int cacheSize, QObject *parent=nullptr)
~QgsVectorLayerCache() override
QgsCoordinateReferenceSystem sourceCrs() const
Returns the coordinate reference system for features in the cache.
bool removeCachedFeature(QgsFeatureId fid)
Removes the feature identified by fid from the cache if present.
Type
The WKB type describes the number of dimensions a geometry has.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &featureRequest=QgsFeatureRequest())
Query this VectorLayerCache for features.
void invalidated()
The cache has been invalidated and cleared.
QList< int > QgsAttributeList
bool checkInformationCovered(const QgsFeatureRequest &featureRequest)
Checks if the information required to complete the request is cached.
QgsFeature getFeature(QgsFeatureId fid)
Query the layer for the feature with the given id.
void attributeValueChanged(QgsFeatureId fid, int field, const QVariant &value)
Emitted when an attribute is changed.
void finished()
When filling the cache, this signal gets emitted once the cache is fully initialized.
QgsFields fields() const
Returns the fields associated with features in the cache.
void progress(int i, bool &cancel)
When filling the cache, this signal gets emitted periodically to notify about the progress and to be ...
void addCacheIndex(QgsAbstractCacheIndex *cacheIndex)
Adds a QgsAbstractCacheIndex to this cache.
void featureAdded(QgsFeatureId fid)
Emitted when a new feature has been added to the layer and this cache.
void featureRemoved(QgsFeatureId fid)
Gets called, whenever a feature has been removed.
QgsVectorLayer * layer()
Returns the layer to which this cache belongs.
bool featureAtId(QgsFeatureId featureId, QgsFeature &feature, bool skipCache=false)
Gets the feature at the given feature id.
QSet< QgsFeatureId > QgsFeatureIds
void cachedLayerDeleted()
Is emitted when the cached layer is deleted.
Abstract base class for cache indices.
bool isFidCached(QgsFeatureId fid) const
Check if a certain feature id is cached.
void setFullCache(bool fullCache)
This enables or disables full caching.
bool hasFullCache() const
Returns true if the cache is complete, ie it contains all features.
int cacheSize()
Returns the maximum number of features this cache will hold.
Delivers features from the cache.
bool nextFeature(QgsFeature &f)
friend class QgsCachedFeature
long featureCount() const
Returns the number of features contained in the source, or -1 if the feature count is unknown.
void setCacheGeometry(bool cacheGeometry)
Enable or disable the caching of geometries.
void setCacheSize(int cacheSize)
Sets the maximum number of features to keep in the cache.
QgsFeatureIterator getFeatures(const QString &expression)
Query the layer for features matching a given expression.
QgsFeatureIterator getFeatures(const QgsRectangle &rectangle)
Query the layer for the features which intersect the specified rectangle.
QgsFeatureIterator getFeatures(const QgsFeatureIds &fids)
Query the layer for the features with the given ids.
bool cacheGeometry() const
Returns true if the cache will fetch and cache feature geometries.
QgsFeatureIds cachedFeatureIds() const
Returns the set of feature IDs for features which are cached.