QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
qgsfeaturepool.h
Go to the documentation of this file.
1/***************************************************************************
2 * qgsfeaturepool.h *
3 * ------------------- *
4 * copyright : (C) 2014 by Sandro Mani / Sourcepole AG *
5 * email : smani@sourcepole.ch *
6 ***************************************************************************/
7
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGS_FEATUREPOOL_H
18#define QGS_FEATUREPOOL_H
19
20#include <QCache>
21#include <QMutex>
22#include <QPointer>
23
24#include "qgis_analysis.h"
25#include "qgsfeature.h"
26#include "qgsspatialindex.h"
27#include "qgsfeaturesink.h"
29
37class ANALYSIS_EXPORT QgsFeaturePool : public QgsFeatureSink SIP_ABSTRACT
38{
39
40 public:
41
48 virtual ~QgsFeaturePool() = default;
49
58 bool getFeature( QgsFeatureId id, QgsFeature &feature );
59
72 QgsFeatureIds getFeatures( const QgsFeatureRequest &request, QgsFeedback *feedback = nullptr ) SIP_SKIP;
73
82 virtual void updateFeature( QgsFeature &feature ) = 0;
83
92 virtual void deleteFeature( QgsFeatureId fid ) = 0;
93
103 QgsFeatureIds allFeatureIds() const SIP_SKIP;
104
114 QgsFeatureIds getIntersects( const QgsRectangle &rect ) const SIP_SKIP;
115
122 QgsVectorLayer *layer() const;
123
134 QPointer<QgsVectorLayer> layerPtr() const SIP_SKIP;
135
139 QString layerId() const;
140
144 Qgis::GeometryType geometryType() const;
145
150
157 QString layerName() const;
158
159 protected:
160
168 void insertFeature( const QgsFeature &feature, bool skipLock = false );
169
177 void refreshCache( const QgsFeature &feature );
178
186 void removeFeature( const QgsFeatureId featureId );
187
195 void setFeatureIds( const QgsFeatureIds &ids ) SIP_SKIP;
196
203 bool isFeatureCached( QgsFeatureId fid ) SIP_SKIP;
204
205 private:
206#ifdef SIP_RUN
207 QgsFeaturePool( const QgsFeaturePool &other )
208 {}
209#endif
210
211 static const int CACHE_SIZE = 1000;
212 QCache<QgsFeatureId, QgsFeature> mFeatureCache;
213 QPointer<QgsVectorLayer> mLayer;
214 mutable QReadWriteLock mCacheLock;
215 QgsFeatureIds mFeatureIds;
216 QgsSpatialIndex mIndex;
217 Qgis::GeometryType mGeometryType;
218 std::unique_ptr<QgsVectorLayerFeatureSource> mFeatureSource;
219 QString mLayerId;
220 QString mLayerName;
222};
223
224#endif // QGS_FEATUREPOOL_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:337
This class represents a coordinate reference system (CRS).
A feature pool is based on a vector layer and caches features.
virtual ~QgsFeaturePool()=default
This class wraps a request for features to a vector layer (or directly its vector data provider).
An interface for objects which accept features via addFeature(s) methods.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
A rectangle specified with double values.
A spatial index for QgsFeature objects.
Represents a vector layer which manages a vector based data sets.
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_ABSTRACT
Definition qgis_sip.h:213
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
const QgsCoordinateReferenceSystem & crs