File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -6746,6 +6746,20 @@ def test_netcdf_LIST_ALL_ARRAYS():
67466746 )
67476747
67486748
6749+ def test_netcdf_LIST_ALL_ARRAYS_on_dataset_without_2D_arrays (tmp_path ):
6750+
6751+ gdal .Run (
6752+ "mdim" ,
6753+ "convert" ,
6754+ input = "data/netcdf/byte.nc" ,
6755+ output = tmp_path / "out.nc" ,
6756+ array = "x" ,
6757+ )
6758+
6759+ ds = gdal .OpenEx (tmp_path / "out.nc" , open_options = ["LIST_ALL_ARRAYS=YES" ])
6760+ assert len (ds .GetSubDatasets ()) == 1
6761+
6762+
67496763###############################################################################
67506764# Test use of GeoTransform attribute to avoid precision loss
67516765# https://github.com/OSGeo/gdal/issues/11993
Original file line number Diff line number Diff line change @@ -8471,8 +8471,11 @@ GDALDataset *netCDFDataset::Open(GDALOpenInfo *poOpenInfo)
84718471 }
84728472 CSLDestroy (papszIgnoreVars);
84738473
8474+ const bool bListAllArrays = CPLTestBool (
8475+ CSLFetchNameValueDef (poDS->papszOpenOptions , " LIST_ALL_ARRAYS" , " NO" ));
8476+
84748477 // Case where there is no raster variable
8475- if (nRasterVars == 0 && !bTreatAsSubdataset)
8478+ if (!bListAllArrays && nRasterVars == 0 && !bTreatAsSubdataset)
84768479 {
84778480 poDS->GDALPamDataset ::SetMetadata (poDS->papszMetadata );
84788481 CPLReleaseMutex (hNCMutex); // Release mutex otherwise we'll deadlock
@@ -8501,8 +8504,6 @@ GDALDataset *netCDFDataset::Open(GDALOpenInfo *poOpenInfo)
85018504 // We have more than one variable with 2 dimensions in the
85028505 // file, then treat this as a subdataset container dataset.
85038506 bool bSeveralVariablesAsBands = false ;
8504- const bool bListAllArrays = CPLTestBool (
8505- CSLFetchNameValueDef (poDS->papszOpenOptions , " LIST_ALL_ARRAYS" , " NO" ));
85068507 if (bListAllArrays || ((nRasterVars > 1 ) && !bTreatAsSubdataset))
85078508 {
85088509 if (CPLFetchBool (poOpenInfo->papszOpenOptions , " VARIABLES_AS_BANDS" ,
You can’t perform that action at this time.
0 commit comments