QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
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#ifndef QGSMEMORYPROVIDER_H
17#define QGSMEMORYPROVIDER_H
18
19#define SIP_NO_FILE
20
23#include "qgsfields.h"
24#include "qgsprovidermetadata.h"
25
27typedef QMap<QgsFeatureId, QgsFeature> QgsFeatureMap;
28
29class QgsSpatialIndex;
30
31class QgsMemoryFeatureIterator;
32
33class QgsMemoryProvider final: public QgsVectorDataProvider
34{
35 Q_OBJECT
36
37 public:
38 explicit QgsMemoryProvider( const QString &uri, const QgsVectorDataProvider::ProviderOptions &coordinateTransformContext,
40
41 ~QgsMemoryProvider() override;
42
44 static QString providerKey();
46 static QString providerDescription();
47
48 /* Implementation of functions from QgsVectorDataProvider */
49
51
52 QString dataSourceUri( bool expandAuthConfig = true ) const override;
53 QString storageType() const override;
54 QgsFeatureIterator getFeatures( const QgsFeatureRequest &request ) const override;
55 Qgis::WkbType wkbType() const override;
56 long long featureCount() const override;
57 QgsFields fields() const override;
59 bool deleteFeatures( const QgsFeatureIds &id ) override;
60 bool addAttributes( const QList<QgsField> &attributes ) override;
61 bool renameAttributes( const QgsFieldNameMap &renamedAttributes ) override;
62 bool deleteAttributes( const QgsAttributeIds &attributes ) override;
63 bool changeAttributeValues( const QgsChangedAttributesMap &attr_map ) override;
64 bool changeGeometryValues( const QgsGeometryMap &geometry_map ) override;
65 QString subsetString() const override;
66 bool setSubsetString( const QString &theSQL, bool updateFeatureCount = true ) override;
67 bool supportsSubsetString() const override;
68 QString subsetStringDialect() const override;
69 QString subsetStringHelpUrl() const override;
70 bool createSpatialIndex() override;
73 bool truncate() override;
74
75 /* Implementation of functions from QgsDataProvider */
76
77 QString name() const override;
78 QString description() const override;
79 QgsRectangle extent() const override;
80 void updateExtents() override;
81 bool isValid() const override;
82 QgsCoordinateReferenceSystem crs() const override;
83 void handlePostCloneOperations( QgsVectorDataProvider *source ) override;
84
85 private:
86 // Coordinate reference system
88
89 // fields
90 QgsFields mFields;
91 Qgis::WkbType mWkbType;
92 mutable QgsRectangle mExtent;
93
94 // features
95 QgsFeatureMap mFeatures;
96 QgsFeatureId mNextFeatureId;
97
98 // indexing
99 QgsSpatialIndex *mSpatialIndex = nullptr;
100
101 QString mSubsetString;
102
103 friend class QgsMemoryFeatureSource;
104};
105
106
107class QgsMemoryProviderMetadata final: public QgsProviderMetadata
108{
109 Q_OBJECT
110
111 public:
112 QgsMemoryProviderMetadata();
113 QIcon icon() const override;
115 QList< Qgis::LayerType > supportedLayerTypes() const override;
116};
117
119#endif // QGSMEMORYPROVIDER_H
SpatialIndexPresence
Enumeration of spatial index presence states.
Definition qgis.h:522
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:450
QFlags< VectorProviderCapability > VectorProviderCapabilities
Vector data provider capabilities.
Definition qgis.h:500
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:256
Base class that can be used for any class that is capable of returning features.
This class represents a coordinate reference system (CRS).
Abstract base class for spatial data provider implementations.
virtual QString subsetString() const
Returns the subset definition string currently in use by the layer and used by the provider to limit ...
virtual QString name() const =0
Returns a provider name.
virtual bool supportsSubsetString() const
Returns true if the provider supports setting of subset strings.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
virtual QString subsetStringHelpUrl() const
Returns a URL pointing to documentation describing the dialect which is supported for subset strings ...
virtual bool isValid() const =0
Returns true if this is a valid layer.
virtual bool setSubsetString(const QString &subset, bool updateFeatureCount=true)
Set the subset string used to create a subset of features in the layer.
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
virtual QString description() const =0
Returns description.
virtual QString subsetStringDialect() const
Returns a user-friendly string describing the dialect which is supported for subset strings by the pr...
virtual void updateExtents()
Update the extents of the layer.
virtual QgsRectangle extent() const =0
Returns the extent of the layer.
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).
QFlags< Flag > Flags
virtual Qgis::SpatialIndexPresence hasSpatialIndex() const
Returns an enum value representing the presence of a valid spatial index on the source,...
Container of fields for a vector layer.
Definition qgsfields.h:46
Holds data provider key, description, and associated shared library file or function pointer informat...
virtual QgsDataProvider * createProvider(const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags=Qgis::DataProviderReadFlags())
Class factory to return a pointer to a newly created QgsDataProvider object.
virtual QIcon icon() const
Returns an icon representing the provider.
virtual QList< Qgis::LayerType > supportedLayerTypes() const
Returns a list of the map layer types supported by the provider.
A rectangle specified with double values.
A spatial index for QgsFeature objects.
This is the base class for vector data providers.
virtual bool changeGeometryValues(const QgsGeometryMap &geometry_map)
Changes geometries of existing features.
virtual bool createSpatialIndex()
Creates a spatial index on the datasource (if supported by the provider type).
long long featureCount() const override=0
Number of features in the layer.
virtual QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
virtual bool truncate()
Removes all features from the layer.
virtual Q_INVOKABLE Qgis::VectorProviderCapabilities capabilities() const
Returns flags containing the supported capabilities.
virtual void handlePostCloneOperations(QgsVectorDataProvider *source)
Handles any post-clone operations required after this vector data provider was cloned from the source...
virtual QgsAbstractFeatureSource * featureSource() const =0
Returns feature source object that can be used for querying provider's data.
virtual bool changeAttributeValues(const QgsChangedAttributesMap &attr_map)
Changes attribute values of existing features.
virtual bool deleteFeatures(const QgsFeatureIds &id)
Deletes one or more features from the provider.
bool addFeatures(QgsFeatureList &flist, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a list of features to the sink.
QgsFields fields() const override=0
Returns the fields associated with this data provider.
Qgis::WkbType wkbType() const override=0
Returns the geometry type which is returned by this layer.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const override=0
Query the provider for features specified in request.
virtual bool addAttributes(const QList< QgsField > &attributes)
Adds new attributes to the provider.
virtual bool renameAttributes(const QgsFieldNameMap &renamedAttributes)
Renames existing attributes.
virtual bool deleteAttributes(const QgsAttributeIds &attributes)
Deletes existing attributes from the provider.
QMap< int, QString > QgsFieldNameMap
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
QList< QgsFeature > QgsFeatureList
QSet< QgsFeatureId > QgsFeatureIds
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
QSet< int > QgsAttributeIds
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
Setting options for creating vector data providers.