OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.9k stars 2.55k forks source link

Failed to open TIF file in GA_Update mode with /vsiwebhdfs prefix #9931

Closed wuxianshenga closed 5 months ago

wuxianshenga commented 5 months ago

What is the bug?

When I use the /vsiwebhdfs prefix to create a pyramid for TIF data, I get an error. After testing, I find that when I open the file in update mode, I get an error message 'Only read-only mode is supported for /vsicurl'

Steps to reproduce the issue

int main(int argc, char* argv[]) { CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO"); CPLSetConfigOption("SHAPE_ENCODING", ""); GDALAllRegister();

CPLSetConfigOption("CPL_VSIL_USE_TEMP_FILE_FOR_RANDOM_WRITE", "YES");
CPLSetConfigOption("WEBHDFS_USERNAME", "root");
CPLSetConfigOption("WEBHDFS_DELEGATION", "token");

const char* in_dataset = u8"/vsiwebhdfs/http://172.16.62.11:9870/webhdfs/v1/tmp/test.tif";

GDALDriver* pTifDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
GDALDataset* pidst = pTifDriver->Create(in_dataset, 10000, 10000, 1, GDT_Byte, nullptr);
GDALClose(pidst);

pidst = (GDALDataset*)GDALOpen(in_dataset, GDALAccess::GA_Update);
if (nullptr == pidst)
{
    fmt::print("[ERROR][UPDATE]:{}\n", CPLGetLastErrorMsg());
}

GDALClose(pidst);
return 0;

}

Versions and provenance

window10 and linux gdal3.6.2

Additional context

No response

rouault commented 5 months ago

I've tested successfully gdaladdo types of scenario with latest GDAL master. I now realize that for update mode, you need at least GDAL 3.8.0 for the fix of https://github.com/OSGeo/gdal/pull/8416 In prior versions, CPL_VSIL_USE_TEMP_FILE_FOR_RANDOM_WRITE only worked when creating a new file, but not to update an existing file

wuxianshenga commented 5 months ago

I've tested successfully gdaladdo types of scenario with latest GDAL master. I now realize that for update mode, you need at least GDAL 3.8.0 for the fix of #8416 In prior versions, CPL_VSIL_USE_TEMP_FILE_FOR_RANDOM_WRITE only worked when creating a new file, but not to update an existing file

Thanks for your reply, I have used the new version to test that opening TIF with update mode is valid, but when I tested gdaladdo.exe, I still couldn't create the pyramid, I used the -ro parameter