From bb65f61fa3b0fe6e46b8a4fce0bfdea146c0f6a9 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 25 Oct 2024 22:51:00 +0200 Subject: [PATCH] [OGR provider] Make querySublayers() work with GTFS .zip datasets Fixes #59222 Added tests/testdata/ogr/gtfs_extract.zip comes from GDAL autotest suite. --- src/core/qgsgdalutils.cpp | 6 ++++++ tests/src/python/test_provider_ogr.py | 9 +++++++++ tests/testdata/ogr/gtfs_extract.zip | Bin 0 -> 12051 bytes 3 files changed, 15 insertions(+) create mode 100644 tests/testdata/ogr/gtfs_extract.zip 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 0000000000000000000000000000000000000000..69538aa39166a15edea3ebf707714c2a042329af GIT binary patch literal 12051 zcmaia1yEeg)-CRq-~>&Ay9WpoG`PD3*C7lV+=6Rx2@V4c7Tn#P;0%`FHbV&RZ@zcm zyEpHC_rI^E_Eev9x>v34-o4JQI!jFv8HES|0RaO6Cz4&qH8#lB5`N_e4=e;q1Tz~e zCkrnQw@+@`T9^pPS3x}%Pw;U6gpGiRvX6{_@W1~Ql~gAbt74`U$Cc;hKYvq?+TAI08x&D(cMsSZsB0T<$FYZVWZXhiV>a<8*auJE3SzuVV`1uF=C9*Y>jSFMF zCihZY3U-N4!q!U%6erSP7PiC*WP{;e`TO@OG1^OA$2D}5Dqa3K7_#46gKu)gc(2oOl;RCalPgG^rM4M8bfiG^ z6Q29yLWZ^=7mHiOe{rRPb2WKBHRuoLNsWkr@C?q?%EjfQi>arXi<6y`%|8i~|L3Kv zjC+UID}jT2(%#EiiqZi*qN3|0NKt#~UPnJt)t{86`%Us5!MBdTR#dx@z*D6Hh{9p% z%CQ@hW&4rAtudy_WD7O<-8Lr_XgH6>-t zX-k$s<_dXSoUeHVL@v0oT`SMeKB1P}8_qavEn!F%9Vo5LG?P9~BXo3w{GjI)J@+au z=?xEU17^OjlJGV5AzSla_ZMo)XJ7vGvZbtT?~pDsN-?wr?u6x=#6 zYg%q7;T*1B`}N~N#PrHB`c}(FZ>&V;^1@oxt@f?&#(Q(aW9ybO>etK*4USh7#U#bt zCNb)vw_)Ye`y12qiUvv&bz4UdZ4y_$(P&z%SMINfbD^!qb%}yra$>_^a;8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