QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsmemoryprovider.h
Go to the documentation of this file.
1 /***************************************************************************
2  memoryprovider.h - provider with storage in memory
3  ------------------
4  begin : June 2008
5  copyright : (C) 2008 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #define SIP_NO_FILE
17 
18 #include "qgsvectordataprovider.h"
20 #include "qgsfields.h"
21 
23 typedef QMap<QgsFeatureId, QgsFeature> QgsFeatureMap;
24 
25 class QgsSpatialIndex;
26 
27 class QgsMemoryFeatureIterator;
28 
29 class QgsMemoryProvider final: public QgsVectorDataProvider
30 {
31  Q_OBJECT
32 
33  public:
34  explicit QgsMemoryProvider( const QString &uri, const QgsVectorDataProvider::ProviderOptions &coordinateTransformContext,
35  QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
36 
37  ~QgsMemoryProvider() override;
38 
40  static QString providerKey();
42  static QString providerDescription();
43 
48  static QgsMemoryProvider *createProvider( const QString &uri, const QgsVectorDataProvider::ProviderOptions &coordinateTransformContext,
49  QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
50 
51  /* Implementation of functions from QgsVectorDataProvider */
52 
53  QgsAbstractFeatureSource *featureSource() const override;
54 
55  QString dataSourceUri( bool expandAuthConfig = true ) const override;
56  QString storageType() const override;
57  QgsFeatureIterator getFeatures( const QgsFeatureRequest &request ) const override;
58  QgsWkbTypes::Type wkbType() const override;
59  long long featureCount() const override;
60  QgsFields fields() const override;
61  bool addFeatures( QgsFeatureList &flist, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override;
62  bool deleteFeatures( const QgsFeatureIds &id ) override;
63  bool addAttributes( const QList<QgsField> &attributes ) override;
64  bool renameAttributes( const QgsFieldNameMap &renamedAttributes ) override;
65  bool deleteAttributes( const QgsAttributeIds &attributes ) override;
66  bool changeAttributeValues( const QgsChangedAttributesMap &attr_map ) override;
67  bool changeGeometryValues( const QgsGeometryMap &geometry_map ) override;
68  QString subsetString() const override;
69  bool setSubsetString( const QString &theSQL, bool updateFeatureCount = true ) override;
70  bool supportsSubsetString() const override { return true; }
71  bool createSpatialIndex() override;
72  QgsFeatureSource::SpatialIndexPresence hasSpatialIndex() const override;
73  QgsVectorDataProvider::Capabilities capabilities() const override;
74  bool truncate() override;
75 
76  /* Implementation of functions from QgsDataProvider */
77 
78  QString name() const override;
79  QString description() const override;
80  QgsRectangle extent() const override;
81  void updateExtents() override;
82  bool isValid() const override;
83  QgsCoordinateReferenceSystem crs() const override;
84  void handlePostCloneOperations( QgsVectorDataProvider *source ) override;
85 
86  private:
87  // Coordinate reference system
89 
90  // fields
91  QgsFields mFields;
92  QgsWkbTypes::Type mWkbType;
93  mutable QgsRectangle mExtent;
94 
95  // features
96  QgsFeatureMap mFeatures;
97  QgsFeatureId mNextFeatureId;
98 
99  // indexing
100  QgsSpatialIndex *mSpatialIndex = nullptr;
101 
102  QString mSubsetString;
103 
104  friend class QgsMemoryFeatureSource;
105 };
106 
Base class that can be used for any class that is capable of returning features.
This class represents a coordinate reference system (CRS).
Wrapper for iterator of features from vector data provider or vector layer.
This class wraps a request for features to a vector layer (or directly its vector data provider).
SpatialIndexPresence
Enumeration of spatial index presence states.
Container of fields for a vector layer.
Definition: qgsfields.h:45
A rectangle specified with double values.
Definition: qgsrectangle.h:42
A spatial index for QgsFeature objects.
This is the base class for vector data providers.
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70
QMap< int, QString > QgsFieldNameMap
Definition: qgsattributes.h:44
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
Definition: qgsfeature.h:731
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
Definition: qgsfeature.h:722
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:736
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28
QSet< int > QgsAttributeIds
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
const QgsCoordinateReferenceSystem & crs
Setting options for creating vector data providers.