13 #include "InternalErr.h"
24 HDFEOS2CFStrField::read ()
27 BESDEBUG(
"h4",
"Coming to HDFEOS2CFStrField read "<<endl);
29 string check_pass_fileid_key_str=
"H4.EnablePassFileID";
30 bool check_pass_fileid_key =
false;
37 vector<int32>offset32;
38 offset32.resize(rank+1);
40 count32.resize(rank+1);
42 step32.resize(rank+1);
59 nelms = format_constraint (&offset[0], &step[0], &count[0]);
63 for (
int i = 0; i < rank; i++) {
64 offset32[i] = (int32) offset[i];
65 count32[i] = (int32) count[i];
66 step32[i] = (int32) step[i];
70 int32 (*openfunc) (
char *, intn);
71 intn (*closefunc) (int32);
72 int32 (*attachfunc) (int32,
char *);
73 intn (*detachfunc) (int32);
74 intn (*fieldinfofunc) (int32,
char *, int32 *, int32 *, int32 *,
char *);
75 intn (*readfieldfunc) (int32,
char *, int32 *, int32 *, int32 *,
void *);
76 int32 (*inqfunc) (
char *,
char *, int32 *);
80 if(grid_or_swath == 0) {
83 attachfunc = GDattach;
84 detachfunc = GDdetach;
85 fieldinfofunc = GDfieldinfo;
86 readfieldfunc = GDreadfield;
93 attachfunc = SWattach;
94 detachfunc = SWdetach;
95 fieldinfofunc = SWfieldinfo;
96 readfieldfunc = SWreadfield;
101 if (
false == check_pass_fileid_key) {
104 gfid = openfunc (const_cast < char *>(filename.c_str ()), DFACC_READ);
107 eherr <<
"File " << filename.c_str () <<
" cannot be open.";
108 throw InternalErr (__FILE__, __LINE__, eherr.str ());
115 int32 gsid = attachfunc (gfid, const_cast < char *>(objname.c_str ()));
117 if(
false == check_pass_fileid_key)
120 eherr <<
"Grid/Swath " << objname.c_str () <<
" cannot be attached.";
121 throw InternalErr (__FILE__, __LINE__, eherr.str ());
127 char tmp_dimlist[1024];
128 int32 tmp_dims[rank];
129 int32 field_dtype = 0;
131 r = fieldinfofunc (gsid, const_cast < char *>(varname.c_str ()),
132 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
135 if(
false == check_pass_fileid_key)
138 eherr <<
"Field " << varname.c_str () <<
" information cannot be obtained.";
139 throw InternalErr (__FILE__, __LINE__, eherr.str ());
143 count32[rank] = tmp_dims[rank];
145 int32 last_dim_size = tmp_dims[rank];
148 val.resize(nelms*count32[rank]);
150 r = readfieldfunc(gsid,const_cast<char*>(varname.c_str()),
151 &offset32[0], &step32[0], &count32[0], &val[0]);
155 if(
false == check_pass_fileid_key)
158 eherr <<
"swath or grid readdata failed.";
159 throw InternalErr (__FILE__, __LINE__, eherr.str ());
162 vector<string>final_val;
163 final_val.resize(nelms);
164 vector<char> temp_buf;
165 temp_buf.resize(last_dim_size+1);
169 for (
int i = 0; i<nelms;i++) {
170 strncpy(&temp_buf[0],&val[0]+last_dim_size*i,last_dim_size);
171 temp_buf[last_dim_size]=
'\0';
172 final_val[i] = &temp_buf[0];
174 set_value(&final_val[0],nelms);
177 if(
false == check_pass_fileid_key)
184 HDFEOS2CFStrField::format_constraint (
int *offset,
int *step,
int *count)
189 Dim_iter p = dim_begin ();
191 while (p != dim_end ()) {
193 int start = dimension_start (p,
true);
194 int stride = dimension_stride (p,
true);
195 int stop = dimension_stop (p,
true);
199 if (stride < 0 || start < 0 || stop < 0 || start > stop) {
202 oss <<
"Array/Grid hyperslab indices are bad: [" << start <<
203 ":" << stride <<
":" << stop <<
"]";
204 throw Error (malformed_expr, oss.str ());
208 if (start == 0 && stop == 0 && stride == 0) {
209 start = dimension_start (p,
false);
210 stride = dimension_stride (p,
false);
211 stop = dimension_stop (p,
false);
216 count[id] = ((stop - start) / stride) + 1;
220 "=format_constraint():"
221 <<
"id=" <<
id <<
" offset=" << offset[
id]
222 <<
" step=" << step[
id]
223 <<
" count=" << count[
id]
This class provides a way to map HDFEOS2 character >1D array to DAP Str array for the CF option...
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.
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream