@@ -42,7 +42,6 @@ email : sherman at mrcc.com
42
42
#include " qgsfield.h"
43
43
#include " qgsgeometry.h"
44
44
#include " qgscoordinatereferencesystem.h"
45
- #include " qgsvectorfilewriter.h"
46
45
#include " qgsvectorlayer.h"
47
46
48
47
static const QString TEXT_PROVIDER_KEY = " ogr" ;
@@ -83,6 +82,43 @@ class QgsCPLErrorHandler
83
82
}
84
83
};
85
84
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
+
86
122
QgsOgrProvider::QgsOgrProvider ( QString const & uri )
87
123
: QgsVectorDataProvider( uri ),
88
124
ogrDataSource( 0 ),
@@ -2369,3 +2405,14 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
2369
2405
return 0 ;
2370
2406
}
2371
2407
2408
+ QGISEXTERN int importVector (
2409
+ QgsVectorLayer *layer,
2410
+ const QString& uri,
2411
+ const QgsCoordinateReferenceSystem *destCRS,
2412
+ bool onlySelected,
2413
+ QString *errorMessage,
2414
+ bool skipAttributeCreation,
2415
+ const QMap<QString,QVariant> *options )
2416
+ {
2417
+ return QgsOgrProvider::importVector ( layer, uri, destCRS, onlySelected, errorMessage, skipAttributeCreation, options );
2418
+ }
0 commit comments