Opened 4 years ago

Closed 6 months ago

#5802 closed defect (fixed)

gdal HDF5 NetCDF plugin bug

Reported by: liminlu0314 Owned by: warmerdam
Priority: normal Milestone: 1.11.2
Component: GDAL_Raster Version: 1.11.1
Severity: normal Keywords: gdal HDF5 NetCDF plugin
Cc: antonio

Description

I found a problem with the HDF5 plugin in GDAL library: it can open H5 file, but cannot open the sub data set. The reason is that, when GDAL register HDF5 plug-in, it only call a registered function (GDALRegister_HDF5), while it needs another function GDALRegister_HDF5Image () to open HDF5 sub datasets. The problem also exists in HDF4 and NetCDF plugin.

Modify the file gdaldirvermanager.cpp in void GDALDriverManager::AutoLoadDrivers?()

            if( pRegister != NULL )
            {
                CPLDebug( "GDAL", "Auto register %s using %s.", 
                          pszFilename, pszFuncName );

                ((void (*)()) pRegister)();
				
				// 如果一个插件dll中有多个注册函数,目前针对特殊的几种格式进行特殊处理
				const char* pszBaseName = CPLGetBasename(papszFiles[iFile]) + 5;
				if( EQUAL(pszBaseName, "HDF4") || EQUAL(pszBaseName, "HDF5") )
				{
					CPLString osLastErrorMsg(CPLGetLastErrorMsg());
					sprintf( pszFuncName, "GDALRegister_%sImage", 
						CPLGetBasename(papszFiles[iFile]) + 5 );

					pRegister = CPLGetSymbol( pszFilename, pszFuncName );
					if( pRegister == NULL )
					{
						CPLError( CE_Failure, CPLE_AppDefined,
							"%s", osLastErrorMsg.c_str() );
					}

					CPLDebug( "GDAL", "Auto register %s using %s.", 
						pszFilename, pszFuncName );

					((void (*)()) pRegister)();
				}
				else if(EQUAL(pszBaseName, "NETCDF"))
				{
					CPLString osLastErrorMsg(CPLGetLastErrorMsg());
					strcpy( pszFuncName, "GDALRegister_GMT" );
					pRegister = CPLGetSymbol( pszFilename, pszFuncName );
					if( pRegister == NULL )
					{
						CPLError( CE_Failure, CPLE_AppDefined,
							"%s", osLastErrorMsg.c_str() );
					}

					CPLDebug( "GDAL", "Auto register %s using %s.", 
						pszFilename, pszFuncName );

					((void (*)()) pRegister)();
				}
            }

Change History (5)

comment:1 Changed 4 years ago by antonio

Cc: antonio added

comment:2 Changed 3 years ago by Even Rouault

trunk r28355 "Windows build: when building netCDF, HDF4, HDF5 as plugins, call registration of 'sub-drivers' GMT, HDF4Image and HDF5Image (#5802)"

comment:3 Changed 3 years ago by Even Rouault

Resolution: fixed
Status: newclosed

Backported in branches/1.11 in r28365

comment:4 Changed 6 months ago by mpd

Resolution: fixed
Status: closedreopened
#ifdef HDF5_PLUGIN
    GDALRegister_HDF5Image();
#endif

... in GDALRegister_HDF5() needs to be ...

#ifdef HDF5_PLUGIN
    GDALRegister_HDF5Image();
    GDALRegister_BAG();
#endif

... to get the BAG driver registered.

comment:5 Changed 6 months ago by Even Rouault

Resolution: fixed
Status: reopenedclosed

In 41331:

HDF5 driver as a plugin: register the BAG driver as well (patch by mpd, fixes #5802)

Note: See TracTickets for help on using tickets.