Opened 9 years ago

Closed 6 years 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 by antonio, 9 years ago

Cc: antonio added

comment:2 by Even Rouault, 9 years ago

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

comment:3 by Even Rouault, 9 years ago

Resolution: fixed
Status: newclosed

Backported in branches/1.11 in r28365

comment:4 by mpd, 6 years ago

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 by Even Rouault, 6 years ago

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.