QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
15 #ifndef QGSVECTORDATAPROVIDER_H
16 #define QGSVECTORDATAPROVIDER_H
20 #include "qgis_core.h"
76 DeleteFeatures = 1 << 1,
77 ChangeAttributeValues = 1 << 2,
78 AddAttributes = 1 << 3,
79 DeleteAttributes = 1 << 4,
80 CreateSpatialIndex = 1 << 6,
82 ChangeGeometries = 1 << 8,
83 SelectEncoding = 1 << 13,
84 CreateAttributeIndex = 1 << 12,
85 SimplifyGeometries = 1 << 14,
86 SimplifyGeometriesWithTopologicalValidation = 1 << 15,
87 TransactionSupport = 1 << 16,
88 CircularGeometries = 1 << 17,
89 ChangeFeatures = 1 << 18,
90 RenameAttributes = 1 << 19,
91 FastTruncate = 1 << 20,
92 ReadLayerMetadata = 1 << 21,
93 WriteLayerMetadata = 1 << 22,
94 CancelSupport = 1 << 23,
95 CreateRenderer = 1 << 24,
96 CreateLabeling = 1 << 25,
99 Q_DECLARE_FLAGS( Capabilities, Capability )
102 static const
int EditingCapabilities = AddFeatures | DeleteFeatures |
103 ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes |
126 QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
149 virtual QString storageType()
const;
174 virtual bool empty()
const;
232 virtual QStringList uniqueStringsMatching(
int index,
const QString &substring,
int limit = -1,
260 virtual void enumValues(
int index, QStringList &enumList
SIP_OUT )
const { Q_UNUSED( index ) enumList.clear(); }
280 virtual bool truncate();
288 virtual bool cancelReload();
295 virtual bool addAttributes(
const QList<QgsField> &attributes );
314 virtual bool renameAttributes(
const QgsFieldNameMap &renamedAttributes );
351 virtual QVariant defaultValue(
int fieldIndex )
const;
360 virtual QString defaultValueClause(
int fieldIndex )
const;
368 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
386 virtual bool changeGeometryValues(
const QgsGeometryMap &geometry_map );
392 virtual bool createSpatialIndex();
395 virtual bool createAttributeIndex(
int field );
403 virtual QgsVectorDataProvider::Capabilities capabilities()
const;
408 QString capabilitiesString()
const;
422 virtual void setEncoding(
const QString &e );
429 QString encoding()
const;
434 int fieldNameIndex(
const QString &fieldName )
const;
439 QMap<QString, int> fieldNameMap()
const;
463 NativeType(
const QString &typeDesc,
const QString &
typeName, QVariant::Type type,
int minLen = 0,
int maxLen = 0,
int minPrec = 0,
int maxPrec = 0, QVariant::Type subType = QVariant::Invalid )
464 : mTypeDesc( typeDesc )
469 , mMinPrec( minPrec )
470 , mMaxPrec( maxPrec )
471 , mSubType( subType )
487 QList< QgsVectorDataProvider::NativeType > nativeTypes()
const;
496 static QStringList availableEncodings();
501 bool hasErrors()
const;
511 QStringList errors()
const;
517 virtual bool isSaveAndLoadStyleToDatabaseSupported()
const;
523 virtual bool isDeleteStyleFromDatabaseSupported()
const;
559 static QVariant convertValue( QVariant::Type type, const QString &value );
574 virtual QSet<QgsMapLayerDependency> dependencies()
const;
583 virtual QList<QgsRelation> discoverRelations(
const QgsVectorLayer *
self,
const QList<QgsVectorLayer *> &layers )
const;
589 virtual QVariantMap
metadata()
const {
return QVariantMap(); }
604 virtual QString
translateMetadataValue(
const QString &mdKey,
const QVariant &value )
const { Q_UNUSED( mdKey )
return value.toString(); }
633 void raiseError( const QString &msg ) const;
641 void clearMinMaxCache();
646 void fillMinMaxCache() const;
657 void pushError( const QString &msg ) const;
678 QTextCodec *textEncoding() const;
681 mutable
bool mCacheMinMaxDirty = true;
682 mutable QMap<
int, QVariant> mCacheMinValues, mCacheMaxValues;
685 QTextCodec *mEncoding =
nullptr;
694 mutable QStringList mErrors;
698 static QStringList sEncodings;
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QSet< int > QgsAttributeIds
virtual QVariant minimumValue(int fieldIndex) const
Returns the minimum value for an attribute column or an invalid variant in case of error.
virtual QgsCoordinateReferenceSystem sourceCrs() const =0
Returns the coordinate reference system for features in the source.
Setting options for creating vector data providers.
Abstract base class for spatial data provider implementations.
FeatureCountState
Enumeration of feature count states.
virtual QVariantMap metadata() const
Gets metadata, dependent on the provider type, that will be display in the metadata tab of the layer ...
A bundle of parameters controlling aggregate calculation.
QgsFields fields() const override=0
Returns the fields associated with this data provider.
virtual void enumValues(int index, QStringList &enumList) const
Returns the possible enum values of an attribute.
Container of fields for a vector layer.
An interface for objects which provide features via a getFeatures method.
Type
The WKB type describes the number of dimensions a geometry has.
virtual bool doesStrictFeatureTypeCheck() const
Returns true if the provider is strict about the type of inserted features (e.g.
This class allows including a set of layers in a database-side transaction, provided the layer data p...
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
Constraint
Constraints which may be present on a field.
virtual bool hasMetadata() const
Returns true if the data source has metadata, false otherwise.
QList< int > QgsAttributeList
A rectangle specified with double values.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
virtual FeatureAvailability hasFeatures() const
Determines if there are any features available in the source.
Capability
enumeration with capabilities that providers might implement
This class wraps a request for features to a vector layer (or directly its vector data provider).
virtual QString translateMetadataValue(const QString &mdKey, const QVariant &value) const
Gets the translated metadata value.
virtual QVariant maximumValue(int fieldIndex) const
Returns the maximum value for an attribute column or an invalid variant in case of error.
virtual void reloadData()
Reloads the data from the source by calling reloadProviderData() implemented by providers with data c...
long featureCount() const override=0
Number of features in the layer.
virtual QgsAbstractFeatureSource * featureSource() const =0
Returns feature source object that can be used for querying provider's data.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Base class that can be used for any class that is capable of returning features.
NativeType(const QString &typeDesc, const QString &typeName, QVariant::Type type, int minLen=0, int maxLen=0, int minPrec=0, int maxPrec=0, QVariant::Type subType=QVariant::Invalid)
QString sourceName() const override
Returns a friendly display name for the source.
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
QList< QgsFeature > QgsFeatureList
virtual QgsRectangle sourceExtent() const
Returns the extent of all geometries from the source.
virtual QString translateMetadataKey(const QString &mdKey) const
Gets the translated metadata key.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const override=0
Query the provider for features specified in request.
QSet< QgsFeatureId > QgsFeatureIds
This class represents a coordinate reference system (CRS).
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
FeatureAvailability
Possible return value for hasFeatures() to determine if a source is empty.
Aggregate
Available aggregates to calculate.
virtual QgsDataProviderTemporalCapabilities * temporalCapabilities()
Returns the provider's temporal capabilities.
virtual QString lastError() const
Returns the most recent error encountered by the sink, e.g.
A geometry is the spatial representation of a feature.
Implementation of data provider temporal properties for QgsVectorDataProviders.
Represents a vector layer which manages a vector based data sets.
QMap< int, QString > QgsFieldNameMap
QHash< int, QString > QgsAttrPalIndexNameHash
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
This is the base class for vector data providers.
virtual bool deleteFeatures(const QgsFeatureIds &fid)
Deletes a set of features from the layer (but does not commit it)
virtual QString dataComment() const
Returns a short comment for the data that this provider is providing access to (e....
Wrapper for iterator of features from vector data provider or vector layer.
virtual bool changeAttributeValues(QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues)
Changes values of attributes (but does not commit it).
const QgsAttributeList & attributeIndexes
An interface for objects which accept features via addFeature(s) methods.
virtual bool addFeatures(QgsFeatureList &features)
Insert a copy of the given features into the layer (but does not commit it)
QgsWkbTypes::Type wkbType() const override=0
Returns the geometry type which is returned by this layer.
Encapsulate a field in an attribute table or data source.