Skip to content

Commit

Permalink
Adding more default SHP->GPKG changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jachym committed Oct 19, 2017
1 parent 516540a commit 28daa1a
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 21 deletions.
6 changes: 3 additions & 3 deletions python/core/qgsvectorfilewriter.sip
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Constructor
const QString &fileName,
const QString &fileEncoding,
const QgsCoordinateReferenceSystem &destCRS = QgsCoordinateReferenceSystem(),
const QString &driverName = "ESRI Shapefile",
const QString &driverName = "GPKG",
bool onlySelected = false,
QString *errorMessage /Out/ = 0,
const QStringList &datasourceOptions = QStringList(),
Expand Down Expand Up @@ -269,7 +269,7 @@ Constructor
const QString &fileName,
const QString &fileEncoding,
const QgsCoordinateTransform &ct,
const QString &driverName = "ESRI Shapefile",
const QString &driverName = "GPKG",
bool onlySelected = false,
QString *errorMessage /Out/ = 0,
const QStringList &datasourceOptions = QStringList(),
Expand Down Expand Up @@ -448,7 +448,7 @@ Optional feedback object allowing cancelation of layer save
const QgsFields &fields,
QgsWkbTypes::Type geometryType,
const QgsCoordinateReferenceSystem &srs = QgsCoordinateReferenceSystem(),
const QString &driverName = "ESRI Shapefile",
const QString &driverName = "GPKG",
const QStringList &datasourceOptions = QStringList(),
const QStringList &layerOptions = QStringList(),
QString *newFilename = 0,
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/db_manager/dlg_export_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def populateFileFilters(self):

# set the last used filter
settings = QgsSettings()
filt = settings.value(self.lastUsedVectorFilterSettingsKey, "ESRI Shapefile")
filt = settings.value(self.lastUsedVectorFilterSettingsKey, "GPKG")

