14 #include "InternalErr.h"
23 HDFEOS2CFStr::HDFEOS2CFStr(
const int gsfd,
24 const std::string &filename,
25 const std::string &objname,
26 const std::string &varname,
27 const std::string &varnewname,
29 :Str(varnewname,filename),
34 grid_or_swath(grid_or_swath)
38 HDFEOS2CFStr::~HDFEOS2CFStr()
41 BaseType *HDFEOS2CFStr::ptr_duplicate()
43 return new HDFEOS2CFStr(*
this);
50 BESDEBUG(
"h4",
"Coming to HDFEOS2CFStr read "<<endl);
52 string check_pass_fileid_key_str=
"H4.EnablePassFileID";
53 bool check_pass_fileid_key =
false;
57 int32 (*openfunc) (
char *, intn);
58 intn (*closefunc) (int32);
59 int32 (*attachfunc) (int32,
char *);
60 intn (*detachfunc) (int32);
61 intn (*fieldinfofunc) (int32,
char *, int32 *, int32 *, int32 *,
char *);
62 intn (*readfieldfunc) (int32,
char *, int32 *, int32 *, int32 *,
void *);
63 int32 (*inqfunc) (
char *,
char *, int32 *);
67 if(grid_or_swath == 0) {
70 attachfunc = GDattach;
71 detachfunc = GDdetach;
72 fieldinfofunc = GDfieldinfo;
73 readfieldfunc = GDreadfield;
80 attachfunc = SWattach;
81 detachfunc = SWdetach;
82 fieldinfofunc = SWfieldinfo;
83 readfieldfunc = SWreadfield;
88 if (
false == check_pass_fileid_key) {
91 gfid = openfunc (const_cast < char *>(filename.c_str ()), DFACC_READ);
94 eherr <<
"File " << filename.c_str () <<
" cannot be open.";
95 throw InternalErr (__FILE__, __LINE__, eherr.str ());
102 int32 gsid = attachfunc (gfid, const_cast < char *>(objname.c_str ()));
104 if(
false == check_pass_fileid_key)
107 eherr <<
"Grid/Swath " << objname.c_str () <<
" cannot be attached.";
108 throw InternalErr (__FILE__, __LINE__, eherr.str ());
114 char tmp_dimlist[1024];
116 int32 field_dtype = 0;
118 r = fieldinfofunc (gsid, const_cast < char *>(varname.c_str ()),
119 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
122 if(
false == check_pass_fileid_key)
125 eherr <<
"Field " << varname.c_str () <<
" information cannot be obtained.";
126 throw InternalErr (__FILE__, __LINE__, eherr.str ());
130 vector<int32>offset32;
132 vector<int32>count32;
137 count32[0] = tmp_dims[0];
141 val.resize(count32[0]);
143 r = readfieldfunc(gsid,const_cast<char*>(varname.c_str()),
144 &offset32[0], &step32[0], &count32[0], &val[0]);
148 if(
false == check_pass_fileid_key)
151 eherr <<
"swath or grid readdata failed.";
152 throw InternalErr (__FILE__, __LINE__, eherr.str ());
155 string final_str(val.begin(),val.end());
156 set_value(final_str);
158 if(
false == check_pass_fileid_key)
static bool check_beskeys(const std::string &key)
Check the BES key. This function will check a BES key specified at the file h4.conf.in. If the key's value is either true or yes. The handler claims to find a key and will do some operations. Otherwise, will do different operations. For example, One may find a line H4.EnableCF=true at h4.conf.in. That means, the HDF4 handler will handle the HDF4 files by following CF conventions.
This class provides a way to map HDFEOS2 1-D character array to DAP Str for the CF option...
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream