QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsvectorfilewriter.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorfilewriter.h
3  generic vector file writer
4  -------------------
5  begin : Jun 6 2004
6  copyright : (C) 2004 by Tim Sutton
7  email : tim at linfiniti.com
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef QGSVECTORFILEWRITER_H
20 #define QGSVECTORFILEWRITER_H
21 
22 #include "qgis_core.h"
23 #include "qgis_sip.h"
24 #include "qgsfields.h"
25 #include "qgsfeedback.h"
26 #include "qgssymbol.h"
27 #include "qgstaskmanager.h"
28 #include "qgsogrutils.h"
29 #include "qgsrenderer.h"
30 #include "qgsgeometryengine.h"
31 #include "qgsfeaturesink.h"
32 #include <ogr_api.h>
33 
34 class QgsSymbolLayer;
35 class QTextCodec;
36 class QgsFeatureIterator;
37 
45 class CORE_EXPORT QgsVectorFileWriter : public QgsFeatureSink
46 {
47  public:
49  {
50  Set,
52  Int,
53  Hidden
54  };
55 
59  class Option
60  {
61  public:
62  Option( const QString &docString, QgsVectorFileWriter::OptionType type )
63  : docString( docString )
64  , type( type ) {}
65  virtual ~Option() = default;
66 
67  QString docString;
69  };
70 
75  {
76  public:
77  SetOption( const QString &docString, const QStringList &values, const QString &defaultValue, bool allowNone = false )
78  : Option( docString, Set )
79  , values( qgis::listToSet( values ) )
80  , defaultValue( defaultValue )
81  , allowNone( allowNone )
82  {}
83 
84  QSet<QString> values;
85  QString defaultValue;
86  bool allowNone;
87  };
88 
93  {
94  public:
95  StringOption( const QString &docString, const QString &defaultValue = QString() )
96  : Option( docString, String )
97  , defaultValue( defaultValue )
98  {}
99 
100  QString defaultValue;
101  };
102 
107  {
108  public:
109  IntOption( const QString &docString, int defaultValue )
110  : Option( docString, Int )
111  , defaultValue( defaultValue )
112  {}
113 
115  };
116 
121  {
122  public:
123  BoolOption( const QString &docString, bool defaultValue )
124  : SetOption( docString, QStringList() << QStringLiteral( "YES" ) << QStringLiteral( "NO" ), defaultValue ? "YES" : "NO" )
125  {}
126  };
127 
132  {
133  public:
134  explicit HiddenOption( const QString &value )
135  : Option( QString(), Hidden )
136  , mValue( value )
137  {}
138 
139  QString mValue;
140  };
141 
142  struct MetaData
143  {
145  MetaData() = default;
146 
147  MetaData( const QString &longName, const QString &trLongName, const QString &glob, const QString &ext, const QMap<QString, QgsVectorFileWriter::Option *> &driverOptions, const QMap<QString, QgsVectorFileWriter::Option *> &layerOptions, const QString &compulsoryEncoding = QString() )
148  : longName( longName )
149  , trLongName( trLongName )
150  , glob( glob )
151  , ext( ext )
152  , driverOptions( driverOptions )
153  , layerOptions( layerOptions )
154  , compulsoryEncoding( compulsoryEncoding )
155  {}
156 
157  QString longName;
158  QString trLongName;
159  QString glob;
160  QString ext;
161  QMap<QString, QgsVectorFileWriter::Option *> driverOptions;
162  QMap<QString, QgsVectorFileWriter::Option *> layerOptions;
165  };
166 
168  {
169  NoError = 0,
179  };
180 
182  {
183  NoSymbology = 0, //export only data
184  FeatureSymbology, //Keeps the number of features and export symbology per feature
185  SymbolLayerSymbology //Exports one feature per symbol layer (considering symbol levels)
186  };
187 
188 
194  {
195  SortRecommended = 1 << 1,
196  SkipNonSpatialFormats = 1 << 2,
197  };
198  Q_DECLARE_FLAGS( VectorFormatOptions, VectorFormatOption )
199 
200 
205  class CORE_EXPORT FieldValueConverter
206  {
207  public:
209  FieldValueConverter() = default;
210 
211  virtual ~FieldValueConverter() = default;
212 
218  virtual QgsField fieldDefinition( const QgsField &field );
219 
226  virtual QVariant convert( int fieldIdxInLayer, const QVariant &value );
227 
232  };
233 
239  {
241  CanAddNewLayer = 1 << 0,
242 
244  CanAppendToExistingLayer = 1 << 1,
245 
247  CanAddNewFieldsToExistingLayer = 1 << 2,
248 
250  CanDeleteLayer = 1 << 3
251  };
252 
257  Q_DECLARE_FLAGS( EditionCapabilities, EditionCapability )
258 
259 
264  {
267 
270 
273 
275  AppendToLayerAddFields
276  };
277 
278 #ifndef SIP_RUN
279 
305 #else
306 
331 #endif
332  Q_DECL_DEPRECATED static QgsVectorFileWriter::WriterError writeAsVectorFormat( QgsVectorLayer *layer,
333  const QString &fileName,
334  const QString &fileEncoding,
336  const QString &driverName = "GPKG",
337  bool onlySelected = false,
338  QString *errorMessage SIP_OUT = nullptr,
339  const QStringList &datasourceOptions = QStringList(),
340  const QStringList &layerOptions = QStringList(),
341  bool skipAttributeCreation = false,
342  QString *newFilename = nullptr,
344  double symbologyScale = 1.0,
345  const QgsRectangle *filterExtent = nullptr,
346  QgsWkbTypes::Type overrideGeometryType = QgsWkbTypes::Unknown,
347  bool forceMulti = false,
348  bool includeZ = false,
349  const QgsAttributeList &attributes = QgsAttributeList(),
350  QgsVectorFileWriter::FieldValueConverter *fieldValueConverter = nullptr
351 #ifndef SIP_RUN
352  , QString *newLayer = nullptr );
353 #else
354  ) SIP_DEPRECATED;
355 #endif
356 
357 #ifndef SIP_RUN
358 
386 #else
387 
414 #endif
415  Q_DECL_DEPRECATED static QgsVectorFileWriter::WriterError writeAsVectorFormat( QgsVectorLayer *layer,
416  const QString &fileName,
417  const QString &fileEncoding,
418  const QgsCoordinateTransform &ct,
419  const QString &driverName = "GPKG",
420  bool onlySelected = false,
421  QString *errorMessage SIP_OUT = nullptr,
422  const QStringList &datasourceOptions = QStringList(),
423  const QStringList &layerOptions = QStringList(),
424  bool skipAttributeCreation = false,
425  QString *newFilename = nullptr,
427  double symbologyScale = 1.0,
428  const QgsRectangle *filterExtent = nullptr,
429  QgsWkbTypes::Type overrideGeometryType = QgsWkbTypes::Unknown,
430  bool forceMulti = false,
431  bool includeZ = false,
432  const QgsAttributeList &attributes = QgsAttributeList(),
433  QgsVectorFileWriter::FieldValueConverter *fieldValueConverter = nullptr
434 #ifndef SIP_RUN
435  , QString *newLayer = nullptr );
436 #else
437  ) SIP_DEPRECATED;
438 #endif
439 
445  class CORE_EXPORT SaveVectorOptions
446  {
447  public:
450 
451  virtual ~SaveVectorOptions() = default;
452 
454  QString driverName;
455 
457  QString layerName;
458 
460  QgsVectorFileWriter::ActionOnExistingFile actionOnExistingFile = CreateOrOverwriteFile;
461 
463  QString fileEncoding;
464 
470 
472  bool onlySelectedFeatures = false;
473 
475  QStringList datasourceOptions;
476 
478  QStringList layerOptions;
479 
481  bool skipAttributeCreation = false;
482 
485 
487  QgsVectorFileWriter::SymbologyExport symbologyExport = NoSymbology;
488 
490  double symbologyScale = 1.0;
491 
494 
499  QgsWkbTypes::Type overrideGeometryType = QgsWkbTypes::Unknown;
500 
502  bool forceMulti = false;
503 
505  bool includeZ = false;
506 
513  QgsVectorFileWriter::FieldValueConverter *fieldValueConverter = nullptr;
514 
516  QgsFeedback *feedback = nullptr;
517  };
518 
519 #ifndef SIP_RUN
520 
532 #else
533 
544 #endif
545  Q_DECL_DEPRECATED static QgsVectorFileWriter::WriterError writeAsVectorFormat( QgsVectorLayer *layer,
546  const QString &fileName,
548  QString *newFilename = nullptr,
549  QString *errorMessage SIP_OUT = nullptr
550 #ifndef SIP_RUN
551  , QString *newLayer = nullptr );
552 #else
553  ) SIP_DEPRECATED;
554 #endif
555 
560  Q_DECL_DEPRECATED QgsVectorFileWriter( const QString &vectorFileName,
561  const QString &fileEncoding,
562  const QgsFields &fields,
563  QgsWkbTypes::Type geometryType,
565  const QString &driverName = "GPKG",
566  const QStringList &datasourceOptions = QStringList(),
567  const QStringList &layerOptions = QStringList(),
568  QString *newFilename = nullptr,
570  QgsFeatureSink::SinkFlags sinkFlags = QgsFeatureSink::SinkFlags()
571 #ifndef SIP_RUN
572  , QString *newLayer = nullptr,
574 #endif
575  ) SIP_DEPRECATED;
576 
598  Q_DECL_DEPRECATED QgsVectorFileWriter( const QString &vectorFileName,
599  const QString &fileEncoding,
600  const QgsFields &fields,
601  QgsWkbTypes::Type geometryType,
602  const QgsCoordinateReferenceSystem &srs,
603  const QString &driverName,
604  const QStringList &datasourceOptions,
605  const QStringList &layerOptions,
606  QString *newFilename,
607  QgsVectorFileWriter::SymbologyExport symbologyExport,
608  QgsVectorFileWriter::FieldValueConverter *fieldValueConverter,
609  const QString &layerName,
611  QString *newLayer = nullptr,
613  QgsFeatureSink::SinkFlags sinkFlags = QgsFeatureSink::SinkFlags()
614  ) SIP_SKIP;
615 
619  QgsVectorFileWriter &operator=( const QgsVectorFileWriter &rh ) = delete;
620 
634  static QgsVectorFileWriter *create( const QString &fileName,
635  const QgsFields &fields,
636  QgsWkbTypes::Type geometryType,
637  const QgsCoordinateReferenceSystem &srs,
638  const QgsCoordinateTransformContext &transformContext,
639  const QgsVectorFileWriter::SaveVectorOptions &options,
640  QgsFeatureSink::SinkFlags sinkFlags = QgsFeatureSink::SinkFlags(),
641  QString *newFilename = nullptr,
642  QString *newLayer = nullptr ) SIP_FACTORY;
643 
656  static QgsVectorFileWriter::WriterError writeAsVectorFormatV2( QgsVectorLayer *layer,
657  const QString &fileName,
658  const QgsCoordinateTransformContext &transformContext,
659  const QgsVectorFileWriter::SaveVectorOptions &options,
660  QString *newFilename = nullptr,
661  QString *newLayer = nullptr,
662  QString *errorMessage SIP_OUT = nullptr );
663 
669  {
671  QString driverName;
672 
674  QString filterString;
675 
680  QStringList globs;
681  };
682 
691  static QList< QgsVectorFileWriter::FilterFormatDetails > supportedFiltersAndFormats( VectorFormatOptions options = SortRecommended );
692 
702  static QStringList supportedFormatExtensions( VectorFormatOptions options = SortRecommended );
703 
711  static bool supportsFeatureStyles( const QString &driverName );
712 
718  {
720  QString longName;
721 
723  QString driverName;
724  };
725 
737  static QList< QgsVectorFileWriter::DriverDetails > ogrDriverList( VectorFormatOptions options = SortRecommended );
738 
745  static QString driverForExtension( const QString &extension );
746 
753  static QString fileFilterString( VectorFormatOptions options = SortRecommended );
754 
756  static QString filterForDriver( const QString &driverName );
757 
759  static QString convertCodecNameForEncodingOption( const QString &codecName );
760 
763 
765  QString errorMessage();
766 
767  bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override;
768  bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override;
769  QString lastError() const override;
770 
775  bool addFeatureWithStyle( QgsFeature &feature, QgsFeatureRenderer *renderer, QgsUnitTypes::DistanceUnit outputUnit = QgsUnitTypes::DistanceMeters );
776 
778  QMap<int, int> attrIdxToOgrIdx() { return mAttrIdxToOgrIdx; } SIP_SKIP
779 
781  ~QgsVectorFileWriter() override;
782 
788  static bool deleteShapeFile( const QString &fileName );
789 
790  QgsVectorFileWriter::SymbologyExport symbologyExport() const { return mSymbologyExport; }
791  void setSymbologyExport( QgsVectorFileWriter::SymbologyExport symExport ) { mSymbologyExport = symExport; }
792 
799  double symbologyScale() const { return mSymbologyScale; }
800 
807  void setSymbologyScale( double scale );
808 
809  static bool driverMetadata( const QString &driverName, MetaData &driverMetadata );
810 
817  static QStringList defaultDatasetOptions( const QString &driverName );
818 
825  static QStringList defaultLayerOptions( const QString &driverName );
826 
833  static OGRwkbGeometryType ogrTypeFromWkbType( QgsWkbTypes::Type type ) SIP_SKIP;
834 
839  static QgsVectorFileWriter::EditionCapabilities editionCapabilities( const QString &datasetName );
840 
845  static bool targetLayerExists( const QString &datasetName,
846  const QString &layerName );
847 
852  static bool areThereNewFieldsToCreate( const QString &datasetName,
853  const QString &layerName,
854  QgsVectorLayer *layer,
855  const QgsAttributeList &attributes );
856 
857  protected:
859  OGRGeometryH createEmptyGeometry( QgsWkbTypes::Type wkbType ) SIP_SKIP;
860 
862  OGRLayerH mLayer = nullptr;
863  OGRSpatialReferenceH mOgrRef = nullptr;
864 
866 
869  QString mErrorMessage;
870 
871  QTextCodec *mCodec = nullptr;
872 
875 
877  QMap<int, int> mAttrIdxToOgrIdx;
878 
880 
881  QMap< QgsSymbolLayer *, QString > mSymbolLayerTable;
882 
885 
886  QString mOgrDriverName;
887 
889  FieldValueConverter *mFieldValueConverter = nullptr;
890 
891  private:
892 #ifdef SIP_RUN
894 #endif
895 
896  struct PreparedWriterDetails
897  {
898  std::unique_ptr< QgsFeatureRenderer > renderer;
900  QgsWkbTypes::Type sourceWkbType = QgsWkbTypes::Unknown;
901  QgsFields sourceFields;
902  QString providerType;
903  long featureCount = 0;
904  QgsFeatureIds selectedFeatureIds;
905  QString dataSourceUri;
906  QString storageType;
907  QgsFeatureIterator geometryTypeScanIterator;
908  QgsExpressionContext expressionContext;
909  QSet< int > fieldsToConvertToInt;
910  QgsRenderContext renderContext;
911  bool shallTransform = false;
914  QgsAttributeList attributes;
915  QgsFields outputFields;
916  QgsFeatureIterator sourceFeatureIterator;
917  QgsGeometry filterRectGeometry;
918  std::unique_ptr< QgsGeometryEngine > filterRectEngine;
919  QVariantMap providerUriParams;
920  };
921 
926  static QgsVectorFileWriter::WriterError prepareWriteAsVectorFormat( QgsVectorLayer *layer,
928  PreparedWriterDetails &details );
929 
943  static QgsVectorFileWriter::WriterError writeAsVectorFormatV2( PreparedWriterDetails &details,
944  const QString &fileName,
945  const QgsCoordinateTransformContext &transformContext,
947  QString *newFilename = nullptr,
948  QString *newLayer = nullptr,
949  QString *errorMessage SIP_OUT = nullptr );
950 
956  Q_DECL_DEPRECATED static QgsVectorFileWriter::WriterError writeAsVectorFormat( PreparedWriterDetails &details,
957  const QString &fileName,
959  QString *newFilename = nullptr,
960  QString *errorMessage SIP_OUT = nullptr,
961  QString *newLayer = nullptr ) SIP_DEPRECATED;
962 
963  void init( QString vectorFileName, QString fileEncoding, const QgsFields &fields,
964  QgsWkbTypes::Type geometryType, QgsCoordinateReferenceSystem srs,
965  const QString &driverName, QStringList datasourceOptions,
966  QStringList layerOptions, QString *newFilename,
967  QgsVectorFileWriter::FieldValueConverter *fieldValueConverter,
968  const QString &layerName,
969  QgsVectorFileWriter::ActionOnExistingFile action, QString *newLayer, QgsFeatureSink::SinkFlags sinkFlags,
970  const QgsCoordinateTransformContext &transformContext );
971  void resetMap( const QgsAttributeList &attributes );
972 
973  std::unique_ptr< QgsFeatureRenderer > mRenderer;
974  QgsRenderContext mRenderContext;
975 
976 
977  std::unique_ptr< QgsCoordinateTransform > mCoordinateTransform;
978 
979  bool mUsingTransaction = false;
980  bool supportsStringList = false;
981 
982  void createSymbolLayerTable( QgsVectorLayer *vl, const QgsCoordinateTransform &ct, OGRDataSourceH ds );
983  gdal::ogr_feature_unique_ptr createFeature( const QgsFeature &feature );
984  bool writeFeature( OGRLayerH layer, OGRFeatureH feature );
985 
987  QgsVectorFileWriter::WriterError exportFeaturesSymbolLevels( const PreparedWriterDetails &details, QgsFeatureIterator &fit, const QgsCoordinateTransform &ct, QString *errorMessage = nullptr );
988  double mmScaleFactor( double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits );
989  double mapUnitScaleFactor( double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits );
990 
991  void startRender( QgsFeatureRenderer *sourceRenderer, const QgsFields &fields );
992  void stopRender();
993  std::unique_ptr< QgsFeatureRenderer > createSymbologyRenderer( QgsFeatureRenderer *sourceRenderer ) const;
995  static void addRendererAttributes( QgsFeatureRenderer *renderer, QgsRenderContext &context, const QgsFields &fields, QgsAttributeList &attList );
996 
998  static QStringList concatenateOptions( const QMap<QString, Option *> &options );
999 
1001  friend class TestQgsVectorFileWriter;
1002 };
1003 
1004 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsVectorFileWriter::EditionCapabilities )
1005 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsVectorFileWriter::VectorFormatOptions )
1006 
1007 // clazy:excludeall=qstring-allocations
1008 
1009 #endif
QgsVectorFileWriter::IntOption
Definition: qgsvectorfilewriter.h:107
QgsVectorFileWriter::DriverDetails
Details of available driver formats.
Definition: qgsvectorfilewriter.h:718
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:370
QgsVectorFileWriter::MetaData
Definition: qgsvectorfilewriter.h:143
QgsVectorFileWriter::OptionType
OptionType
Definition: qgsvectorfilewriter.h:49
qgsfields.h
QgsVectorFileWriter::MetaData::driverOptions
QMap< QString, QgsVectorFileWriter::Option * > driverOptions
Definition: qgsvectorfilewriter.h:161
QgsVectorFileWriter::IntOption::defaultValue
int defaultValue
Definition: qgsvectorfilewriter.h:114
gdal::ogr_feature_unique_ptr
std::unique_ptr< std::remove_pointer< OGRFeatureH >::type, OGRFeatureDeleter > ogr_feature_unique_ptr
Scoped OGR feature.
Definition: qgsogrutils.h:129
QgsVectorFileWriter::attrIdxToOgrIdx
QMap< int, int > attrIdxToOgrIdx()
Definition: qgsvectorfilewriter.h:778
QgsVectorFileWriter::Set
@ Set
Definition: qgsvectorfilewriter.h:50
outputCrs
const QgsCoordinateReferenceSystem & outputCrs
Definition: qgswfsgetfeature.cpp:61
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:58
QgsVectorFileWriter::DriverDetails::driverName
QString driverName
Unique driver name.
Definition: qgsvectorfilewriter.h:723
QgsVectorFileWriter::SaveVectorOptions
Options to pass to writeAsVectorFormat()
Definition: qgsvectorfilewriter.h:446
QgsVectorFileWriter::ErrFeatureWriteFailed
@ ErrFeatureWriteFailed
Definition: qgsvectorfilewriter.h:176
QgsVectorFileWriterTask
QgsTask task which performs a QgsVectorFileWriter layer saving operation as a background task.
Definition: qgsvectorfilewritertask.h:36
QgsVectorFileWriter::CreateOrOverwriteFile
@ CreateOrOverwriteFile
Create or overwrite file.
Definition: qgsvectorfilewriter.h:266
QgsVectorFileWriter::Option::type
QgsVectorFileWriter::OptionType type
Definition: qgsvectorfilewriter.h:68
QgsVectorFileWriter
A convenience class for writing vector files to disk.
Definition: qgsvectorfilewriter.h:46
QgsVectorFileWriter::MetaData::glob
QString glob
Definition: qgsvectorfilewriter.h:159
QgsVectorFileWriter::SymbologyExport
SymbologyExport
Definition: qgsvectorfilewriter.h:182
QgsVectorFileWriter::FilterFormatDetails::filterString
QString filterString
Filter string for file picker dialogs.
Definition: qgsvectorfilewriter.h:674
QgsVectorFileWriter::FilterFormatDetails
Details of available filters and formats.
Definition: qgsvectorfilewriter.h:669
qgstaskmanager.h
QgsVectorFileWriter::mOgrDriverName
QString mOgrDriverName
Definition: qgsvectorfilewriter.h:886
QgsVectorFileWriter::DriverDetails::longName
QString longName
Descriptive, user friendly name for the driver.
Definition: qgsvectorfilewriter.h:720
QgsVectorFileWriter::HiddenOption
Definition: qgsvectorfilewriter.h:132
SIP_OUT
#define SIP_OUT
Definition: qgis_sip.h:58
QgsVectorFileWriter::FilterFormatDetails::globs
QStringList globs
Matching glob patterns for format, e.g.
Definition: qgsvectorfilewriter.h:680
gdal::ogr_datasource_unique_ptr
std::unique_ptr< std::remove_pointer< OGRDataSourceH >::type, OGRDataSourceDeleter > ogr_datasource_unique_ptr
Scoped OGR data source.
Definition: qgsogrutils.h:114
QgsVectorFileWriter::mError
WriterError mError
Contains error value if construction was not successful.
Definition: qgsvectorfilewriter.h:868
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:45
QgsVectorFileWriter::setSymbologyExport
void setSymbologyExport(QgsVectorFileWriter::SymbologyExport symExport)
Definition: qgsvectorfilewriter.h:791
qgsfeaturesink.h
QgsVectorFileWriter::MetaData::MetaData
MetaData()=default
Constructor for MetaData.
gdal
Definition: qgsogrutils.h:31
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:58
QgsVectorFileWriter::MetaData::longName
QString longName
Definition: qgsvectorfilewriter.h:157
QgsVectorFileWriter::SaveVectorOptions::layerName
QString layerName
Layer name. If let empty, it will be derived from the filename.
Definition: qgsvectorfilewriter.h:457
qgsogrutils.h
QgsVectorFileWriter::Option::Option
Option(const QString &docString, QgsVectorFileWriter::OptionType type)
Definition: qgsvectorfilewriter.h:62
QgsWkbTypes::Type
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70
QgsVectorFileWriter::FieldValueConverter
Interface to convert raw field values to their user-friendly value.
Definition: qgsvectorfilewriter.h:206
QgsVectorFileWriter::NoSymbology
@ NoSymbology
Definition: qgsvectorfilewriter.h:183
QgsVectorFileWriter::CreateOrOverwriteLayer
@ CreateOrOverwriteLayer
Create or overwrite layer.
Definition: qgsvectorfilewriter.h:269
field
const QgsField & field
Definition: qgsfield.h:456
QgsVectorFileWriter::ErrCreateDataSource
@ ErrCreateDataSource
Definition: qgsvectorfilewriter.h:171
QgsUnitTypes::DistanceUnit
DistanceUnit
Units of distance.
Definition: qgsunittypes.h:68
QgsAttributeList
QList< int > QgsAttributeList
Definition: qgsfield.h:26
QgsVectorFileWriter::Canceled
@ Canceled
Writing was interrupted by manual cancellation.
Definition: qgsvectorfilewriter.h:178
QgsVectorFileWriter::WriterError
WriterError
Definition: qgsvectorfilewriter.h:168
QgsVectorFileWriter::mErrorMessage
QString mErrorMessage
Definition: qgsvectorfilewriter.h:869
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsVectorFileWriter::FieldValueConverter::FieldValueConverter
FieldValueConverter()=default
Constructor.
QgsVectorFileWriter::MetaData::compulsoryEncoding
QString compulsoryEncoding
Some formats require a compulsory encoding, typically UTF-8. If no compulsory encoding,...
Definition: qgsvectorfilewriter.h:164
QgsVectorFileWriter::StringOption::StringOption
StringOption(const QString &docString, const QString &defaultValue=QString())
Definition: qgsvectorfilewriter.h:95
QgsVectorFileWriter::symbologyExport
QgsVectorFileWriter::SymbologyExport symbologyExport() const
Definition: qgsvectorfilewriter.h:790
QgsVectorFileWriter::mSymbologyExport
SymbologyExport mSymbologyExport
Definition: qgsvectorfilewriter.h:879
QgsVectorFileWriter::BoolOption
Definition: qgsvectorfilewriter.h:121
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsVectorFileWriter::HiddenOption::mValue
QString mValue
Definition: qgsvectorfilewriter.h:139
QgsVectorFileWriter::SaveVectorOptions::attributes
QgsAttributeList attributes
Attributes to export (empty means all unless skipAttributeCreation is set)
Definition: qgsvectorfilewriter.h:484
OGRSpatialReferenceH
void * OGRSpatialReferenceH
Definition: qgscoordinatereferencesystem.h:60
geos::unique_ptr
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:79
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
QgsVectorFileWriter::SaveVectorOptions::ct
QgsCoordinateTransform ct
Transform to reproject exported geometries with, or invalid transform for no transformation.
Definition: qgsvectorfilewriter.h:469
qgsgeometryengine.h
QgsVectorFileWriter::mDS
gdal::ogr_datasource_unique_ptr mDS
Definition: qgsvectorfilewriter.h:861
QgsSymbolLayer
Definition: qgssymbollayer.h:53
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsVectorFileWriter::String
@ String
Definition: qgsvectorfilewriter.h:51
QgsVectorFileWriter::mSymbologyScale
double mSymbologyScale
Scale for symbology export (e.g. for symbols units in map units)
Definition: qgsvectorfilewriter.h:884
QgsWkbTypes::Unknown
@ Unknown
Definition: qgswkbtypes.h:71
QgsVectorFileWriter::StringOption::defaultValue
QString defaultValue
Definition: qgsvectorfilewriter.h:100
QgsVectorFileWriter::mAttrIdxToOgrIdx
QMap< int, int > mAttrIdxToOgrIdx
Map attribute indizes to OGR field indexes.
Definition: qgsvectorfilewriter.h:877
QgsVectorFileWriter::MetaData::ext
QString ext
Definition: qgsvectorfilewriter.h:160
QgsVectorFileWriter::SaveVectorOptions::fileEncoding
QString fileEncoding
Encoding to use.
Definition: qgsvectorfilewriter.h:463
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsVectorFileWriter::symbologyScale
double symbologyScale() const
Returns the reference scale for output.
Definition: qgsvectorfilewriter.h:799
QgsVectorFileWriter::SetOption::SetOption
SetOption(const QString &docString, const QStringList &values, const QString &defaultValue, bool allowNone=false)
Definition: qgsvectorfilewriter.h:77
qgis_sip.h
QgsVectorFileWriter::ErrAttributeTypeUnsupported
@ ErrAttributeTypeUnsupported
Definition: qgsvectorfilewriter.h:173
Q_DECLARE_OPERATORS_FOR_FLAGS
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.
QgsFeatureList
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:583
QgsUnitTypes
Helper functions for various unit types.
Definition: qgsunittypes.h:39
QgsUnitTypes::DistanceMeters
@ DistanceMeters
Meters.
Definition: qgsunittypes.h:69
QgsVectorFileWriter::mSymbolLayerTable
QMap< QgsSymbolLayer *, QString > mSymbolLayerTable
Definition: qgsvectorfilewriter.h:881
QgsVectorFileWriter::ErrDriverNotFound
@ ErrDriverNotFound
Definition: qgsvectorfilewriter.h:170
QgsVectorFileWriter::MetaData::trLongName
QString trLongName
Definition: qgsvectorfilewriter.h:158
qgsrenderer.h
QgsVectorFileWriter::mFields
QgsFields mFields
Definition: qgsvectorfilewriter.h:865
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
QgsVectorFileWriter::EditionCapability
EditionCapability
Edition capability flags.
Definition: qgsvectorfilewriter.h:239
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsVectorFileWriter::mWkbType
QgsWkbTypes::Type mWkbType
Geometry type which is being used.
Definition: qgsvectorfilewriter.h:874
QgsVectorFileWriter::SaveVectorOptions::datasourceOptions
QStringList datasourceOptions
List of OGR data source creation options.
Definition: qgsvectorfilewriter.h:475
QgsVectorFileWriter::AppendToLayerNoNewFields
@ AppendToLayerNoNewFields
Append features to existing layer, but do not create new fields.
Definition: qgsvectorfilewriter.h:272
QgsVectorFileWriter::StringOption
Definition: qgsvectorfilewriter.h:93
QgsVectorFileWriter::ErrInvalidLayer
@ ErrInvalidLayer
Definition: qgsvectorfilewriter.h:177
QgsFeatureRenderer
Definition: qgsrenderer.h:103
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsVectorFileWriter::IntOption::IntOption
IntOption(const QString &docString, int defaultValue)
Definition: qgsvectorfilewriter.h:109
QgsVectorFileWriter::SaveVectorOptions::~SaveVectorOptions
virtual ~SaveVectorOptions()=default
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsVectorFileWriter::SetOption::allowNone
bool allowNone
Definition: qgsvectorfilewriter.h:86
QgsVectorFileWriter::Int
@ Int
Definition: qgsvectorfilewriter.h:52
QgsVectorFileWriter::Option::~Option
virtual ~Option()=default
QgsVectorFileWriter::BoolOption::BoolOption
BoolOption(const QString &docString, bool defaultValue)
Definition: qgsvectorfilewriter.h:123
QgsVectorFileWriter::HiddenOption::HiddenOption
HiddenOption(const QString &value)
Definition: qgsvectorfilewriter.h:134
QgsVectorFileWriter::MetaData::layerOptions
QMap< QString, QgsVectorFileWriter::Option * > layerOptions
Definition: qgsvectorfilewriter.h:162
QgsVectorFileWriter::SetOption::defaultValue
QString defaultValue
Definition: qgsvectorfilewriter.h:85
QgsVectorFileWriter::FieldValueConverter::~FieldValueConverter
virtual ~FieldValueConverter()=default
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
QgsVectorFileWriter::Option
Definition: qgsvectorfilewriter.h:60
QgsWkbTypes
Handles storage of information regarding WKB types and their properties.
Definition: qgswkbtypes.h:42
QgsVectorFileWriter::SaveVectorOptions::filterExtent
QgsRectangle filterExtent
If not empty, only features intersecting the extent will be saved.
Definition: qgsvectorfilewriter.h:493
QgsVectorFileWriter::ActionOnExistingFile
ActionOnExistingFile
Combination of CanAddNewLayer, CanAppendToExistingLayer, CanAddNewFieldsToExistingLayer or CanDeleteL...
Definition: qgsvectorfilewriter.h:264
QgsVectorFileWriter::ErrCreateLayer
@ ErrCreateLayer
Definition: qgsvectorfilewriter.h:172
QgsVectorFileWriter::FilterFormatDetails::driverName
QString driverName
Unique driver name.
Definition: qgsvectorfilewriter.h:671
QgsVectorFileWriter::SetOption::values
QSet< QString > values
Definition: qgsvectorfilewriter.h:84
QgsVectorFileWriter::SaveVectorOptions::layerOptions
QStringList layerOptions
List of OGR layer creation options.
Definition: qgsvectorfilewriter.h:478
QgsVectorFileWriter::ErrAttributeCreationFailed
@ ErrAttributeCreationFailed
Definition: qgsvectorfilewriter.h:174
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:53
QgsVectorFileWriter::SaveVectorOptions::driverName
QString driverName
OGR driver to use.
Definition: qgsvectorfilewriter.h:454
QgsFeatureIterator
Wrapper for iterator of features from vector data provider or vector layer.
Definition: qgsfeatureiterator.h:265
qgsfeedback.h
QgsVectorFileWriter::SetOption
Definition: qgsvectorfilewriter.h:75
QgsVectorFileWriter::ErrProjection
@ ErrProjection
Definition: qgsvectorfilewriter.h:175
qgssymbol.h
QgsVectorFileWriter::MetaData::MetaData
MetaData(const QString &longName, const QString &trLongName, const QString &glob, const QString &ext, const QMap< QString, QgsVectorFileWriter::Option * > &driverOptions, const QMap< QString, QgsVectorFileWriter::Option * > &layerOptions, const QString &compulsoryEncoding=QString())
Definition: qgsvectorfilewriter.h:147
QgsFeatureSink
An interface for objects which accept features via addFeature(s) methods.
Definition: qgsfeaturesink.h:34
QgsVectorFileWriter::VectorFormatOption
VectorFormatOption
Options for sorting and filtering vector formats.
Definition: qgsvectorfilewriter.h:194
QgsVectorFileWriter::Option::docString
QString docString
Definition: qgsvectorfilewriter.h:67
QgsField
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:50
QgsVectorFileWriter::FeatureSymbology
@ FeatureSymbology
Definition: qgsvectorfilewriter.h:184