@@ -42,7 +42,6 @@ email : sherman at mrcc.com
4242#include " qgsfield.h"
4343#include " qgsgeometry.h"
4444#include " qgscoordinatereferencesystem.h"
45- #include " qgsvectorfilewriter.h"
4645#include " qgsvectorlayer.h"
4746
4847static const QString TEXT_PROVIDER_KEY = " ogr" ;
@@ -83,6 +82,43 @@ class QgsCPLErrorHandler
8382 }
8483};
8584
85+
86+
87+ QgsVectorFileWriter::WriterError
88+ QgsOgrProvider::importVector (
89+ QgsVectorLayer *layer,
90+ const QString& fileName,
91+ const QgsCoordinateReferenceSystem *destCRS,
92+ bool onlySelected,
93+ QString *errorMessage,
94+ bool skipAttributeCreation,
95+ const QMap<QString,QVariant> *options )
96+ {
97+ QString encoding;
98+ QString driverName = " ESRI Shapefile" ;
99+ QStringList dsOptions, layerOptions;
100+
101+ if ( options )
102+ {
103+ if ( options->contains ( " fileEncoding" ) )
104+ encoding = options->value ( " fileEncoding" ).toString ();
105+
106+ if ( options->contains ( " driverName" ) )
107+ driverName = options->value ( " driverName" ).toString ();
108+
109+ if ( options->contains ( " datasourceOptions" ) )
110+ dsOptions << options->value ( " datasourceOptions" ).toStringList ();
111+
112+ if ( options->contains ( " layerOptions" ) )
113+ layerOptions << options->value ( " layerOptions" ).toStringList ();
114+ }
115+
116+ return QgsVectorFileWriter::writeAsVectorFormat (
117+ layer, fileName, encoding, destCRS, driverName, onlySelected,
118+ errorMessage, dsOptions, layerOptions, skipAttributeCreation );
119+ }
120+
121+
86122QgsOgrProvider::QgsOgrProvider ( QString const & uri )
87123 : QgsVectorDataProvider( uri ),
88124 ogrDataSource( 0 ),
@@ -2362,3 +2398,14 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
23622398 return 0 ;
23632399}
23642400
2401+ QGISEXTERN int importVector (
2402+ QgsVectorLayer *layer,
2403+ const QString& uri,
2404+ const QgsCoordinateReferenceSystem *destCRS,
2405+ bool onlySelected,
2406+ QString *errorMessage,
2407+ bool skipAttributeCreation,
2408+ const QMap<QString,QVariant> *options )
2409+ {
2410+ return QgsOgrProvider::importVector ( layer, uri, destCRS, onlySelected, errorMessage, skipAttributeCreation, options );
2411+ }
0 commit comments