idx = self.cboFileFormat.findText(filt)
if idx < 0:
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributeactiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void QgsAttributeActionDialog::addDefaultActions()
{
int pos = 0;
insertRow( pos++, QgsAction::Generic, tr( "Echo attribute's value" ), QStringLiteral( "echo \"[% \"MY_FIELD\" %]\"" ), QLatin1String( "" ), true, tr( "Attribute Value" ), QSet<QString>() << QStringLiteral( "Field" ), QString() );
insertRow( pos++, QgsAction::Generic, tr( "Run an application" ), QStringLiteral( "ogr2ogr -f \"ESRI Shapefile\" \"[% \"OUTPUT_PATH\" %]\" \"[% \"INPUT_FILE\" %]\"" ), QLatin1String( "" ), true, tr( "Run application" ), QSet<QString>() << QStringLiteral( "Feature" ) << QStringLiteral( "Canvas" ), QString() );
insertRow( pos++, QgsAction::Generic, tr( "Run an application" ), QStringLiteral( "ogr2ogr -f \"GPKG\" \"[% \"OUTPUT_PATH\" %]\" \"[% \"INPUT_FILE\" %]\"" ), QLatin1String( "" ), true, tr( "Run application" ), QSet<QString>() << QStringLiteral( "Feature" ) << QStringLiteral( "Canvas" ), QString() );
insertRow( pos++, QgsAction::GenericPython, tr( "Get feature id" ), QStringLiteral( "from qgis.PyQt import QtWidgets\n\nQtWidgets.QMessageBox.information(None, \"Feature id\", \"feature id is [% $id %]\")" ), QLatin1String( "" ), false, tr( "Feature ID" ), QSet<QString>() << QStringLiteral( "Feature" ) << QStringLiteral( "Canvas" ), QString() );
insertRow( pos++, QgsAction::GenericPython, tr( "Selected field's value (Identify features tool)" ), QStringLiteral( "from qgis.PyQt import QtWidgets\n\nQtWidgets.QMessageBox.information(None, \"Current field's value\", \"[% @current_field %]\")" ), QLatin1String( "" ), false, tr( "Field Value" ), QSet<QString>() << QStringLiteral( "Field" ), QString() );
insertRow( pos++, QgsAction::GenericPython, tr( "Clicked coordinates (Run feature actions tool)" ), QStringLiteral( "from qgis.PyQt import QtWidgets\n\nQtWidgets.QMessageBox.information(None, \"Clicked coords\", \"layer: [% @layer_id %]\\ncoords: ([% @click_x %],[% @click_y %])\")" ), QLatin1String( "" ), false, tr( "Clicked Coordinate" ), QSet<QString>() << QStringLiteral( "Canvas" ), QString() );
Expand Down
4 changes: 2 additions & 2 deletions src/core/processing/qgsprocessingutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ void parseDestinationString( QString &destination, QString &providerKey, QString

if ( format.isEmpty() )
{
format = QStringLiteral( "ESRI Shapefile" );
destination = destination + QStringLiteral( ".shp" );
format = QStringLiteral( "GPKG" );
destination = destination + QStringLiteral( ".gpkg" );
}

options.insert( QStringLiteral( "driverName" ), format );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorfilewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2306,7 +2306,7 @@ QgsVectorFileWriter::WriterError QgsVectorFileWriter::writeAsVectorFormat( QgsVe
}

QgsVectorFileWriter::SaveVectorOptions::SaveVectorOptions()
: driverName( QStringLiteral( "ESRI Shapefile" ) )
: driverName( QStringLiteral( "GPKG" ) )
{
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsvectorfilewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class CORE_EXPORT QgsVectorFileWriter : public QgsFeatureSink
const QString &fileName,
const QString &fileEncoding,
const QgsCoordinateReferenceSystem &destCRS = QgsCoordinateReferenceSystem(),
const QString &driverName = "ESRI Shapefile",
const QString &driverName = "GPKG",
bool onlySelected = false,
QString *errorMessage SIP_OUT = nullptr,
const QStringList &datasourceOptions = QStringList(),
Expand Down Expand Up @@ -334,7 +334,7 @@ class CORE_EXPORT QgsVectorFileWriter : public QgsFeatureSink
const QString &fileName,
const QString &fileEncoding,
const QgsCoordinateTransform &ct,
const QString &driverName = "ESRI Shapefile",
const QString &driverName = "GPKG",
bool onlySelected = false,
QString *errorMessage SIP_OUT = nullptr,
const QStringList &datasourceOptions = QStringList(),
Expand Down Expand Up @@ -450,7 +450,7 @@ class CORE_EXPORT QgsVectorFileWriter : public QgsFeatureSink
const QgsFields &fields,
QgsWkbTypes::Type geometryType,
const QgsCoordinateReferenceSystem &srs = QgsCoordinateReferenceSystem(),
const QString &driverName = "ESRI Shapefile",
const QString &driverName = "GPKG",
const QStringList &datasourceOptions = QStringList(),
const QStringList &layerOptions = QStringList(),
QString *newFilename = nullptr,
Expand Down
2 changes: 1 addition & 1 deletion src/gui/ogr/qgsvectorlayersaveasdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void QgsVectorLayerSaveAsDialog::setup()
mFormatComboBox->addItem( it.key(), it.value() );
}

QString format = settings.value( QStringLiteral( "UI/lastVectorFormat" ), "ESRI Shapefile" ).toString();
QString format = settings.value( QStringLiteral( "UI/lastVectorFormat" ), "GPKG" ).toString();
mFormatComboBox->setCurrentIndex( mFormatComboBox->findData( format ) );
mFormatComboBox->blockSignals( false );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void QgsGeometryCheckerResultTab::exportErrors()
initialdir = dir.absolutePath();
}

QString file = QFileDialog::getSaveFileName( this, tr( "Select Output File" ), initialdir, tr( "ESRI Shapefile (*.shp);;" ) );
QString file = QFileDialog::getSaveFileName( this, tr( "Select Output File" ), initialdir, tr( "GeoPackage (*.gpkg);;" ) );
if ( file.isEmpty() )
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void QgsGeometryCheckerSetupTab::validateInput()

void QgsGeometryCheckerSetupTab::selectOutputFile()
{
QString filterString = QgsVectorFileWriter::filterForDriver( QStringLiteral( "ESRI Shapefile" ) );
QString filterString = QgsVectorFileWriter::filterForDriver( QStringLiteral( "GPKG" ) );
QMap<QString, QString> filterFormatMap = QgsVectorFileWriter::supportedFiltersAndFormats();
Q_FOREACH ( const QString &filter, filterFormatMap.keys() )
{
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ QgsVectorLayerExporter::ExportError QgsOgrProvider::createEmptyLayer( const QStr
const QMap<QString, QVariant> *options )
{
QString encoding;
QString driverName = QStringLiteral( "ESRI Shapefile" );
QString driverName = QStringLiteral( "GPKG" );
QStringList dsOptions, layerOptions;
QString layerName;
Expand Down
11 changes: 6 additions & 5 deletions tests/src/analysis/testqgsprocessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ void TestQgsProcessing::initTestCase()
void TestQgsProcessing::cleanupTestCase()
{
QFile::remove( QDir::tempPath() + "/create_feature_sink.tab" );
QgsVectorFileWriter::deleteShapeFile( QDir::tempPath() + "/create_feature_sink2.shp" );
QgsVectorFileWriter::deleteShapeFile( QDir::tempPath() + "/create_feature_sink2.gpkg" );

QgsApplication::exitQgis();
}
Expand Down Expand Up @@ -1211,7 +1211,7 @@ void TestQgsProcessing::createFeatureSink()

// no extension, should default to shp
destination = QDir::tempPath() + "/create_feature_sink2";
prevDest = QDir::tempPath() + "/create_feature_sink2.shp";
prevDest = QDir::tempPath() + "/create_feature_sink2.gpkg";
sink.reset( QgsProcessingUtils::createFeatureSink( destination, context, fields, QgsWkbTypes::Point25D, QgsCoordinateReferenceSystem::fromEpsgId( 3111 ) ) );
QVERIFY( sink.get() );
f.setGeometry( QgsGeometry::fromWkt( QStringLiteral( "PointZ(1 2 3)" ) ) );
Expand All @@ -1222,9 +1222,10 @@ void TestQgsProcessing::createFeatureSink()
layer = qobject_cast< QgsVectorLayer *>( QgsProcessingUtils::mapLayerFromString( destination, context, true ) );
QCOMPARE( layer->wkbType(), QgsWkbTypes::Point25D );
QCOMPARE( layer->crs().authid(), QStringLiteral( "EPSG:3111" ) );
QCOMPARE( layer->fields().size(), 1 );
QCOMPARE( layer->fields().at( 0 ).name(), QStringLiteral( "my_field" ) );
QCOMPARE( layer->fields().at( 0 ).type(), QVariant::String );
QCOMPARE( layer->fields().size(), 2 );
QCOMPARE( layer->fields().at( 0 ).name(), QStringLiteral( "fid" ) );
QCOMPARE( layer->fields().at( 1 ).name(), QStringLiteral( "my_field" ) );
QCOMPARE( layer->fields().at( 1 ).type(), QVariant::String );
QCOMPARE( layer->featureCount(), 1L );
delete layer;
layer = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/testqgsmaprendererjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void TestQgsMapRendererJob::initTestCase()
QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt
QString myTestDataDir = myDataDir + '/';
QString myTmpDir = QDir::tempPath() + '/';
QString myFileName = myTmpDir + "maprender_testdata.shp";
QString myFileName = myTmpDir + "maprender_testdata.gpkg";
//copy over the default qml for our generated layer
QString myQmlFileName = myTestDataDir + "maprender_testdata.qml";
QFile::remove( myTmpDir + "maprender_testdata.qml" );
Expand Down
Binary file modified tests/testdata/polys_overlapping_with_id.dbf
Binary file not shown.

0 comments on commit 28daa1a

Please sign in to comment.