Skip to content
Permalink
Browse files
Remove unused skipAttributeCreation option in QgsVectorLayerExporter:…
…:exportLayer
  • Loading branch information
nyalldawson committed May 11, 2017
1 parent 64b612f commit 75a5d5d
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 20 deletions.
@@ -2189,6 +2189,7 @@ QgsCoordinateReferenceSystem is now implicitly shared, using references to QgsCo
pointers makes for more robust, safer code. Use an invalid (default constructed) QgsCoordinateReferenceSystem
in code which previously passed a null pointer to QgsVectorLayerImport.
- importLayer was renamed to exportLayer
- The unused skipAttributeCreation in exportLayer() was removed
- The unused QProgressBar argument in the QgsVectorLayerImport was removed
- ImportError was renamed to ExportError
- The unused enum value ErrDriverNotFound was removed
@@ -52,7 +52,6 @@ class QgsVectorLayerExporter : QgsFeatureSink
const QgsCoordinateReferenceSystem &destCRS,
bool onlySelected = false,
QString *errorMessage /Out/ = 0,
bool skipAttributeCreation = false,
QMap<QString, QVariant> *options = 0,
QProgressDialog *progress = 0
);
@@ -65,7 +64,6 @@ class QgsVectorLayerExporter : QgsFeatureSink
not available
\param onlySelected set to true to export only selected features
\param errorMessage if non-null, will be set to any error messages
\param skipAttributeCreation set to true to skip exporting feature attributes
\param options optional provider dataset options
\param progress optional progress dialog to show progress of export
:return: NoError for a successful export, or encountered error
@@ -179,7 +179,7 @@ def accept(self):
self.inLayer.setCrs(inCrs)

# do the export!
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs, False,
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs,
False, options)
except Exception as e:
ret = -1
@@ -360,7 +360,7 @@ def accept(self):
onlySelected = self.chkSelectedFeatures.isChecked()

# do the import!
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs, onlySelected, False, options)
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs, onlySelected, options)
except Exception as e:
ret = -1
errMsg = str(e)
@@ -170,7 +170,6 @@ def processAlgorithm(self, context, feedback):
providerName,
self.crs,
False,
False,
options,
)
if ret != 0:
@@ -140,7 +140,6 @@ def processAlgorithm(self, context, feedback):
providerName,
self.crs,
False,
False,
options,
)
if ret != 0:
@@ -231,7 +231,6 @@ QgsVectorLayerExporter::exportLayer( QgsVectorLayer *layer,
const QgsCoordinateReferenceSystem &destCRS,
bool onlySelected,
QString *errorMessage,
bool skipAttributeCreation,
QMap<QString, QVariant> *options,
QProgressDialog *progress )
{
@@ -263,7 +262,7 @@ QgsVectorLayerExporter::exportLayer( QgsVectorLayer *layer,
forceSinglePartGeom = options->take( QStringLiteral( "forceSinglePartGeometryType" ) ).toBool();
}

QgsFields fields = skipAttributeCreation ? QgsFields() : layer->fields();
QgsFields fields = layer->fields();
QgsWkbTypes::Type wkbType = layer->wkbType();

// Special handling for Shapefiles
@@ -327,8 +326,6 @@ QgsVectorLayerExporter::exportLayer( QgsVectorLayer *layer,
QgsFeatureRequest req;
if ( wkbType == QgsWkbTypes::NoGeometry )
req.setFlags( QgsFeatureRequest::NoGeometry );
if ( skipAttributeCreation )
req.setSubsetOfAttributes( QgsAttributeList() );

QgsFeatureIterator fit = layer->getFeatures( req );

@@ -405,10 +402,6 @@ QgsVectorLayerExporter::exportLayer( QgsVectorLayer *layer,
return ErrProjection;
}
}
if ( skipAttributeCreation )
{
fet.initAttributes( 0 );
}
if ( !writer->addFeature( fet ) )
{
if ( writer->errorCode() && errorMessage )
@@ -504,7 +497,7 @@ bool QgsVectorLayerExporterTask::run()


mError = QgsVectorLayerExporter::exportLayer(
mLayer.data(), mDestUri, mDestProviderKey, mDestCrs, false, &mErrorMessage, false,
mLayer.data(), mDestUri, mDestProviderKey, mDestCrs, false, &mErrorMessage,
&mOptions );

if ( mOwnsLayer )
@@ -74,7 +74,6 @@ class CORE_EXPORT QgsVectorLayerExporter : public QgsFeatureSink
* not available
* \param onlySelected set to true to export only selected features
* \param errorMessage if non-null, will be set to any error messages
* \param skipAttributeCreation set to true to skip exporting feature attributes
* \param options optional provider dataset options
* \param progress optional progress dialog to show progress of export
* \returns NoError for a successful export, or encountered error
@@ -85,7 +84,6 @@ class CORE_EXPORT QgsVectorLayerExporter : public QgsFeatureSink
const QgsCoordinateReferenceSystem &destCRS,
bool onlySelected = false,
QString *errorMessage SIP_OUT = 0,
bool skipAttributeCreation = false,
QMap<QString, QVariant> *options = nullptr,
QProgressDialog *progress = nullptr
);
@@ -416,7 +416,7 @@ def testSimulatedDBManagerImport(self):
options['update'] = True
options['driverName'] = 'GPKG'
options['layerName'] = 'my_out_table'
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, False, options)
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, options)
self.assertEqual(err[0], QgsVectorLayerExporter.NoError,
'unexpected import error {0}'.format(err))
lyr = QgsVectorLayer(tmpfile + "|layername=my_out_table", "y", "ogr")
@@ -431,7 +431,7 @@ def testSimulatedDBManagerImport(self):
features = None

# Test overwriting without overwrite option
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, False, options)
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, options)
self.assertEqual(err[0], QgsVectorLayerExporter.ErrCreateDataSource)

# Test overwriting
@@ -441,7 +441,7 @@ def testSimulatedDBManagerImport(self):
f['f1'] = 3
lyr.dataProvider().addFeatures([f])
options['overwrite'] = True
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, False, options)
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, options)
self.assertEqual(err[0], QgsVectorLayerExporter.NoError,
'unexpected import error {0}'.format(err))
lyr = QgsVectorLayer(tmpfile + "|layername=my_out_table", "y", "ogr")

0 comments on commit 75a5d5d

Please sign in to comment.