14#include <libdap/debug.h>
15#include <libdap/InternalErr.h>
20#include "HDFEOS2Array_RealField.h"
22#include "HDF4RequestHandler.h"
27#define SIGNED_BYTE_TO_INT32 1
30HDFEOS2Array_RealField::read ()
33 BESDEBUG(
"h4",
"Coming to HDFEOS2_Array_RealField read "<<endl);
37 bool check_pass_fileid_key = HDF4RequestHandler::get_pass_fileid();
49 nelms = format_constraint (offset.data(), step.data(), count.data());
53 offset32.resize(rank);
60 for (
int i = 0; i < rank; i++) {
61 offset32[i] = offset[i];
62 count32[i] = count[i];
67 int32 (*openfunc) (
char *, intn);
68 intn (*closefunc) (int32);
69 int32 (*attachfunc) (int32,
char *);
70 intn (*detachfunc) (int32);
71 intn (*fieldinfofunc) (int32,
char *, int32 *, int32 *, int32 *,
char *);
74 if (swathname ==
"") {
77 attachfunc = GDattach;
78 detachfunc = GDdetach;
79 fieldinfofunc = GDfieldinfo;
80 datasetname = gridname;
82 else if (gridname ==
"") {
85 attachfunc = SWattach;
86 detachfunc = SWdetach;
87 fieldinfofunc = SWfieldinfo;
88 datasetname = swathname;
91 throw InternalErr (__FILE__, __LINE__,
"It should be either grid or swath.");
97 if (
true == isgeofile ||
false == check_pass_fileid_key) {
100 gfid = openfunc (
const_cast < char *
>(filename.c_str ()), DFACC_READ);
103 eherr <<
"File " << filename.c_str () <<
" cannot be open.";
104 throw InternalErr (__FILE__, __LINE__, eherr.str ());
111 gridid = attachfunc (gfid,
const_cast < char *
>(datasetname.c_str ()));
113 close_fileid(gfid,-1);
115 eherr <<
"Grid/Swath " << datasetname.c_str () <<
" cannot be attached.";
116 throw InternalErr (__FILE__, __LINE__, eherr.str ());
119 bool is_modis_l1b =
false;
120 if (
"MODIS_SWATH_Type_L1B" == swathname)
123 bool is_modis_vip =
false;
124 if (
"VIP_CMG_GRID" == gridname)
127 bool field_is_vdata =
false;
138 char tmp_dimlist[1024];
139 int32 tmp_dims[rank];
140 int32 field_dtype = 0;
143 r = fieldinfofunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
144 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
147 close_fileid(gfid,-1);
150 eherr <<
"Field " << fieldname.c_str () <<
" information cannot be obtained.";
151 throw InternalErr (__FILE__, __LINE__, eherr.str ());
155 field_is_vdata =
true;
159 bool has_Key_attr =
false;
161 if (
false == field_is_vdata) {
166 if (
true == isgeofile ||
false == check_pass_fileid_key) {
168 sdfileid = SDstart(filename.c_str (), DFACC_READ);
170 if (FAIL == sdfileid) {
172 close_fileid(gfid,-1);
174 eherr <<
"Cannot Start the SD interface for the file " << filename <<endl;
182 sdsindex = SDnametoindex(sdfileid, fieldname.c_str());
183 if (FAIL == sdsindex) {
185 close_fileid(gfid,sdfileid);
187 eherr <<
"Cannot obtain the index of " << fieldname;
188 throw InternalErr (__FILE__, __LINE__, eherr.str ());
191 sdsid = SDselect(sdfileid, sdsindex);
194 close_fileid(gfid,sdfileid);
196 eherr <<
"Cannot obtain the SDS ID of " << fieldname;
197 throw InternalErr (__FILE__, __LINE__, eherr.str ());
206 if (SDfindattr(sdsid,
"Key")!=FAIL)
211 if (
true == isgeofile ||
false == check_pass_fileid_key)
217 if ((
false == is_modis_l1b) && (
false == is_modis_vip)
218 &&(
false == has_Key_attr) && (
true == HDF4RequestHandler::get_disable_scaleoffset_comp()))
219 write_dap_data_disable_scale_comp(gridid,nelms,offset32.data(),count32.data(),step32.data());
221 write_dap_data_scale_comp(gridid,nelms,offset32,count32,step32);
225 close_fileid(gfid,-1);
230 r = detachfunc (gridid);
232 close_fileid(gfid,-1);
234 eherr <<
"Grid/Swath " << datasetname.c_str () <<
" cannot be detached.";
235 throw InternalErr (__FILE__, __LINE__, eherr.str ());
239 if (
true == isgeofile ||
false == check_pass_fileid_key) {
240 r = closefunc (gfid);
243 eherr <<
"Grid/Swath " << filename.c_str () <<
" cannot be closed.";
244 throw InternalErr (__FILE__, __LINE__, eherr.str ());
252HDFEOS2Array_RealField::write_dap_data_scale_comp(int32 gridid,
260 "coming to HDFEOS2Array_RealField write_dap_data_scale_comp "
263 bool check_pass_fileid_key = HDF4RequestHandler::get_pass_fileid();
266 intn (*fieldinfofunc) (int32,
char *, int32 *, int32 *, int32 *,
char *);
267 intn (*readfieldfunc) (int32,
char *, int32 *, int32 *, int32 *,
void *);
270 if (swathname ==
"") {
271 fieldinfofunc = GDfieldinfo;
272 readfieldfunc = GDreadfield;
274 else if (gridname ==
"") {
275 fieldinfofunc = SWfieldinfo;
276 readfieldfunc = SWreadfield;
279 throw InternalErr (__FILE__, __LINE__,
"It should be either grid or swath.");
283 char tmp_dimlist[1024];
286 int32 tmp_dims[rank];
289 int32 field_dtype = 0;
296 r = fieldinfofunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
297 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
301 eherr <<
"Field " << fieldname.c_str () <<
" information cannot be obtained.";
302 throw InternalErr (__FILE__, __LINE__, eherr.str ());
312 float *reflectance_offsets =
nullptr;
313 float *reflectance_scales =
nullptr;
314 float *radiance_offsets =
nullptr;
315 float *radiance_scales =
nullptr;
318 int32 attr_dtype = 0;
321 int32 temp_attrcount = 0;
324 int32 num_eles_of_an_attr = 0;
327 int32 cf_modl1b_rr_attrindex = 0;
330 int32 cf_modl1b_rr_attrindex2 = 0;
333 int32 cf_vr_attrindex = 0;
336 int32 cf_fv_attrindex = 0;
339 int32 scale_factor_attr_index = 0;
342 int32 add_offset_attr_index = 0;
348 float field_offset = 0;
354 float orig_valid_min = 0;
357 float orig_valid_max = 0;
364 bool has_Key_attr =
false;
367 if (sotype!=SOType::DEFAULT_CF_EQU) {
369 bool field_is_vdata =
false;
382 r = fieldinfofunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
383 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
386 eherr <<
"Field " << fieldname.c_str ()
387 <<
" information cannot be obtained.";
388 throw InternalErr (__FILE__, __LINE__, eherr.str ());
392 field_is_vdata =
true;
402 if (
false == field_is_vdata) {
404 char attrname[H4_MAX_NC_NAME + 1];
408 if (
false == isgeofile ||
false == check_pass_fileid_key)
411 sdfileid = SDstart(filename.c_str (), DFACC_READ);
412 if (FAIL == sdfileid) {
414 eherr <<
"Cannot Start the SD interface for the file "
416 throw InternalErr (__FILE__, __LINE__, eherr.str ());
422 sdsindex = SDnametoindex(sdfileid, fieldname.c_str());
423 if (FAIL == sdsindex) {
424 if (
true == isgeofile ||
false == check_pass_fileid_key)
427 eherr <<
"Cannot obtain the index of " << fieldname;
428 throw InternalErr (__FILE__, __LINE__, eherr.str ());
431 sdsid = SDselect(sdfileid, sdsindex);
433 if (
true == isgeofile ||
false == check_pass_fileid_key)
436 eherr <<
"Cannot obtain the SDS ID of " << fieldname;
437 throw InternalErr (__FILE__, __LINE__, eherr.str ());
441 char attrname[H4_MAX_NC_NAME + 1];
449 cf_general_attrindex = SDfindattr(sdsid,
"radiance_scales");
450 cf_general_attrindex2 = SDfindattr(sdsid,
"radiance_offsets");
453 if (cf_general_attrindex!=FAIL && cf_general_attrindex2!=FAIL)
456 ret = SDattrinfo(sdsid, cf_general_attrindex, attrname, &attr_dtype, &temp_attrcount);
460 if (
true == isgeofile)
463 eherr <<
"Attribute 'radiance_scales' in " << fieldname.c_str () <<
" cannot be obtained.";
464 throw InternalErr (__FILE__, __LINE__, eherr.str ());
467 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
468 ret = SDreadattr(sdsid, cf_general_attrindex, (VOIDP)attrbuf.data());
471 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
473 if (
true == isgeofile)
476 eherr <<
"Attribute 'radiance_scales' in " << fieldname.c_str () <<
" cannot be obtained.";
477 throw InternalErr (__FILE__, __LINE__, eherr.str ());
479 ret = SDattrinfo(sdsid, cf_general_attrindex2, attrname, &attr_dtype, &temp_attrcount);
482 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
484 if (
true == isgeofile)
487 eherr <<
"Attribute 'radiance_offsets' in " << fieldname.c_str () <<
" cannot be obtained.";
488 throw InternalErr (__FILE__, __LINE__, eherr.str ());
491 attrbuf2.resize(DFKNTsize(attr_dtype)*temp_attrcount);
492 ret = SDreadattr(sdsid, cf_general_attrindex2, (VOIDP)attrbuf2.data());
495 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
497 if (
true == isgeofile)
500 eherr <<
"Attribute 'radiance_offsets' in " << fieldname.c_str () <<
" cannot be obtained.";
501 throw InternalErr (__FILE__, __LINE__, eherr.str ());
508#define GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES(TYPE, CAST) \
511 CAST *ptr = (CAST*)attrbuf.data(); \
512 CAST *ptr2 = (CAST*)attrbuf2.data(); \
513 radiance_scales = new float[temp_attrcount]; \
514 radiance_offsets = new float[temp_attrcount]; \
515 for(int l=0; l<temp_attrcount; l++) \
517 radiance_scales[l] = ptr[l]; \
518 radiance_offsets[l] = ptr2[l]; \
522 GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT32,
float);
523 GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT64,
double);
525#undef GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES
526 num_eles_of_an_attr = temp_attrcount;
530 cf_general_attrindex = SDfindattr(sdsid,
"reflectance_scales");
531 cf_general_attrindex2 = SDfindattr(sdsid,
"reflectance_offsets");
532 if (cf_general_attrindex!=FAIL && cf_general_attrindex2!=FAIL)
535 ret = SDattrinfo(sdsid, cf_general_attrindex, attrname, &attr_dtype, &temp_attrcount);
538 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
540 if (
true == isgeofile)
543 eherr <<
"Attribute 'reflectance_scales' in " << fieldname.c_str () <<
" cannot be obtained.";
544 throw InternalErr (__FILE__, __LINE__, eherr.str ());
547 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
548 ret = SDreadattr(sdsid, cf_general_attrindex, (VOIDP)attrbuf.data());
551 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
553 if (
true == isgeofile)
556 eherr <<
"Attribute 'reflectance_scales' in " << fieldname.c_str () <<
" cannot be obtained.";
557 throw InternalErr (__FILE__, __LINE__, eherr.str ());
560 ret = SDattrinfo(sdsid, cf_general_attrindex2, attrname, &attr_dtype, &temp_attrcount);
563 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
565 if (
true == isgeofile)
568 eherr <<
"Attribute 'reflectance_offsets' in " << fieldname.c_str () <<
" cannot be obtained.";
569 throw InternalErr (__FILE__, __LINE__, eherr.str ());
572 attrbuf2.resize(DFKNTsize(attr_dtype)*temp_attrcount);
573 ret = SDreadattr(sdsid, cf_general_attrindex2, (VOIDP)attrbuf2.data());
576 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
578 if (
true == isgeofile)
581 eherr <<
"Attribute 'reflectance_offsets' in " << fieldname.c_str () <<
" cannot be obtained.";
582 throw InternalErr (__FILE__, __LINE__, eherr.str ());
586#define GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES(TYPE, CAST) \
589 CAST *ptr = (CAST*)attrbuf.data(); \
590 CAST *ptr2 = (CAST*)attrbuf2.data(); \
591 reflectance_scales = new float[temp_attrcount]; \
592 reflectance_offsets = new float[temp_attrcount]; \
593 for(int l=0; l<temp_attrcount; l++) \
595 reflectance_scales[l] = ptr[l]; \
596 reflectance_offsets[l] = ptr2[l]; \
600 GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT32,
float);
601 GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT64,
double);
603#undef GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES
604 num_eles_of_an_attr = temp_attrcount;
609 scale_factor_attr_index = SDfindattr(sdsid,
"scale_factor");
610 if (scale_factor_attr_index!=FAIL)
613 ret = SDattrinfo(sdsid, scale_factor_attr_index, attrname,
614 &attr_dtype, &temp_attrcount);
618 if (
true == isgeofile ||
false == check_pass_fileid_key)
621 eherr <<
"Attribute 'scale_factor' in "
622 << fieldname.c_str () <<
" cannot be obtained.";
623 throw InternalErr (__FILE__, __LINE__, eherr.str ());
626 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
627 ret = SDreadattr(sdsid, scale_factor_attr_index, (VOIDP)attrbuf.data());
631 if (
true == isgeofile ||
false == check_pass_fileid_key)
635 eherr <<
"Attribute 'scale_factor' in "
636 << fieldname.c_str () <<
" cannot be obtained.";
637 throw InternalErr (__FILE__, __LINE__, eherr.str ());
642#define GET_SCALE_FACTOR_ATTR_VALUE(TYPE, CAST) \
645 CAST tmpvalue = *(CAST*)attrbuf.data(); \
646 scale = (float)tmpvalue; \
649 GET_SCALE_FACTOR_ATTR_VALUE(INT8, int8)
650 GET_SCALE_FACTOR_ATTR_VALUE(CHAR,int8)
651 GET_SCALE_FACTOR_ATTR_VALUE(UINT8, uint8)
652 GET_SCALE_FACTOR_ATTR_VALUE(UCHAR,uint8)
653 GET_SCALE_FACTOR_ATTR_VALUE(INT16, int16)
654 GET_SCALE_FACTOR_ATTR_VALUE(UINT16, uint16)
655 GET_SCALE_FACTOR_ATTR_VALUE(INT32, int32)
656 GET_SCALE_FACTOR_ATTR_VALUE(UINT32, uint32)
657 GET_SCALE_FACTOR_ATTR_VALUE(FLOAT32,
float)
658 GET_SCALE_FACTOR_ATTR_VALUE(FLOAT64,
double)
660 throw InternalErr(__FILE__,__LINE__,
"unsupported data type.");
664#undef GET_SCALE_FACTOR_ATTR_VALUE
668 add_offset_attr_index = SDfindattr(sdsid,
"add_offset");
669 if (add_offset_attr_index!=FAIL)
672 ret = SDattrinfo(sdsid, add_offset_attr_index, attrname,
673 &attr_dtype, &temp_attrcount);
677 if (
true == isgeofile ||
false == check_pass_fileid_key)
681 eherr <<
"Attribute 'add_offset' in " << fieldname.c_str ()
682 <<
" cannot be obtained.";
683 throw InternalErr (__FILE__, __LINE__, eherr.str ());
686 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
687 ret = SDreadattr(sdsid, add_offset_attr_index, (VOIDP)attrbuf.data());
691 if (
true == isgeofile ||
false == check_pass_fileid_key)
695 eherr <<
"Attribute 'add_offset' in " << fieldname.c_str ()
696 <<
" cannot be obtained.";
697 throw InternalErr (__FILE__, __LINE__, eherr.str ());
702#define GET_ADD_OFFSET_ATTR_VALUE(TYPE, CAST) \
705 CAST tmpvalue = *(CAST*)attrbuf.data(); \
706 field_offset = (float)tmpvalue; \
709 GET_ADD_OFFSET_ATTR_VALUE(INT8, int8)
710 GET_ADD_OFFSET_ATTR_VALUE(CHAR,int8)
711 GET_ADD_OFFSET_ATTR_VALUE(UINT8, uint8)
712 GET_ADD_OFFSET_ATTR_VALUE(UCHAR,uint8)
713 GET_ADD_OFFSET_ATTR_VALUE(INT16, int16)
714 GET_ADD_OFFSET_ATTR_VALUE(UINT16, uint16)
715 GET_ADD_OFFSET_ATTR_VALUE(INT32, int32)
716 GET_ADD_OFFSET_ATTR_VALUE(UINT32, uint32)
717 GET_ADD_OFFSET_ATTR_VALUE(FLOAT32,
float)
718 GET_ADD_OFFSET_ATTR_VALUE(FLOAT64,
double)
720 throw InternalErr(__FILE__,__LINE__,
"unsupported data type.");
723#undef GET_ADD_OFFSET_ATTR_VALUE
727 cf_fv_attrindex = SDfindattr(sdsid,
"_FillValue");
728 if (cf_fv_attrindex!=FAIL)
731 ret = SDattrinfo(sdsid, cf_fv_attrindex, attrname, &attr_dtype, &temp_attrcount);
735 if (
true == isgeofile ||
false == check_pass_fileid_key)
739 eherr <<
"Attribute '_FillValue' in " << fieldname.c_str ()
740 <<
" cannot be obtained.";
741 throw InternalErr (__FILE__, __LINE__, eherr.str ());
744 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
745 ret = SDreadattr(sdsid, cf_fv_attrindex, (VOIDP)attrbuf.data());
749 if (
true == isgeofile ||
false == check_pass_fileid_key)
753 eherr <<
"Attribute '_FillValue' in " << fieldname.c_str ()
754 <<
" cannot be obtained.";
755 throw InternalErr (__FILE__, __LINE__, eherr.str ());
760#define GET_FILLVALUE_ATTR_VALUE(TYPE, CAST) \
763 CAST tmpvalue = *(CAST*)attrbuf.data(); \
764 fillvalue = (float)tmpvalue; \
767 GET_FILLVALUE_ATTR_VALUE(INT8, int8)
768 GET_FILLVALUE_ATTR_VALUE(CHAR, int8)
769 GET_FILLVALUE_ATTR_VALUE(INT16, int16)
770 GET_FILLVALUE_ATTR_VALUE(INT32, int32)
771 GET_FILLVALUE_ATTR_VALUE(UINT8, uint8)
772 GET_FILLVALUE_ATTR_VALUE(UCHAR, uint8)
773 GET_FILLVALUE_ATTR_VALUE(UINT16, uint16)
774 GET_FILLVALUE_ATTR_VALUE(UINT32, uint32)
776 throw InternalErr(__FILE__,__LINE__,
"unsupported data type.");
779#undef GET_FILLVALUE_ATTR_VALUE
785 cf_vr_attrindex = SDfindattr(sdsid,
"valid_range");
786 if (cf_vr_attrindex!=FAIL)
789 ret = SDattrinfo(sdsid, cf_vr_attrindex, attrname, &attr_dtype, &temp_attrcount);
793 if (
true == isgeofile ||
false == check_pass_fileid_key)
797 eherr <<
"Attribute '_FillValue' in " << fieldname.c_str ()
798 <<
" cannot be obtained.";
799 throw InternalErr (__FILE__, __LINE__, eherr.str ());
802 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
803 ret = SDreadattr(sdsid, cf_vr_attrindex, (VOIDP)attrbuf.data());
807 if (
true == isgeofile ||
false == check_pass_fileid_key)
811 eherr <<
"Attribute '_FillValue' in " << fieldname.c_str ()
812 <<
" cannot be obtained.";
813 throw InternalErr (__FILE__, __LINE__, eherr.str ());
817 string attrbuf_str(attrbuf.begin(),attrbuf.end());
825 size_t found = attrbuf_str.find_first_of(
",");
826 size_t found_from_end = attrbuf_str.find_last_of(
",");
828 if (string::npos == found){
830 if (
true == isgeofile ||
false == check_pass_fileid_key)
832 throw InternalErr(__FILE__,__LINE__,
"should find the separator ,");
834 if (found != found_from_end){
836 if (
true == isgeofile ||
false == check_pass_fileid_key)
838 throw InternalErr(__FILE__,__LINE__,
839 "Only one separator , should be available.");
842 orig_valid_min = (float)(atof((attrbuf_str.substr(0,found)).c_str()));
843 orig_valid_max = (float)(atof((attrbuf_str.substr(found+1)).c_str()));
857 if (temp_attrcount >2) {
859 size_t found = attrbuf_str.find_first_of(
",");
860 size_t found_from_end = attrbuf_str.find_last_of(
",");
862 if (string::npos == found){
864 if (
true == isgeofile ||
false == check_pass_fileid_key)
866 throw InternalErr(__FILE__,__LINE__,
"should find the separator ,");
868 if (found != found_from_end){
870 if (
true == isgeofile ||
false == check_pass_fileid_key)
872 throw InternalErr(__FILE__,__LINE__,
873 "Only one separator , should be available.");
876 orig_valid_min = (float)(atof((attrbuf_str.substr(0,found)).c_str()));
877 orig_valid_max = (float)(atof((attrbuf_str.substr(found+1)).c_str()));
880 else if (2 == temp_attrcount) {
881 orig_valid_min = (float)attrbuf[0];
882 orig_valid_max = (float)attrbuf[1];
886 if (
true == isgeofile ||
false == check_pass_fileid_key)
888 throw InternalErr(__FILE__,__LINE__,
889 "The number of attribute count should be greater than 1.");
898 if (temp_attrcount != 2) {
900 if (
true == isgeofile ||
false == check_pass_fileid_key)
903 throw InternalErr(__FILE__,__LINE__,
904 "The number of attribute count should be 2 for the DFNT_UINT8 type.");
907 auto temp_valid_range = (
unsigned char *)attrbuf.data();
908 orig_valid_min = (float)(temp_valid_range[0]);
909 orig_valid_max = (float)(temp_valid_range[1]);
915 if (temp_attrcount != 2) {
917 if (
true == isgeofile ||
false == check_pass_fileid_key)
920 throw InternalErr(__FILE__,__LINE__,
921 "The number of attribute count should be 2 for the DFNT_INT16 type.");
924 auto temp_valid_range = (
short *)attrbuf.data();
925 orig_valid_min = (float)(temp_valid_range[0]);
926 orig_valid_max = (float)(temp_valid_range[1]);
932 if (temp_attrcount != 2) {
934 if (
true == isgeofile ||
false == check_pass_fileid_key)
937 throw InternalErr(__FILE__,__LINE__,
938 "The number of attribute count should be 2 for the DFNT_UINT16 type.");
941 auto temp_valid_range = (
unsigned short *)attrbuf.data();
942 orig_valid_min = (float)(temp_valid_range[0]);
943 orig_valid_max = (float)(temp_valid_range[1]);
949 if (temp_attrcount != 2) {
951 if (
true == isgeofile ||
false == check_pass_fileid_key)
954 throw InternalErr(__FILE__,__LINE__,
955 "The number of attribute count should be 2 for the DFNT_INT32 type.");
958 auto temp_valid_range = (
int *)attrbuf.data();
959 orig_valid_min = (float)(temp_valid_range[0]);
960 orig_valid_max = (float)(temp_valid_range[1]);
966 if (temp_attrcount != 2) {
968 if (
true == isgeofile ||
false == check_pass_fileid_key)
971 throw InternalErr(__FILE__,__LINE__,
972 "The number of attribute count should be 2 for the DFNT_UINT32 type.");
975 auto temp_valid_range = (
unsigned int *)attrbuf.data();
976 orig_valid_min = (float)(temp_valid_range[0]);
977 orig_valid_max = (float)(temp_valid_range[1]);
983 if (temp_attrcount != 2) {
985 if (
true == isgeofile ||
false == check_pass_fileid_key)
988 throw InternalErr(__FILE__,__LINE__,
989 "The number of attribute count should be 2 for the DFNT_FLOAT32 type.");
992 auto temp_valid_range = (
float *)attrbuf.data();
993 orig_valid_min = temp_valid_range[0];
994 orig_valid_max = temp_valid_range[1];
1000 if (temp_attrcount != 2){
1002 if (
true == isgeofile ||
false == check_pass_fileid_key)
1005 throw InternalErr(__FILE__,__LINE__,
1006 "The number of attribute count should be 2 for the DFNT_FLOAT64 type.");
1008 auto temp_valid_range = (
double *)attrbuf.data();
1015 orig_valid_min = (float)temp_valid_range[0];
1016 orig_valid_max = (float)temp_valid_range[1];
1021 if (
true == isgeofile ||
false == check_pass_fileid_key)
1023 throw InternalErr(__FILE__,__LINE__,
"Unsupported data type.");
1033 int32 cf_mod_key_attrindex = SUCCEED;
1034 cf_mod_key_attrindex = SDfindattr(sdsid,
"Key");
1035 if (cf_mod_key_attrindex !=FAIL) {
1036 has_Key_attr =
true;
1048 cf_modl1b_rr_attrindex = SDfindattr(sdsid,
"radiance_scales");
1049 cf_modl1b_rr_attrindex2 = SDfindattr(sdsid,
"radiance_offsets");
1052 if (cf_modl1b_rr_attrindex!=FAIL && cf_modl1b_rr_attrindex2!=FAIL)
1055 ret = SDattrinfo(sdsid, cf_modl1b_rr_attrindex, attrname,
1056 &attr_dtype, &temp_attrcount);
1060 if (
true == isgeofile ||
false == check_pass_fileid_key)
1063 eherr <<
"Attribute 'radiance_scales' in " << fieldname.c_str ()
1064 <<
" cannot be obtained.";
1065 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1068 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
1069 ret = SDreadattr(sdsid, cf_modl1b_rr_attrindex, (VOIDP)attrbuf.data());
1073 if (
true == isgeofile ||
false == check_pass_fileid_key)
1076 eherr <<
"Attribute 'radiance_scales' in " << fieldname.c_str ()
1077 <<
" cannot be obtained.";
1078 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1080 ret = SDattrinfo(sdsid, cf_modl1b_rr_attrindex2, attrname,
1081 &attr_dtype, &temp_attrcount);
1085 if (
true == isgeofile ||
false == check_pass_fileid_key)
1088 eherr <<
"Attribute 'radiance_offsets' in "
1089 << fieldname.c_str () <<
" cannot be obtained.";
1090 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1093 attrbuf2.resize(DFKNTsize(attr_dtype)*temp_attrcount);
1094 ret = SDreadattr(sdsid, cf_modl1b_rr_attrindex2, (VOIDP)attrbuf2.data());
1098 if (
true == isgeofile ||
false == check_pass_fileid_key)
1101 eherr <<
"Attribute 'radiance_offsets' in "
1102 << fieldname.c_str () <<
" cannot be obtained.";
1103 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1111#define GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES(TYPE, CAST) \
1114 CAST *ptr = (CAST*)attrbuf.data(); \
1115 CAST *ptr2 = (CAST*)attrbuf2.data(); \
1116 radiance_scales = new float[temp_attrcount]; \
1117 radiance_offsets = new float[temp_attrcount]; \
1118 for(int l=0; l<temp_attrcount; l++) \
1120 radiance_scales[l] = ptr[l]; \
1121 radiance_offsets[l] = ptr2[l]; \
1125 GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT32,
float)
1126 GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT64,
double)
1128 throw InternalErr(__FILE__,__LINE__,
"unsupported data type.");
1131#undef GET_RADIANCE_SCALES_OFFSETS_ATTR_VALUES
1133 num_eles_of_an_attr = temp_attrcount;
1138 cf_modl1b_rr_attrindex = SDfindattr(sdsid,
"reflectance_scales");
1139 cf_modl1b_rr_attrindex2 = SDfindattr(sdsid,
"reflectance_offsets");
1140 if (cf_modl1b_rr_attrindex!=FAIL && cf_modl1b_rr_attrindex2!=FAIL)
1143 ret = SDattrinfo(sdsid, cf_modl1b_rr_attrindex, attrname,
1144 &attr_dtype, &temp_attrcount);
1147 release_mod1b_res(reflectance_scales,reflectance_offsets,
1148 radiance_scales,radiance_offsets);
1150 if (
true == isgeofile ||
false == check_pass_fileid_key)
1153 eherr <<
"Attribute 'reflectance_scales' in "
1154 << fieldname.c_str () <<
" cannot be obtained.";
1155 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1158 attrbuf.resize(DFKNTsize(attr_dtype)*temp_attrcount);
1159 ret = SDreadattr(sdsid, cf_modl1b_rr_attrindex, (VOIDP)attrbuf.data());
1162 release_mod1b_res(reflectance_scales,reflectance_offsets,
1163 radiance_scales,radiance_offsets);
1165 if (
true == isgeofile ||
false == check_pass_fileid_key)
1168 eherr <<
"Attribute 'reflectance_scales' in "
1169 << fieldname.c_str () <<
" cannot be obtained.";
1170 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1173 ret = SDattrinfo(sdsid, cf_modl1b_rr_attrindex2, attrname,
1174 &attr_dtype, &temp_attrcount);
1177 release_mod1b_res(reflectance_scales,reflectance_offsets,
1178 radiance_scales,radiance_offsets);
1180 if (
true == isgeofile ||
false == check_pass_fileid_key)
1183 eherr <<
"Attribute 'reflectance_offsets' in "
1184 << fieldname.c_str () <<
" cannot be obtained.";
1185 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1188 attrbuf2.resize(DFKNTsize(attr_dtype)*temp_attrcount);
1189 ret = SDreadattr(sdsid, cf_modl1b_rr_attrindex2, (VOIDP)attrbuf2.data());
1192 release_mod1b_res(reflectance_scales,reflectance_offsets,
1193 radiance_scales,radiance_offsets);
1195 if (
true == isgeofile ||
false == check_pass_fileid_key)
1198 eherr <<
"Attribute 'reflectance_offsets' in "
1199 << fieldname.c_str () <<
" cannot be obtained.";
1200 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1204#define GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES(TYPE, CAST) \
1207 CAST *ptr = (CAST*)attrbuf.data(); \
1208 CAST *ptr2 = (CAST*)attrbuf2.data(); \
1209 reflectance_scales = new float[temp_attrcount]; \
1210 reflectance_offsets = new float[temp_attrcount]; \
1211 for(int l=0; l<temp_attrcount; l++) \
1213 reflectance_scales[l] = ptr[l]; \
1214 reflectance_offsets[l] = ptr2[l]; \
1218 GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT32,
float)
1219 GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES(FLOAT64,
double)
1221 throw InternalErr(__FILE__,__LINE__,
"unsupported data type.");
1224#undef GET_REFLECTANCE_SCALES_OFFSETS_ATTR_VALUES
1225 num_eles_of_an_attr = temp_attrcount;
1230 BESDEBUG(
"h4",
"scale is "<<scale <<endl);
1231 BESDEBUG(
"h4",
"offset is "<<field_offset <<endl);
1232 BESDEBUG(
"h4",
"fillvalue is "<<fillvalue <<endl);
1261 if (SOType::MODIS_EQ_SCALE == sotype || SOType::MODIS_MUL_SCALE == sotype) {
1263 bool need_change_scale =
true;
1266 string temp_filename;
1267 if (filename.find(
"#") != string::npos)
1268 temp_filename =filename.substr(filename.find_last_of(
"#") + 1);
1270 temp_filename = filename.substr(filename.find_last_of(
"/") +1);
1272 if ((temp_filename.size() >5) && ((temp_filename.compare(0,5,
"MOD09") == 0)
1273 ||(temp_filename.compare(0,5,
"MYD09") == 0))) {
1274 if ((fieldname.size() >5) && fieldname.compare(0,5,
"Range") == 0)
1275 need_change_scale =
false;
1278 else if ((temp_filename.size() >7)&&
1279 ((temp_filename.compare(0,7,
"MOD16A2") == 0)|| (temp_filename.compare(0,7,
"MYD16A2")==0)||
1280 (temp_filename.compare(0,7,
"MOD16A3") == 0)|| (temp_filename.compare(0,7,
"MYD16A3")==0)))
1281 need_change_scale =
false;
1285 if (
true == need_change_scale) {
1286 sotype = SOType::MODIS_DIV_SCALE;
1287 INFO_LOG(
"The field " + fieldname +
" scale factor is "
1288 + std::to_string(scale) +
" . But the original scale factor type is MODIS_MUL_SCALE"
1289 +
" or MODIS_EQ_SCALE. Now change it to MODIS_DIV_SCALE.");
1294 if (SOType::MODIS_DIV_SCALE == sotype) {
1296 sotype = SOType::MODIS_MUL_SCALE;
1297 INFO_LOG(
"The field " + fieldname +
" scale factor is "
1298 + std::to_string(scale) +
". But the original scale factor type is MODIS_DIV_SCALE. "
1299 +
" Now change it to MODIS_MUL_SCALE.");
1331#define RECALCULATE(CAST, DODS_CAST, VAL) \
1333 bool change_data_value = false; \
1334 if (sotype!=SOType::DEFAULT_CF_EQU) \
1336 vector<float>tmpval; \
1337 tmpval.resize(nelms); \
1338 CAST tmptr = (CAST)VAL; \
1339 for(int l=0; l<nelms; l++) \
1340 tmpval[l] = (float)tmptr[l]; \
1341 bool special_case = false; \
1342 if (scale_factor_attr_index==FAIL) \
1343 if (num_eles_of_an_attr==1) \
1344 if ((radiance_scales!=nullptr) && (radiance_offsets!=nullptr)) \
1346 scale = radiance_scales[0]; \
1347 field_offset = radiance_offsets[0];\
1348 special_case = true; \
1350 if (((scale_factor_attr_index!=FAIL) && !((scale==1) && (field_offset==0))) || special_case) \
1352 float temp_scale = scale; \
1353 float temp_offset = field_offset; \
1354 if (sotype==SOType::MODIS_MUL_SCALE) \
1355 temp_offset = -1. *field_offset*temp_scale;\
1356 else if (sotype==SOType::MODIS_DIV_SCALE) \
1358 temp_scale = 1/scale; \
1359 temp_offset = -1. *field_offset*temp_scale;\
1361 for(int l=0; l<nelms; l++) \
1363 if (cf_vr_attrindex!=FAIL) \
1365 if ((float)tmptr[l] != fillvalue ) \
1367 if (false == HDFCFUtil::is_special_value(field_dtype,fillvalue,tmptr[l]))\
1369 if (((orig_valid_min<=tmpval[l]) && (orig_valid_max>=tmpval[l])) || (true==has_Key_attr))\
1371 tmpval[l] = tmptr[l]*temp_scale + temp_offset; \
1377 change_data_value = true; \
1378 set_value((dods_float32 *)tmpval.data(), nelms); \
1379 } else if ((num_eles_of_an_attr>1) && (((radiance_scales!=nullptr) && (radiance_offsets!=nullptr)) || ((reflectance_scales!=nullptr) && (reflectance_offsets!=nullptr)))) \
1381 size_t dimindex=0; \
1382 if ( num_eles_of_an_attr!=tmp_dims[dimindex]) \
1384 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets); \
1385 ostringstream eherr; \
1386 eherr << "The number of Z-Dimension scale attribute is not equal to the size of the first dimension in " << fieldname.c_str() << ". These two values must be equal."; \
1387 throw InternalErr (__FILE__, __LINE__, eherr.str ()); \
1389 size_t start_index, end_index; \
1390 size_t nr_elems = nelms/count32[dimindex]; \
1391 start_index = offset32[dimindex]; \
1392 end_index = start_index+step32[dimindex]*(count32[dimindex]-1); \
1394 for(size_t k=start_index; k<=end_index; k+=step32[dimindex]) \
1396 float tmpscale = (fieldname.find("Emissive")!=string::npos)? radiance_scales[k]: reflectance_scales[k]; \
1397 float tmpoffset = (fieldname.find("Emissive")!=string::npos)? radiance_offsets[k]: reflectance_offsets[k]; \
1398 for(size_t l=0; l<nr_elems; l++) \
1400 if (cf_vr_attrindex!=FAIL) \
1402 if (((float)tmptr[index])!=fillvalue) \
1404 if (false == HDFCFUtil::is_special_value(field_dtype,fillvalue,tmptr[index]))\
1406 if (sotype==SOType::MODIS_MUL_SCALE) \
1407 tmpval[index] = (tmptr[index]-tmpoffset)*tmpscale; \
1408 else if (sotype==SOType::MODIS_EQ_SCALE) \
1409 tmpval[index] = tmptr[index]*tmpscale+tmpoffset; \
1410 else if (sotype==SOType::MODIS_DIV_SCALE) \
1411 tmpval[index] = (tmptr[index]-tmpoffset)/tmpscale; \
1418 change_data_value = true; \
1419 set_value((dods_float32 *)tmpval.data(), nelms); \
1422 if (!change_data_value) \
1424 set_value ((DODS_CAST)VAL, nelms); \
1427 switch (field_dtype) {
1433 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1434 offset32.data(), step32.data(), count32.data(), val.data());
1436 release_mod1b_res(reflectance_scales,reflectance_offsets,
1437 radiance_scales,radiance_offsets);
1439 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1440 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1443#ifndef SIGNED_BYTE_TO_INT32
1444 RECALCULATE(int8*, dods_byte*, val.data());
1448 newval.resize(nelms);
1450 for (
int counter = 0; counter < nelms; counter++)
1451 newval[counter] = (int32) (val[counter]);
1453 RECALCULATE(int32*, dods_int32*, newval.data())
1463 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1464 offset32.data(), step32.data(), count32.data(), val.data());
1466 release_mod1b_res(reflectance_scales,reflectance_offsets,
1467 radiance_scales,radiance_offsets);
1470 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1471 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1474 RECALCULATE(uint8*, dods_byte*, val.data())
1482 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1483 offset32.data(), step32.data(), count32.data(), val.data());
1487 release_mod1b_res(reflectance_scales,reflectance_offsets,
1488 radiance_scales,radiance_offsets);
1491 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1492 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1494 RECALCULATE(int16*, dods_int16*, val.data())
1502 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1503 offset32.data(), step32.data(), count32.data(), val.data());
1505 release_mod1b_res(reflectance_scales,reflectance_offsets,
1506 radiance_scales,radiance_offsets);
1509 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1510 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1513 RECALCULATE(uint16*, dods_uint16*, val.data())
1520 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1521 offset32.data(), step32.data(), count32.data(), val.data());
1524 release_mod1b_res(reflectance_scales,reflectance_offsets,
1525 radiance_scales,radiance_offsets);
1528 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1529 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1532 RECALCULATE(int32*, dods_int32*, val.data())
1539 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1540 offset32.data(), step32.data(), count32.data(), val.data());
1543 release_mod1b_res(reflectance_scales,reflectance_offsets,
1544 radiance_scales,radiance_offsets);
1547 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1548 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1551 RECALCULATE(uint32*, dods_uint32*, val.data())
1558 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1559 offset32.data(), step32.data(), count32.data(), val.data());
1562 release_mod1b_res(reflectance_scales,reflectance_offsets,
1563 radiance_scales,radiance_offsets);
1566 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1567 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1571 RECALCULATE(float32*, dods_float32*, val.data())
1579 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1580 offset32.data(), step32.data(), count32.data(), val.data());
1583 release_mod1b_res(reflectance_scales,reflectance_offsets,
1584 radiance_scales,radiance_offsets);
1587 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1588 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1590 set_value ((dods_float64 *) val.data(), nelms);
1594 release_mod1b_res(reflectance_scales,reflectance_offsets,
1595 radiance_scales,radiance_offsets);
1596 throw InternalErr (__FILE__, __LINE__,
"unsupported data type.");
1599 release_mod1b_res(reflectance_scales,reflectance_offsets,radiance_scales,radiance_offsets);
1603 if (
true == isgeofile ||
false == check_pass_fileid_key)
1612HDFEOS2Array_RealField::write_dap_data_disable_scale_comp(int32 gridid,
1620 "Coming to HDFEOS2_Array_RealField: write_dap_data_disable_scale_comp"
1624 intn (*fieldinfofunc) (int32,
char *, int32 *, int32 *, int32 *,
char *);
1625 intn (*readfieldfunc) (int32,
char *, int32 *, int32 *, int32 *,
void *);
1628 if (swathname ==
"") {
1629 fieldinfofunc = GDfieldinfo;
1630 readfieldfunc = GDreadfield;
1633 else if (gridname ==
"") {
1634 fieldinfofunc = SWfieldinfo;
1635 readfieldfunc = SWreadfield;
1639 throw InternalErr (__FILE__, __LINE__,
"It should be either grid or swath.");
1645 char tmp_dimlist[1024];
1648 int32 tmp_dims[rank];
1651 int32 field_dtype = 0;
1658 r = fieldinfofunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1659 &tmp_rank, tmp_dims, &field_dtype, tmp_dimlist);
1662 eherr <<
"Field " << fieldname.c_str ()
1663 <<
" information cannot be obtained.";
1664 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1668 switch (field_dtype) {
1673 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1674 offset32, step32, count32, val.data());
1677 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1678 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1681#ifndef SIGNED_BYTE_TO_INT32
1682 set_value((dods_byte*)val.data(),nelms);
1686 newval.resize(nelms);
1688 for (
int counter = 0; counter < nelms; counter++)
1689 newval[counter] = (int32) (val[counter]);
1691 set_value((dods_int32*)newval.data(),nelms);
1701 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1702 offset32, step32, count32, val.data());
1706 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1707 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1710 set_value((dods_byte*)val.data(),nelms);
1718 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1719 offset32, step32, count32, val.data());
1723 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1724 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1726 set_value((dods_int16*)val.data(),nelms);
1733 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1734 offset32, step32, count32, val.data());
1737 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1738 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1741 set_value((dods_uint16*)val.data(),nelms);
1748 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1749 offset32, step32, count32, val.data());
1752 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1753 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1756 set_value((dods_int32*)val.data(),nelms);
1763 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1764 offset32, step32, count32, val.data());
1767 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1768 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1771 set_value((dods_uint32*)val.data(),nelms);
1778 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1779 offset32, step32, count32, val.data());
1782 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1783 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1787 set_value((dods_float32*)val.data(),nelms);
1794 r = readfieldfunc (gridid,
const_cast < char *
>(fieldname.c_str ()),
1795 offset32, step32, count32, val.data());
1798 eherr <<
"field " << fieldname.c_str () <<
"cannot be read.";
1799 throw InternalErr (__FILE__, __LINE__, eherr.str ());
1801 set_value ((dods_float64 *) val.data(), nelms);
1805 throw InternalErr (__FILE__, __LINE__,
"unsupported data type.");
1813HDFEOS2Array_RealField::format_constraint (
int *offset,
int *step,
int *count)
1818 Dim_iter p = dim_begin ();
1819 while (p != dim_end ()) {
1821 int start = dimension_start (p,
true);
1822 int stride = dimension_stride (p,
true);
1823 int stop = dimension_stop (p,
true);
1828 oss <<
"Array/Grid hyperslab start point "<< start <<
1829 " is greater than stop point " << stop <<
".";
1830 throw Error(malformed_expr, oss.str());
1835 count[id] = ((stop - start) / stride) + 1;
1839 "=format_constraint():"
1840 <<
"id=" <<
id <<
" offset=" << offset[
id]
1841 <<
" step=" << step[
id]
1842 <<
" count=" << count[
id]
1853void HDFEOS2Array_RealField::close_fileid(
const int gsfileid,
const int sdfileid)
const{
1855 if (
true == isgeofile ||
false == HDF4RequestHandler::get_pass_fileid()) {
1860 if (gsfileid != -1){
1871void HDFEOS2Array_RealField::release_mod1b_res(
float*ref_scale,
1876 if (ref_scale !=
nullptr)
1878 if (ref_offset !=
nullptr)
1879 delete[] ref_offset;
1880 if (rad_scale !=
nullptr)
1882 if (rad_offset !=
nullptr)
1883 delete[] rad_offset;