QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
26 #include <QMutexLocker>
30 : mFeatureCache( CACHE_SIZE )
32 , mGeometryType( layer->geometryType() )
34 , mLayerName( layer->name() )
50 QgsFeature *cachedFeature = mFeatureCache.object(
id );
54 feature = *cachedFeature;
60 if ( !mFeatureSource->getFeatures(
QgsFeatureRequest(
id ) ).nextFeature( feature ) )
65 mFeatureCache.insert(
id,
new QgsFeature( feature ) );
75 Q_ASSERT( QThread::currentThread() == qApp->thread() );
77 mFeatureCache.clear();
82 mFeatureSource = qgis::make_unique<QgsVectorLayerFeatureSource>( mLayer );
109 Q_ASSERT( QThread::currentThread() == qApp->thread() );
111 return mLayer.data();
124 mFeatureCache.insert( feature.
id(),
new QgsFeature( feature ) );
132 mFeatureCache.remove( feature.
id() );
150 mFeatureCache.remove( origFeature.
id() );
161 return mFeatureCache.contains( fid );
172 return mFeatureSource->crs();
177 return mGeometryType;
183 return mFeatureSource->id();
void changeMode(Mode mode)
Change the mode of the lock to mode.
bool deleteFeature(const QgsFeature &feature)
Removes a feature from the index.
QgsFeatureIds getFeatures(const QgsFeatureRequest &request, QgsFeedback *feedback=nullptr)
Gets features for the provided request.
void setFeatureIds(const QgsFeatureIds &ids)
Sets all the feature ids governed by this feature pool.
QPointer< QgsVectorLayer > layerPtr() const
Gets a QPointer to the underlying layer.
bool getFeature(QgsFeatureId id, QgsFeature &feature)
Retrieves the feature with the specified id into feature.
void unlock()
Unlocks the lock.
bool isFeatureCached(QgsFeatureId fid)
Checks if the feature fid is cached.
QgsWkbTypes::GeometryType geometryType() const
The geometry type of this layer.
QString layerName() const
Returns the name of the layer.
QSet< QgsFeatureId > QgsFeatureIds
QgsCoordinateReferenceSystem crs() const
The coordinate reference system of this layer.
void removeFeature(const QgsFeatureId featureId)
Removes a feature from the cache and the spatial index.
QgsFeatureIds allFeatureIds() const
Returns the complete set of feature ids in this pool.
QgsVectorLayer * layer() const
Gets a pointer to the underlying layer.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
bool nextFeature(QgsFeature &f)
QList< QgsFeatureId > intersects(const QgsRectangle &rectangle) const
Returns a list of features with a bounding box which intersects the specified rectangle.
QString layerId() const
The layer id of the layer.
QgsFeaturePool(QgsVectorLayer *layer)
Creates a new feature pool for layer.
QgsFeatureIds getIntersects(const QgsRectangle &rect) const
Gets all feature ids in the bounding box rect.
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a feature to the index.
void refreshCache(const QgsFeature &feature)
Changes a feature in the cache and the spatial index.
void insertFeature(const QgsFeature &feature, bool skipLock=false)
Inserts a feature into the cache and the spatial index.