Skip to content

Commit

Permalink
Vector driver lists (open/save): add .gpkg.zip extension
Browse files Browse the repository at this point in the history
Fixes #59959
  • Loading branch information
rouault authored and lbartoletti committed Jan 22, 2025
1 parent 282a5a1 commit ef0dd03
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/core/providers/ogr/qgsogrproviderutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) ) )
{
Expand Down
4 changes: 4 additions & 0 deletions src/core/qgsvectorfilewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 11 additions & 2 deletions tests/src/python/test_qgsvectorfilewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down

0 comments on commit ef0dd03

Please sign in to comment.