diff --git a/src/core/qgsgdalutils.cpp b/src/core/qgsgdalutils.cpp index cd3e29251db0..afe05bf06573 100644 --- a/src/core/qgsgdalutils.cpp +++ b/src/core/qgsgdalutils.cpp @@ -855,7 +855,13 @@ QString QgsGdalUtils::vsiPrefixForPath( const QString &path ) return QStringLiteral( "/vsizip/" ); } else if ( path.endsWith( QLatin1String( ".zip" ), Qt::CaseInsensitive ) ) + { + // GTFS driver directly handles .zip files + const char *const apszAllowedDrivers[] = { "GTFS", nullptr }; + if ( GDALIdentifyDriverEx( path.toUtf8().constData(), GDAL_OF_VECTOR, apszAllowedDrivers, nullptr ) ) + return QString(); return QStringLiteral( "/vsizip/" ); + } else if ( path.endsWith( QLatin1String( ".tar" ), Qt::CaseInsensitive ) || path.endsWith( QLatin1String( ".tar.gz" ), Qt::CaseInsensitive ) || path.endsWith( QLatin1String( ".tgz" ), Qt::CaseInsensitive ) ) diff --git a/tests/src/python/test_provider_ogr.py b/tests/src/python/test_provider_ogr.py index bea3c46863cf..e03ee1ca34a8 100644 --- a/tests/src/python/test_provider_ogr.py +++ b/tests/src/python/test_provider_ogr.py @@ -1626,6 +1626,15 @@ def testDecodeEncodeUriVsizip(self): encodedUri = QgsProviderRegistry.instance().encodeUri('ogr', parts) self.assertEqual(encodedUri, uri) + @unittest.skipIf(gdal.GetDriverByName("GTFS") is None, "GTFS driver required") + def testDecodeGTFS(self): + """Test querySublayers() for GTFS .zip dataset""" + + uri = os.path.join(TEST_DATA_DIR, "ogr", "gtfs_extract.zip") + metadata = QgsProviderRegistry.instance().providerMetadata('ogr') + res = metadata.querySublayers(uri) + self.assertEqual(len(res), 9) + def testDecodeEncodeUriCredentialOptions(self): """Test decodeUri/encodeUri credential options support""" diff --git a/tests/testdata/ogr/gtfs_extract.zip b/tests/testdata/ogr/gtfs_extract.zip new file mode 100644 index 000000000000..69538aa39166 Binary files /dev/null and b/tests/testdata/ogr/gtfs_extract.zip differ