From 31e3e272206ca31e82416e7607f49613c303a071 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 21 Jan 2025 18:18:06 +0100 Subject: [PATCH] Vector driver lists (open/save): add .gpkg.zip extension Fixes #59959 --- src/core/providers/ogr/qgsogrproviderutils.cpp | 5 +++++ src/core/qgsvectorfilewriter.cpp | 4 ++++ tests/src/python/test_qgsvectorfilewriter.py | 13 +++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/core/providers/ogr/qgsogrproviderutils.cpp b/src/core/providers/ogr/qgsogrproviderutils.cpp index 9c1b80eb3457..67b779c265c2 100644 --- a/src/core/providers/ogr/qgsogrproviderutils.cpp +++ b/src/core/providers/ogr/qgsogrproviderutils.cpp @@ -344,8 +344,13 @@ QString createFilters( const QString &type ) } else if ( driverName.startsWith( QLatin1String( "GPKG" ) ) ) { +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,7,0) + sFileFilters += createFileFilter_( QObject::tr( "GeoPackage" ), QStringLiteral( "*.gpkg *.gpkg.zip" ) ); + sExtensions << QStringLiteral( "gpkg" ) << QStringLiteral( "gpkg.zip" ); +#else sFileFilters += createFileFilter_( QObject::tr( "GeoPackage" ), QStringLiteral( "*.gpkg" ) ); sExtensions << QStringLiteral( "gpkg" ); +#endif } else if ( driverName.startsWith( QLatin1String( "GRASS" ) ) ) { diff --git a/src/core/qgsvectorfilewriter.cpp b/src/core/qgsvectorfilewriter.cpp index 91e12afce66b..0ae7e8e2b5cf 100644 --- a/src/core/qgsvectorfilewriter.cpp +++ b/src/core/qgsvectorfilewriter.cpp @@ -1574,7 +1574,11 @@ class QgsVectorFileWriterMetadataContainer QgsVectorFileWriter::MetaData( QStringLiteral( "GeoPackage" ), QObject::tr( "GeoPackage" ), +#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,7,0) + QStringLiteral( "*.gpkg *.gpkg.zip" ), +#else QStringLiteral( "*.gpkg" ), +#endif QStringLiteral( "gpkg" ), datasetOptions, layerOptions, diff --git a/tests/src/python/test_qgsvectorfilewriter.py b/tests/src/python/test_qgsvectorfilewriter.py index a1a2f6dcbffe..857fae26f145 100644 --- a/tests/src/python/test_qgsvectorfilewriter.py +++ b/tests/src/python/test_qgsvectorfilewriter.py @@ -903,9 +903,18 @@ def testSupportedFiltersAndFormat(self): formats = QgsVectorFileWriter.supportedFiltersAndFormats( QgsVectorFileWriter.VectorFormatOption.SortRecommended ) - self.assertEqual(formats[0].filterString, "GeoPackage (*.gpkg *.GPKG)") + if int(gdal.VersionInfo("VERSION_NUM")) >= GDAL_COMPUTE_VERSION(3, 7, 0): + self.assertEqual( + formats[0].filterString, + "GeoPackage (*.gpkg *.gpkg.zip *.GPKG *.GPKG.ZIP)", + ) + else: + self.assertEqual(formats[0].filterString, "GeoPackage (*.gpkg *.GPKG)") self.assertEqual(formats[0].driverName, "GPKG") - self.assertEqual(formats[0].globs, ["*.gpkg"]) + if int(gdal.VersionInfo("VERSION_NUM")) >= GDAL_COMPUTE_VERSION(3, 7, 0): + self.assertEqual(formats[0].globs, ["*.gpkg", "*.gpkg.zip"]) + else: + self.assertEqual(formats[0].globs, ["*.gpkg"]) self.assertEqual(formats[1].filterString, "ESRI Shapefile (*.shp *.SHP)") self.assertEqual(formats[1].driverName, "ESRI Shapefile") self.assertEqual(formats[1].globs, ["*.shp"])