QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 public:
46 virtual ~QgsFeaturePool() = default;
47
56 bool getFeature( QgsFeatureId id, QgsFeature &feature );
57
70 QgsFeatureIds getFeatures( const QgsFeatureRequest &request, QgsFeedback *feedback = nullptr ) SIP_SKIP;
71
80 virtual void updateFeature( QgsFeature &feature ) = 0;
81
90 virtual void deleteFeature( QgsFeatureId fid ) = 0;
91
101 QgsFeatureIds allFeatureIds() const SIP_SKIP;
102
112 QgsFeatureIds getIntersects( const QgsRectangle &rect ) const SIP_SKIP;
113
120 QgsVectorLayer *layer() const;
121
132 QPointer<QgsVectorLayer> layerPtr() const SIP_SKIP;
133
137 QString layerId() const;
138
142 Qgis::GeometryType geometryType() const;
143
148
155 QString layerName() const;
156
157 protected:
165 void insertFeature( const QgsFeature &feature, bool skipLock = false );
166
178 void refreshCache( QgsFeature feature, const QgsFeature &origFeature );
179
187 void removeFeature( const QgsFeatureId featureId );
188
196 void setFeatureIds( const QgsFeatureIds &ids ) SIP_SKIP;
197
204 bool isFeatureCached( QgsFeatureId fid ) SIP_SKIP;
205
206 private:
207#ifdef SIP_RUN
208 QgsFeaturePool( const QgsFeaturePool &other )
209 {}
210#endif
211
212 static const int CACHE_SIZE = 1000;
213 QCache<QgsFeatureId, QgsFeature> mFeatureCache;
214 QPointer<QgsVectorLayer> mLayer;
215 mutable QReadWriteLock mCacheLock;
216 QgsFeatureIds mFeatureIds;
217 QgsSpatialIndex mIndex;
218 Qgis::GeometryType mGeometryType;
219 std::unique_ptr<QgsVectorLayerFeatureSource> mFeatureSource;
220 QString mLayerId;
221 QString mLayerName;
223
234 QHash<QgsFeatureId, QgsFeature> mUpdatedFeatures;
235
236 friend class TestQgsVectorLayerFeaturePool;
237};
238
239#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