QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
18 #ifndef QGSVECTORLAYEREXPORTER_H
19 #define QGSVECTORLAYEREXPORTER_H
21 #include "qgis_core.h"
29 class QProgressDialog;
82 const QString &providerKey,
84 bool onlySelected =
false,
85 QString *errorMessage
SIP_OUT =
nullptr,
86 const QMap<QString, QVariant> &options = QMap<QString, QVariant>(),
103 const QString &provider,
107 bool overwrite =
false,
108 const QMap<QString, QVariant> &options = QMap<QString, QVariant>(),
109 QgsFeatureSink::SinkFlags sinkFlags = QgsFeatureSink::SinkFlags() );
128 QString errorMessage()
const;
138 bool addFeature(
QgsFeature &feature, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() )
override;
151 bool createSpatialIndex();
155 QString mErrorMessage;
162 QMap<int, int> mOldToNewAttrIdx;
166 int mFeatureBufferMemoryUsage = 0;
168 bool mCreateSpatialIndex =
true;
201 const QString &providerKey,
203 const QMap<QString, QVariant> &options = QMap<QString, QVariant>(),
204 bool ownsLayer =
false );
214 const QString &providerKey,
216 const QMap<QString, QVariant> &options = QMap<QString, QVariant>() )
SIP_FACTORY;
236 void finished(
bool result )
override;
240 QPointer< QgsVectorLayer > mLayer =
nullptr;
241 bool mOwnsLayer =
false;
244 QString mDestProviderKey;
246 QMap<QString, QVariant> mOptions;
248 std::unique_ptr< QgsFeedback > mOwnedFeedback;
251 QString mErrorMessage;
255 #endif // QGSVECTORLAYEREXPORTER_H
@ ErrProviderUnsupportedFeature
Provider does not support creation of empty layers.
void errorOccurred(int error, const QString &errorMessage)
Emitted when an error occurs which prevented the layer being exported (or if the task is canceled).
const QgsCoordinateReferenceSystem & crs
virtual bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags())
Adds a single feature to the sink.
Container of fields for a vector layer.
int errorCount() const
Returns the number of error messages encountered during the export.
@ ErrFeatureWriteFailed
An error occurred while writing a feature to the destination.
void exportComplete()
Emitted when exporting the layer is successfully completed.
Type
The WKB type describes the number of dimensions a geometry has.
@ NoError
No errors were encountered.
virtual void finished(bool result)
If the task is managed by a QgsTaskManager, this will be called after the task has finished (whether ...
virtual void cancel()
Notifies the task that it should terminate.
@ ErrCreateDataSource
Could not create the destination data source.
QgsTask task which performs a QgsVectorLayerExporter layer export operation as a background task.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
QgsVectorLayerExporter(const QgsVectorLayerExporter &rh)=delete
QgsVectorLayerExporter cannot be copied.
QList< QgsFeature > QgsFeatureList
@ ErrInvalidLayer
Could not access newly created destination layer.
@ ErrUserCanceled
User canceled the export.
@ ErrCreateLayer
Could not create destination layer.
@ ErrInvalidProvider
Could not find a matching provider key.
This class represents a coordinate reference system (CRS).
@ ErrAttributeTypeUnsupported
Source layer has an attribute type which could not be handled by destination.
virtual QString lastError() const
Returns the most recent error encountered by the sink, e.g.
Represents a vector layer which manages a vector based data sets.
@ ErrConnectionFailed
Could not connect to destination.
virtual bool flushBuffer()
Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to...
A convenience class for exporting vector layers to a destination data provider.
virtual bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags())=0
Adds a list of features to the sink.
This is the base class for vector data providers.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
@ ErrProjection
An error occurred while reprojecting features to destination CRS.
QgsVectorLayerExporter & operator=(const QgsVectorLayerExporter &rh)=delete
QgsVectorLayerExporter cannot be copied.
virtual bool run()=0
Performs the task's operation.
An interface for objects which accept features via addFeature(s) methods.
@ ErrAttributeCreationFailed
Destination provider was unable to create an attribute.
Abstract base class for long running background tasks.