QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
A convenience class for exporting vector layers to a destination data provider. More...
#include <qgsvectorlayerexporter.h>
Public Member Functions | |
QgsVectorLayerExporter (const QgsVectorLayerExporter &rh)=delete | |
QgsVectorLayerExporter (const QString &uri, const QString &provider, const QgsFields &fields, Qgis::WkbType geometryType, const QgsCoordinateReferenceSystem &crs, bool overwrite=false, const QMap< QString, QVariant > &options=QMap< QString, QVariant >(), QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags()) | |
Constructor for QgsVectorLayerExporter. | |
~QgsVectorLayerExporter () override | |
Finalizes the export and closes the new created layer. | |
bool | addFeature (QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override |
Adds a single feature to the sink. | |
bool | addFeatures (QgsFeatureList &features, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override |
Adds a list of features to the sink. | |
Qgis::VectorDataProviderAttributeEditCapabilities | attributeEditCapabilities () const |
Returns the attribute capabilities of the exporter. | |
Qgis::VectorExportResult | errorCode () const |
Returns any encountered error code, or false if no error was encountered. | |
int | errorCount () const |
Returns the number of error messages encountered during the export. | |
QString | errorMessage () const |
Returns any error message encountered during the export. | |
bool | flushBuffer () override |
Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to the sink's destination. | |
QString | lastError () const override |
Returns the most recent error encountered by the sink, e.g. | |
QgsVectorLayerExporter & | operator= (const QgsVectorLayerExporter &rh)=delete |
Public Member Functions inherited from QgsFeatureSink | |
virtual | ~QgsFeatureSink ()=default |
virtual bool | addFeatures (QgsFeatureIterator &iterator, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) |
Adds all features from the specified iterator to the sink. | |
virtual void | finalize () |
Finalizes the sink, flushing any buffered features to the destination. | |
Static Public Member Functions | |
static Qgis::VectorExportResult | exportLayer (QgsVectorLayer *layer, const QString &uri, const QString &providerKey, const QgsCoordinateReferenceSystem &destCRS, bool onlySelected=false, QString *errorMessage=nullptr, const QMap< QString, QVariant > &options=QMap< QString, QVariant >(), QgsFeedback *feedback=nullptr) |
Writes the contents of vector layer to a different datasource. | |
Additional Inherited Members | |
Public Types inherited from QgsFeatureSink | |
enum | Flag { FastInsert = 1 << 1 , RollBackOnErrors = 1 << 2 } |
Flags controlling how features are added to a sink. More... | |
typedef QFlags< Flag > | Flags |
enum | SinkFlag { RegeneratePrimaryKey = 1 << 1 } |
Flags that can be set on a QgsFeatureSink. More... | |
typedef QFlags< SinkFlag > | SinkFlags |
A convenience class for exporting vector layers to a destination data provider.
QgsVectorLayerExporter can be used in two ways:
Definition at line 48 of file qgsvectorlayerexporter.h.
QgsVectorLayerExporter::QgsVectorLayerExporter | ( | const QString & | uri, |
const QString & | provider, | ||
const QgsFields & | fields, | ||
Qgis::WkbType | geometryType, | ||
const QgsCoordinateReferenceSystem & | crs, | ||
bool | overwrite = false , |
||
const QMap< QString, QVariant > & | options = QMap<QString, QVariant>() , |
||
QgsFeatureSink::SinkFlags | sinkFlags = QgsFeatureSink::SinkFlags() |
||
) |
Constructor for QgsVectorLayerExporter.
uri | URI for destination data source |
provider | string key for destination data provider |
fields | fields to include in created layer |
geometryType | destination geometry type |
crs | desired CRS, or an invalid (default constructed) CRS if not available |
overwrite | set to true to overwrite any existing data source |
options | optional provider dataset options |
sinkFlags | for how to add features |
Definition at line 50 of file qgsvectorlayerexporter.cpp.
|
delete |
|
override |
Finalizes the export and closes the new created layer.
Definition at line 182 of file qgsvectorlayerexporter.cpp.
|
overridevirtual |
Adds a single feature to the sink.
Feature addition behavior is controlled by the specified flags.
true
in case of success and false
in case of failure Reimplemented from QgsFeatureSink.
Definition at line 220 of file qgsvectorlayerexporter.cpp.
|
overridevirtual |
Adds a list of features to the sink.
Feature addition behavior is controlled by the specified flags.
true
in case of success and false
in case of failure Implements QgsFeatureSink.
Definition at line 209 of file qgsvectorlayerexporter.cpp.
Qgis::VectorDataProviderAttributeEditCapabilities QgsVectorLayerExporter::attributeEditCapabilities | ( | ) | const |
Returns the attribute capabilities of the exporter.
Definition at line 204 of file qgsvectorlayerexporter.cpp.
Qgis::VectorExportResult QgsVectorLayerExporter::errorCode | ( | ) | const |
Returns any encountered error code, or false
if no error was encountered.
Definition at line 194 of file qgsvectorlayerexporter.cpp.
|
inline |
Returns the number of error messages encountered during the export.
Definition at line 118 of file qgsvectorlayerexporter.h.
QString QgsVectorLayerExporter::errorMessage | ( | ) | const |
Returns any error message encountered during the export.
Definition at line 199 of file qgsvectorlayerexporter.cpp.
|
static |
Writes the contents of vector layer to a different datasource.
layer | source layer |
uri | URI for destination data source |
providerKey | string key for destination data provider |
destCRS | destination CRS, or an invalid (default constructed) CRS if not available |
onlySelected | set to true to export only selected features |
errorMessage | if non-null, will be set to any error messages |
options | optional provider dataset options |
feedback | optional feedback object to show progress and cancellation of export |
Definition at line 299 of file qgsvectorlayerexporter.cpp.
|
overridevirtual |
Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to the sink's destination.
false
if any buffered features could not be added to the sink. Reimplemented from QgsFeatureSink.
Definition at line 258 of file qgsvectorlayerexporter.cpp.
|
overridevirtual |
Returns the most recent error encountered by the sink, e.g.
when a call to addFeatures() returns false
.
Reimplemented from QgsFeatureSink.
Definition at line 253 of file qgsvectorlayerexporter.cpp.
|
delete |