Skip to content

Commit

Permalink
Don't show metadata.xml subcomponent file from ESRI tin folders as
Browse files Browse the repository at this point in the history
a OGR layer in browser
  • Loading branch information
nyalldawson committed Oct 6, 2021
1 parent fcbcf2c commit 6a6d6f6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/core/providers/ogr/qgsogrprovidermetadata.cpp
Expand Up @@ -1134,6 +1134,17 @@ QList<QgsProviderSublayerDetails> QgsOgrProviderMetadata::querySublayers( const
return {};
}

// metadata.xml file next to tdenv?.adf files is a subcomponent of an ESRI tin layer alone, shouldn't be exposed
if ( pathInfo.fileName().compare( QLatin1String( "metadata.xml" ), Qt::CaseInsensitive ) == 0 )
{
const QDir dir = pathInfo.dir();
if ( dir.exists( QStringLiteral( "tdenv9.adf" ) )
|| dir.exists( QStringLiteral( "tdenv.adf" ) )
|| dir.exists( QStringLiteral( "TDENV9.ADF" ) )
|| dir.exists( QStringLiteral( "TDENV.ADF" ) ) )
return {};
}

// if file is trivial to read then there's no need to rely on
// the extension only scan here -- avoiding it always gives us the correct data type
// and sublayer visibility
Expand Down
10 changes: 10 additions & 0 deletions tests/src/python/test_provider_ogr.py
Expand Up @@ -2088,6 +2088,11 @@ def test_provider_sublayer_details(self):
{'name': 'virts_geometry_columns_field_infos', 'systemTable': True},
{'name': 'virts_geometry_columns_statistics', 'systemTable': True}])

# metadata.xml file next to tdenv?.adf file -- this is a subcomponent of an ESRI tin layer, should not be exposed
res = metadata.querySublayers(
os.path.join(TEST_DATA_DIR, 'esri_tin', 'metadata.xml'))
self.assertFalse(res)

@unittest.skipIf(int(gdal.VersionInfo('VERSION_NUM')) < GDAL_COMPUTE_VERSION(3, 4, 0), "GDAL 3.4 required")
def test_provider_sublayer_details_hierarchy(self):
"""
Expand Down Expand Up @@ -2224,6 +2229,11 @@ def test_provider_sublayer_details_fast_scan(self):
res = metadata.querySublayers(os.path.join(TEST_DATA_DIR, "/raster/hub13263.vrt"), Qgis.SublayerQueryFlag.FastScan)
self.assertEqual(len(res), 0)

# metadata.xml file next to tdenv?.adf file -- this is a subcomponent of an ESRI tin layer, should not be exposed
res = metadata.querySublayers(
os.path.join(TEST_DATA_DIR, 'esri_tin', 'metadata.xml'), Qgis.SublayerQueryFlag.FastScan)
self.assertFalse(res)

def test_provider_sidecar_files_for_uri(self):
"""
Test retrieving sidecar files for uris
Expand Down

0 comments on commit 6a6d6f6

Please sign in to comment.