QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
37 class ANALYSIS_EXPORT QgsFeaturePool : public QgsFeatureSink SIP_ABSTRACT
38 {
39 
40  public:
41 
46  virtual ~QgsFeaturePool() = default;
47 
53  bool getFeature( QgsFeatureId id, QgsFeature &feature );
54 
65  QgsFeatureIds getFeatures( const QgsFeatureRequest &request, QgsFeedback *feedback = nullptr ) SIP_SKIP;
66 
71  virtual void updateFeature( QgsFeature &feature ) = 0;
72 
77  virtual void deleteFeature( QgsFeatureId fid ) = 0;
78 
85  QgsFeatureIds allFeatureIds() const SIP_SKIP;
86 
93  QgsFeatureIds getIntersects( const QgsRectangle &rect ) const SIP_SKIP;
94 
100  QgsVectorLayer *layer() const;
101 
111  QPointer<QgsVectorLayer> layerPtr() const SIP_SKIP;
112 
116  QString layerId() const;
117 
121  QgsWkbTypes::GeometryType geometryType() const;
122 
127 
134  QString layerName() const;
135 
136  protected:
137 
142  void insertFeature( const QgsFeature &feature, bool skipLock = false );
143 
148  void refreshCache( const QgsFeature &feature );
149 
154  void removeFeature( const QgsFeatureId featureId );
155 
163  void setFeatureIds( const QgsFeatureIds &ids ) SIP_SKIP;
164 
171  bool isFeatureCached( QgsFeatureId fid ) SIP_SKIP;
172 
173  private:
174 #ifdef SIP_RUN
175  QgsFeaturePool( const QgsFeaturePool &other )
176  {}
177 #endif
178 
179  static const int CACHE_SIZE = 1000;
180  QCache<QgsFeatureId, QgsFeature> mFeatureCache;
181  QPointer<QgsVectorLayer> mLayer;
182  mutable QReadWriteLock mCacheLock;
183  QgsFeatureIds mFeatureIds;
184  QgsSpatialIndex mIndex;
185  QgsWkbTypes::GeometryType mGeometryType;
186  std::unique_ptr<QgsVectorLayerFeatureSource> mFeatureSource;
187  QString mLayerName;
188 };
189 
190 #endif // QGS_FEATUREPOOL_H
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
qgsfeaturesink.h
qgsfeature.h
QgsRectangle
Definition: qgsrectangle.h:41
QgsFeatureRequest
Definition: qgsfeaturerequest.h:75
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsFeedback
Definition: qgsfeedback.h:43
QgsSpatialIndex
Definition: qgsspatialindex.h:67
qgsvectorlayerfeatureiterator.h
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:34
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:139
QgsVectorLayer
Definition: qgsvectorlayer.h:385
qgsspatialindex.h
QgsFeature
Definition: qgsfeature.h:55
QgsFeatureSink
Definition: qgsfeaturesink.h:33
QgsFeaturePool
Definition: qgsfeaturepool.h:37
SIP_ABSTRACT
#define SIP_ABSTRACT
Definition: qgis_sip.h:194
QgsFeatureId
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25