QGIS API Documentation 3.41.0-Master (181b2f43d8e)
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 : [email protected] *
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
181 void refreshCache( QgsFeature feature, const QgsFeature &origFeature );
182
190 void removeFeature( const QgsFeatureId featureId );
191
199 void setFeatureIds( const QgsFeatureIds &ids ) SIP_SKIP;
200
207 bool isFeatureCached( QgsFeatureId fid ) SIP_SKIP;
208
209 private:
210#ifdef SIP_RUN
211 QgsFeaturePool( const QgsFeaturePool &other )
212 {}
213#endif
214
215 static const int CACHE_SIZE = 1000;
216 QCache<QgsFeatureId, QgsFeature> mFeatureCache;
217 QPointer<QgsVectorLayer> mLayer;
218 mutable QReadWriteLock mCacheLock;
219 QgsFeatureIds mFeatureIds;
220 QgsSpatialIndex mIndex;
221 Qgis::GeometryType mGeometryType;
222 std::unique_ptr<QgsVectorLayerFeatureSource> mFeatureSource;
223 QString mLayerId;
224 QString mLayerName;
226
237 QHash<QgsFeatureId, QgsFeature> mUpdatedFeatures;
238
239 friend class TestQgsVectorLayerFeaturePool;
240};
241
242#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