Difficulties adjusting to different versions of HDFEOS2 library for HDF4 files
captainkirk99 opened this issue · 2 comments
The HDFEOS2 library is for NASA HDF4 files, like MODIS.
As discussed in this issue (SpatioTemporal/STAREmaster#111), there are two different versions of HDFEOS2 that should be accomodated, 2.19 and 2.20. Unfortunately there is some const changes which interact badly with the hdf4_handler file HDFEOS2.cc.
In HDFEOS2.cc there is code that passes some of the HDFEOS2 functions as function pointers to a function that calls the HDFEOS2 function. For example:
vector<string> gridlist;
if (!Utility::ReadNamelist(file->path.c_str(), GDinqgrid, gridlist)) {
delete file;
throw1("Grid ReadNamelist failed.");
}
This is calling the Utility::ReadNamelist() function, which is also in HDFEOS2.cc:
// Read name list from the EOS2 APIs and store names into a vector
bool Utility::ReadNamelist(const char *path,
int32 (*inq)(const char *, char *, int32 *),
vector<string> &names)
{
char *fname = const_cast<char *>(path);
int32 bufsize;
int numobjs;
if ((numobjs = inq(fname, NULL, &bufsize)) == -1) return false;
if (numobjs > 0) {
vector<char> buffer;
buffer.resize(bufsize + 1);
if (inq(fname, &buffer[0], &bufsize) == -1) return false;
HDFCFUtil::Split(&buffer[0], bufsize, ',', names);
}
return true;
}
Note that the second (unnamed) parameter to ReadNamelis() is a function pointer.
This ReadNamelist function is called only 3 times, for functions GDinqgrid(), SWinqswath(), and PTinqpoint().
The challenge here is that one of these functions, SWinqswath(), has a different first parameter in 2.19 and 2.20. In 2.20 it adds a const.
OK, roger that!