33 #include <sys/types.h>
59 #include "he5dds.tab.hh"
62 #include "he5das.tab.hh"
64 struct yy_buffer_state;
79 BESDEBUG(
"h5",
"Coming to HDF-EOS5 products DDS mapping function map_eos5_cfdds "<<endl);
85 string product_str=
"";
90 read_ecs_metadata(file_id,st_str,core_str,arch_str,xml_str, subset_str,product_str,other_str,st_only);
94 "unable to obtain the HDF-EOS5 struct metadata ";
95 throw InternalErr(__FILE__, __LINE__, msg);
98 string check_objnameclashing_key =
"H5.EnableCheckNameClashing";
99 bool is_check_nameclashing =
false;
105 f =
new EOS5File(filename.c_str(),file_id);
108 throw InternalErr(__FILE__,__LINE__,
"Cannot allocate the file object.");
111 bool include_attr =
false;
127 throw InternalErr(
"Unknown HDF-EOS5 grid paramters found in the file");
131 throw InternalErr(
"The HDF-EOS5 is missing project code ");
135 throw InternalErr(
"The current project code is not supported");
160 throw InternalErr(e.
what());
197 if(
true == is_check_nameclashing)
205 if(
true == is_check_nameclashing)
216 throw InternalErr(e.
what());
234 BESDEBUG(
"h5",
"Coming to HDF-EOS5 products DAS mapping function map_eos5_cfdas "<<endl);
239 string subset_str=
"";
240 string product_str=
"";
241 string other_str =
"";
244 read_ecs_metadata(file_id,st_str,core_str,arch_str,xml_str, subset_str,product_str,other_str,st_only);
248 "unable to obtain the HDF-EOS5 struct metadata ";
249 throw InternalErr(__FILE__, __LINE__, msg);
252 string check_objnameclashing_key =
"H5.EnableCheckNameClashing";
253 bool is_check_nameclashing =
false;
256 string add_path_attrs_key =
"H5.EnableAddPathAttrs";
257 bool is_add_path_attrs =
false;
262 f =
new EOS5File(filename.c_str(),file_id);
265 throw InternalErr(__FILE__,__LINE__,
"Cannot allocate the file object.");
267 bool include_attr =
true;
282 throw InternalErr(
"Unknown HDF-EOS5 grid paramters found in the file");
286 throw InternalErr(
"The HDF-EOS5 is missing project code ");
290 throw InternalErr(
"The current project code is not supported");
305 throw InternalErr(e.
what());
331 if (
true == is_check_nameclashing)
346 throw InternalErr(e.
what());
366 BESDEBUG(
"h5",
"Coming to HDF-EOS5 products DDS generation function gen_eos5_cfdds "<<endl);
367 const vector<HDF5CF::Var *>& vars = f->
getVars();
368 const vector<HDF5CF::EOS5CVar *>& cvars = f->
getCVars();
369 const string filename = f->
getPath();
373 vector<HDF5CF::Var *>::const_iterator it_v;
374 vector<HDF5CF::EOS5CVar *>::const_iterator it_cv;
376 for (it_v = vars.begin(); it_v !=vars.end();++it_v) {
381 for (it_cv = cvars.begin(); it_cv !=cvars.end();++it_cv) {
395 #define HANDLE_CASE(tid,type) \
397 bt = new (type)(cvar->getNewName(),cvar->getFullPath()); \
411 throw InternalErr(__FILE__,__LINE__,
"unsupported data type.");
417 const vector<HDF5CF::Dimension *>& dims = cvar->
getDimensions();
418 vector <HDF5CF::Dimension*>:: const_iterator it_d;
437 throw InternalErr(__FILE__,__LINE__,
"unable to allocate memory for HDF5CFArray.");
440 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
441 if (
""==(*it_d)->getNewName())
442 ar->append_dim((*it_d)->getSize());
444 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
479 throw InternalErr(__FILE__,__LINE__,
"unable to allocate memory for HDFEOS5CFMissLLArray.");
482 for(it_d = dims.begin(); it_d != dims.end(); ++it_d) {
483 if (
""==(*it_d)->getNewName())
484 ar->append_dim((*it_d)->getSize());
486 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
500 throw InternalErr(__FILE__, __LINE__,
"The rank of missing Z dimension field must be 1");
514 throw InternalErr(__FILE__,__LINE__,
"unable to allocate memory for HDFEOS5CFMissNonLLCVArray.");
518 for(it_d = dims.begin(); it_d != dims.end(); it_d++) {
519 if (
""==(*it_d)->getNewName())
520 ar->append_dim((*it_d)->getSize());
522 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
537 throw InternalErr(__FILE__, __LINE__,
"The rank of missing Z dimension field must be 1");
555 throw InternalErr(__FILE__,__LINE__,
"unable to allocate memory for HDF5CFArray.");
559 for(it_d = dims.begin(); it_d != dims.end(); ++it_d){
560 if (
""==(*it_d)->getNewName())
561 ar->append_dim((*it_d)->getSize());
563 ar->append_dim((*it_d)->getSize(), (*it_d)->getNewName());
573 throw InternalErr(__FILE__,__LINE__,
"Unsupported coordinate variable type.");
583 BESDEBUG(
"h5",
"Coming to HDF-EOS5 products DAS generation function gen_eos5_cfdas "<<endl);
586 const vector<HDF5CF::Var *>& vars = f->
getVars();
587 const vector<HDF5CF::EOS5CVar *>& cvars = f->
getCVars();
588 const vector<HDF5CF::Group *>& grps = f->
getGroups();
589 const vector<HDF5CF::Attribute *>& root_attrs = f->
getAttributes();
591 vector<HDF5CF::Var *>::const_iterator it_v;
592 vector<HDF5CF::EOS5CVar *>::const_iterator it_cv;
593 vector<HDF5CF::Group *>::const_iterator it_g;
594 vector<HDF5CF::Attribute *>::const_iterator it_ra;
598 if (
false == root_attrs.empty()) {
599 AttrTable *at = das.get_table(FILE_ATTR_TABLE_NAME);
601 at = das.add_table(FILE_ATTR_TABLE_NAME,
new AttrTable);
603 for (it_ra = root_attrs.begin(); it_ra != root_attrs.end(); it_ra++) {
608 if (
false == grps.empty()) {
609 for (it_g = grps.begin();
610 it_g != grps.end(); ++it_g) {
611 AttrTable *at = das.get_table((*it_g)->getNewName());
613 at = das.add_table((*it_g)->getNewName(),
new AttrTable);
615 for (it_ra = (*it_g)->getAttributes().begin();
616 it_ra != (*it_g)->getAttributes().end(); ++it_ra) {
622 for (it_v = vars.begin();
623 it_v != vars.end(); ++it_v) {
624 if (
false == ((*it_v)->getAttributes().empty())) {
626 AttrTable *at = das.get_table((*it_v)->getNewName());
628 at = das.add_table((*it_v)->getNewName(),
new AttrTable);
630 for (it_ra = (*it_v)->getAttributes().begin();
631 it_ra != (*it_v)->getAttributes().end(); ++it_ra) {
637 for (it_cv = cvars.begin(); it_cv !=cvars.end();it_cv++) {
640 if (
false == ((*it_cv)->getAttributes().empty())) {
642 AttrTable *at = das.get_table((*it_cv)->getNewName());
644 at = das.add_table((*it_cv)->getNewName(),
new AttrTable);
646 for (it_ra = (*it_cv)->getAttributes().begin();
647 it_ra != (*it_cv)->getAttributes().end(); ++it_ra) {
661 string subset_str=
"";
662 string product_str=
"";
663 string other_str =
"";
664 bool st_only =
false;
667 subset_str, product_str, other_str, st_only);
670 if(st_str!=
"") cerr <<
"Final structmetadata "<<st_str <<endl;
671 if(core_str!=
"") cerr <<
"Final coremetadata "<<core_str <<endl;
672 if(arch_str!=
"") cerr <<
"Final archivedmetadata "<<arch_str <<endl;
673 if(xml_str!=
"") cerr <<
"Final xmlmetadata "<<xml_str <<endl;
674 if(subset_str!=
"") cerr <<
"Final subsetmetadata "<<subset_str <<endl;
675 if(product_str!=
"") cerr <<
"Final productmetadata "<<product_str <<endl;
676 if(other_str!=
"") cerr <<
"Final othermetadata "<<other_str <<endl;
681 string check_disable_smetadata_key =
"H5.DisableStructMetaAttr";
682 bool is_check_disable_smetadata =
false;
685 if (
false == is_check_disable_smetadata) {
687 AttrTable *at = das.get_table(
"StructMetadata");
689 at = das.add_table(
"StructMetadata",
new AttrTable);
694 ||
false == arg.status()){
697 <<
"StructMetadata " <<
" HDFEOS attribute" << endl;
707 AttrTable *at = das.get_table(
"CoreMetadata");
709 at = das.add_table(
"CoreMetadata",
new AttrTable);
713 ||
false == arg.status()){
716 <<
"CoreMetadata " <<
" HDFEOS attribute" << endl;
723 AttrTable *at = das.get_table(
"ArchiveMetadata");
725 at = das.add_table(
"ArchiveMetadata",
new AttrTable);
729 ||
false == arg.status()){
732 <<
"ArchiveMetadata " <<
" HDFEOS attribute" << endl;
742 AttrTable *at = das.get_table(
"XMLMetadata");
744 at = das.add_table(
"XMLMetadata",
new AttrTable);
746 at->append_attr(
"Contents",
"String",xml_str);
752 if(subset_str !=
""){
753 AttrTable *at = das.get_table(
"SubsetMetadata");
755 at = das.add_table(
"SubsetMetadata",
new AttrTable);
759 ||
false == arg.status()) {
762 <<
"SubsetMetadata " <<
" HDFEOS attribute" << endl;
767 if(product_str !=
""){
768 AttrTable *at = das.get_table(
"ProductMetadata");
770 at = das.add_table(
"ProductMetadata",
new AttrTable);
774 ||
false == arg.status()){
776 <<
"ProductMetadata " <<
" HDFEOS attribute" << endl;
785 if (other_str !=
""){
786 AttrTable *at = das.get_table(
"OtherMetadata");
788 at = das.add_table(
"OtherMetadata",
new AttrTable);
789 at->append_attr(
"Contents",
"String",other_str);
796 string &total_strmeta_value,
797 string &total_coremeta_value,
798 string &total_archmeta_value,
799 string &total_xmlmeta_value,
800 string &total_submeta_value,
801 string &total_prometa_value,
802 string &total_othermeta_value,
805 string ecs_group =
"/HDFEOS INFORMATION";
806 hid_t ecs_grp_id = -1;
807 if ((ecs_grp_id = H5Gopen(s_file_id, ecs_group.c_str(),H5P_DEFAULT))<0) {
810 "h5_ecs_meta: unable to open the HDF5 group ";
813 throw InternalErr(__FILE__, __LINE__, msg);
819 if (H5Gget_info(ecs_grp_id,&g_info) <0) {
821 "h5_ecs_meta: unable to obtain the HDF5 group info. for ";
823 H5Gclose(ecs_grp_id);
825 throw InternalErr(__FILE__, __LINE__, msg);
828 nelems = g_info.nlinks;
830 ssize_t oname_size = 0;
832 int cur_archmeta_suffix = 0;
833 int cur_coremeta_suffix = 0;
834 int cur_strmeta_suffix = 0;
835 int cur_xmlmeta_suffix = 0;
838 int archmeta_num = -1;
839 int coremeta_num = -1;
840 int xmlmeta_num = -1;
841 int strmeta_num = -1;
842 int submeta_num = -1;
843 int prometa_num = -1;
846 int archmeta_num_total = 0;
847 int coremeta_num_total = 0;
848 int xmlmeta_num_total = 0;
849 int strmeta_num_total = 0;
850 int submeta_num_total = 0;
851 int prometa_num_total = 0;
852 int othermeta_num_total = 0;
854 bool archmeta_no_suffix =
true;
855 bool coremeta_no_suffix =
true;
856 bool strmeta_no_suffix =
true;
857 bool xmlmeta_no_suffix =
true;
858 bool submeta_no_suffix =
true;
859 bool prometa_no_suffix =
true;
862 vector<string> s_oname(nelems);
868 for (
unsigned int i =0; i<nelems; i++)
871 for (hsize_t i = 0; i < nelems; i++) {
875 H5Lget_name_by_idx(ecs_grp_id,
".",H5_INDEX_NAME,H5_ITER_NATIVE,i,
NULL,
877 if (oname_size <= 0) {
878 string msg =
"hdf5 object name error from: ";
880 H5Gclose(ecs_grp_id);
882 throw InternalErr(__FILE__, __LINE__, msg);
886 vector<char> oname(oname_size + 1);
887 if (H5Lget_name_by_idx(ecs_grp_id,
".",H5_INDEX_NAME,H5_ITER_NATIVE,i,&oname[0],
888 (
size_t)(oname_size+1), H5P_DEFAULT)<0){
889 string msg =
"hdf5 object name error from: ";
891 H5Gclose(ecs_grp_id);
893 throw InternalErr(__FILE__, __LINE__, msg);
899 if (H5Lget_info(ecs_grp_id,&oname[0],&linfo,H5P_DEFAULT)<0) {
900 string msg =
"hdf5 link name error from: ";
902 H5Gclose(ecs_grp_id);
904 throw InternalErr(__FILE__, __LINE__, msg);
908 if (linfo.type == H5L_TYPE_SOFT){
909 string msg =
"hdf5 link name error from: ";
911 H5Gclose(ecs_grp_id);
913 throw InternalErr(__FILE__, __LINE__, msg);
918 if (H5Oget_info_by_idx(ecs_grp_id,
".", H5_INDEX_NAME, H5_ITER_NATIVE,
919 i, &oinfo, H5P_DEFAULT)<0) {
920 string msg =
"Cannot obtain the object info ";
922 H5Gclose(ecs_grp_id);
924 throw InternalErr(__FILE__, __LINE__, msg);
927 if(oinfo.type != H5O_TYPE_DATASET) {
928 string msg =
"hdf5 link name error from: ";
930 H5Gclose(ecs_grp_id);
932 throw InternalErr(__FILE__, __LINE__, msg);
936 string s_one_oname(oname.begin(),oname.end()-1);
938 s_oname[i] = s_one_oname;
941 if (((s_one_oname.find(
"StructMetadata"))==0) ||
942 ((s_one_oname.find(
"structmetadata"))==0)){
951 if (
false == strmeta_no_suffix) {
952 string msg =
"StructMetadata/structmetadata without suffix should only appear once. ";
953 H5Gclose(ecs_grp_id);
955 throw InternalErr(__FILE__, __LINE__, msg);
958 else if(strmeta_num_total >0)
961 if ((0 == s_one_oname.compare(
"StructMetadata"))||
962 (0 == s_one_oname.compare(
"structmetadata")))
963 strmeta_no_suffix =
false;
964 else strmeta_num_total++;
967 cerr <<
"strmeta_num_total= "<<strmeta_num_total <<endl;
968 if(strmeta_no_suffix) cerr <<
"structmeta data has the suffix" <<endl;
969 else cerr <<
"structmeta data doesn't have the suffix" <<endl;
973 if(
false == s_st_only) {
975 if ((0 == (s_one_oname.find(
"CoreMetadata"))) ||
976 (0 == (s_one_oname.find(
"coremetadata")))){
984 if (
false == coremeta_no_suffix) {
985 string msg =
"CoreMetadata/coremetadata without suffix should only appear once. ";
986 H5Gclose(ecs_grp_id);
988 throw InternalErr(__FILE__, __LINE__, msg);
991 else if(coremeta_num_total >0)
992 coremeta_num_total++;
997 if ((0 == s_one_oname.compare(
"CoreMetadata")) ||
998 (0 == s_one_oname.compare(
"coremetadata")))
999 coremeta_no_suffix =
false;
1000 else coremeta_num_total++;
1003 cerr <<
"coremeta_num_total= "<<coremeta_num_total <<endl;
1004 if(coremeta_no_suffix) cerr <<
"coreuctmeta data has the suffix" <<endl;
1005 else cerr <<
"coremeta data doesn't have the suffix" <<endl;
1010 else if ((0 == (s_one_oname.find(
"ArchivedMetadata"))) ||
1011 (0 == (s_one_oname.find(
"archivedmetadata"))) ||
1012 (0 == (s_one_oname.find(
"ArchiveMetadata"))) ||
1013 (0 == (s_one_oname.find(
"archivemetadata")))){
1020 if (
false == archmeta_no_suffix) {
1021 string msg =
"archivedmetadata/ArchivedMetadata without suffix should only appear once. ";
1022 H5Gclose(ecs_grp_id);
1024 throw InternalErr(__FILE__, __LINE__, msg);
1027 else if(archmeta_num_total >0)
1028 archmeta_num_total++;
1030 if ((0 == s_one_oname.compare(
"ArchivedMetadata"))||
1031 (0 == s_one_oname.compare(
"archivedmetadata")) ||
1032 (0 == s_one_oname.compare(
"archivemetadata")) ||
1033 (0 == s_one_oname.compare(
"ArchiveMetadata")))
1034 archmeta_no_suffix =
false;
1036 archmeta_num_total++;
1039 cerr <<
"archmeta_num_total= "<<archmeta_num_total <<endl;
1040 if(archmeta_no_suffix) cerr <<
"archuctmeta data has the suffix" <<endl;
1041 else cerr <<
"archmeta data doesn't have the suffix" <<endl;
1046 else if (((s_one_oname.find(
"SubsetMetadata"))==0) ||
1047 ((s_one_oname.find(
"subsetmetadata"))==0)){
1054 if (
false == submeta_no_suffix) {
1055 H5Gclose(ecs_grp_id);
1057 string msg =
"submetadata/SubMetadata without suffix should only appear once. ";
1058 throw InternalErr(__FILE__, __LINE__, msg);
1061 else if(submeta_num_total >0)
1062 submeta_num_total++;
1064 if ((0 == s_one_oname.compare(
"SubsetMetadata"))||
1065 (0 == s_one_oname.compare(
"subsetmetadata")))
1066 submeta_no_suffix =
false;
1067 else submeta_num_total++;
1070 cerr <<
"submeta_num_total= "<<submeta_num_total <<endl;
1071 if(submeta_no_suffix) cerr <<
"subuctmeta data has the suffix" <<endl;
1072 else cerr <<
"submeta data doesn't have the suffix" <<endl;
1077 else if ((0 == (s_one_oname.find(
"XmlMetadata"))) ||
1078 (0 == (s_one_oname.find(
"xmlmetadata")))){
1086 if (
false == xmlmeta_no_suffix) {
1087 H5Gclose(ecs_grp_id);
1089 string msg =
"xmlmetadata/Xmlmetadata without suffix should only appear once. ";
1090 throw InternalErr(__FILE__, __LINE__, msg);
1093 else if(xmlmeta_num_total >0)
1094 xmlmeta_num_total++;
1096 if ((0 == s_one_oname.compare(
"XmlMetadata"))||
1097 (0 == s_one_oname.compare(
"xmlmetadata")))
1098 xmlmeta_no_suffix =
false;
1099 else xmlmeta_num_total++;
1102 cerr <<
"xmlmeta_num_total= "<<xmlmeta_num_total <<endl;
1103 if(xmlmeta_no_suffix) cerr <<
"xmluctmeta data doesn't have the suffix" <<endl;
1104 else cerr <<
"xmlmeta data has the suffix" <<endl;
1109 else if ((0 == (s_one_oname.find(
"ProductMetadata"))) ||
1110 (0 == (s_one_oname.find(
"productmetadata")))){
1117 if (!prometa_no_suffix) {
1118 H5Gclose(ecs_grp_id);
1120 string msg =
"productmetadata/ProductMetadata without suffix should only appear once. ";
1121 throw InternalErr(__FILE__, __LINE__, msg);
1124 else if(prometa_num_total >0) prometa_num_total++;
1126 if ((0 == s_one_oname.compare(
"ProductMetadata"))||
1127 (0 == s_one_oname.compare(
"productmetadata")))
1128 prometa_no_suffix =
false;
1129 else prometa_num_total++;
1135 else othermeta_num_total++;
1140 s_one_oname.clear();
1145 vector<string> strmeta_value;
1146 if (strmeta_num_total <= 0) {
1147 string msg =
"hdf5 object name error from: ";
1148 H5Gclose(ecs_grp_id);
1150 throw InternalErr(__FILE__, __LINE__, msg);
1155 strmeta_value.resize(strmeta_num_total);
1156 for (
int i = 0; i < strmeta_num_total; i++)
1157 strmeta_value[i]=
"";
1162 vector<string> archmeta_value;
1163 if (archmeta_num_total >0) {
1164 archmeta_value.resize(archmeta_num_total);
1165 for (
int i = 0; i < archmeta_num_total; i++)
1166 archmeta_value[i]=
"";
1170 vector<string> coremeta_value;
1172 if (coremeta_num_total >0) {
1173 coremeta_value.resize(coremeta_num_total);
1174 for (
int i = 0; i < coremeta_num_total; i++)
1175 coremeta_value[i]=
"";
1179 vector<string> xmlmeta_value;
1180 if (xmlmeta_num_total >0) {
1181 xmlmeta_value.resize(xmlmeta_num_total);
1182 for (
int i = 0; i < xmlmeta_num_total; i++)
1183 xmlmeta_value[i]=
"";
1187 vector<string> submeta_value;
1188 if (submeta_num_total >0) {
1189 submeta_value.resize(submeta_num_total);
1190 for (
int i = 0; i < submeta_num_total; i++)
1191 submeta_value[i]=
"";
1195 vector<string> prometa_value;
1196 if (prometa_num_total >0) {
1197 prometa_value.resize(prometa_num_total);
1198 for (
int i = 0; i < prometa_num_total; i++)
1199 prometa_value[i]=
"";
1208 for (hsize_t i = 0; i < nelems; i++) {
1217 if (
true == s_st_only &&
1218 (((s_oname[i].find(
"StructMetadata"))!=0) &&
1219 ((s_oname[i].find(
"structmetadata"))!=0))){
1224 hid_t s_dset_id = -1;
1225 hid_t s_space_id = -1;
1227 hssize_t s_nelms = -1;
1228 size_t dtype_size = -1;
1230 if ((s_dset_id = H5Dopen(ecs_grp_id,s_oname[i].c_str(),H5P_DEFAULT))<0){
1231 string msg =
"Cannot open HDF5 dataset ";
1233 H5Gclose(ecs_grp_id);
1235 throw InternalErr(__FILE__, __LINE__, msg);
1238 if ((s_space_id = H5Dget_space(s_dset_id))<0) {
1239 string msg =
"Cannot open the data space of HDF5 dataset ";
1241 H5Dclose(s_dset_id);
1242 H5Gclose(ecs_grp_id);
1244 throw InternalErr(__FILE__, __LINE__, msg);
1247 if ((s_ty_id = H5Dget_type(s_dset_id)) < 0) {
1248 string msg =
"Cannot get the data type of HDF5 dataset ";
1250 H5Sclose(s_space_id);
1251 H5Dclose(s_dset_id);
1252 H5Gclose(ecs_grp_id);
1254 throw InternalErr(__FILE__, __LINE__, msg);
1256 if ((s_nelms = H5Sget_simple_extent_npoints(s_space_id))<0) {
1257 string msg =
"Cannot get the number of points of HDF5 dataset ";
1260 H5Sclose(s_space_id);
1261 H5Dclose(s_dset_id);
1262 H5Gclose(ecs_grp_id);
1264 throw InternalErr(__FILE__, __LINE__, msg);
1266 if ((dtype_size = H5Tget_size(s_ty_id))==0) {
1268 string msg =
"Cannot get the data type size of HDF5 dataset ";
1271 H5Sclose(s_space_id);
1272 H5Dclose(s_dset_id);
1273 H5Gclose(ecs_grp_id);
1275 throw InternalErr(__FILE__, __LINE__, msg);
1279 vector<char> s_buf(dtype_size*s_nelms +1);
1281 if ((H5Dread(s_dset_id,s_ty_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,&s_buf[0]))<0) {
1283 string msg =
"Cannot read HDF5 dataset ";
1286 H5Sclose(s_space_id);
1287 H5Dclose(s_dset_id);
1288 H5Gclose(ecs_grp_id);
1290 throw InternalErr(__FILE__, __LINE__, msg);
1295 H5Sclose(s_space_id);
1296 H5Dclose(s_dset_id);
1300 string tempstr(s_buf.begin(),s_buf.end());
1302 size_t temp_null_pos = tempstr.find_first_of(
'\0');
1307 string finstr = tempstr.substr(0,temp_null_pos);
1317 H5Gclose(ecs_grp_id);
1318 throw InternalErr(__FILE__,__LINE__,
"Obtain structmetadata suffix error.");
1325 if (-1 == strmeta_num)
1326 total_strmeta_value = finstr;
1328 else if (strmeta_value[strmeta_num]!=
"") {
1329 string msg =
"The structmeta value array at this index should be empty string ";
1330 H5Gclose(ecs_grp_id);
1332 throw InternalErr(__FILE__, __LINE__, msg);
1336 strmeta_value[strmeta_num] = finstr;
1340 if (
false == s_st_only &&
1343 switch (metatype[i]) {
1347 if (coremeta_num_total < 0) {
1348 string msg =
"There may be no coremetadata or coremetadata is not counted ";
1349 H5Gclose(ecs_grp_id);
1351 throw InternalErr(__FILE__, __LINE__, msg);
1359 H5Gclose(ecs_grp_id);
1360 throw InternalErr(__FILE__,__LINE__,
"Obtain coremetadata suffix error.");
1366 if ( -1 == coremeta_num )
1367 total_coremeta_value = finstr;
1368 else if (coremeta_value[coremeta_num]!=
"") {
1369 string msg =
"The coremeta value array at this index should be empty string ";
1370 H5Gclose(ecs_grp_id);
1372 throw InternalErr(__FILE__, __LINE__, msg);
1377 coremeta_value[coremeta_num] = finstr;
1383 if (archmeta_num_total < 0) {
1384 string msg =
"There may be no archivemetadata or archivemetadata is not counted ";
1385 H5Gclose(ecs_grp_id);
1387 throw InternalErr(__FILE__, __LINE__, msg);
1393 H5Gclose(ecs_grp_id);
1394 throw InternalErr(__FILE__,__LINE__,
"Obtain archivemetadata suffix error.");
1396 if (-1 == archmeta_num )
1397 total_archmeta_value = finstr;
1398 else if (archmeta_value[archmeta_num]!=
"") {
1399 string msg =
"The archivemeta value array at this index should be empty string ";
1400 H5Gclose(ecs_grp_id);
1402 throw InternalErr(__FILE__, __LINE__, msg);
1407 archmeta_value[archmeta_num] = finstr;
1412 if (submeta_num_total < 0) {
1413 string msg =
"The subsetemeta value array at this index should be empty string ";
1414 H5Gclose(ecs_grp_id);
1416 throw InternalErr(__FILE__, __LINE__, msg);
1422 H5Gclose(ecs_grp_id);
1423 throw InternalErr(__FILE__,__LINE__,
"Obtain subsetmetadata suffix error.");
1425 if (-1 == submeta_num )
1426 total_submeta_value = finstr;
1427 else if (submeta_value[submeta_num]!=
"") {
1428 string msg =
"The submeta value array at this index should be empty string ";
1429 H5Gclose(ecs_grp_id);
1431 throw InternalErr(__FILE__, __LINE__, msg);
1435 submeta_value[submeta_num] = finstr;
1440 if (prometa_num_total < 0) {
1441 string msg =
"There may be no productmetadata or productmetadata is not counted ";
1442 H5Gclose(ecs_grp_id);
1444 throw InternalErr(__FILE__, __LINE__, msg);
1450 H5Gclose(ecs_grp_id);
1451 throw InternalErr(__FILE__,__LINE__,
"Obtain productmetadata suffix error.");
1453 if (prometa_num == -1)
1454 total_prometa_value = finstr;
1455 else if (prometa_value[prometa_num]!=
"") {
1456 string msg =
"The productmeta value array at this index should be empty string ";
1457 H5Gclose(ecs_grp_id);
1459 throw InternalErr(__FILE__, __LINE__, msg);
1463 prometa_value[prometa_num] = finstr;
1468 if (xmlmeta_num_total < 0) {
1469 string msg =
"There may be no xmlmetadata or xmlmetadata is not counted ";
1470 H5Gclose(ecs_grp_id);
1472 throw InternalErr(__FILE__, __LINE__, msg);
1478 H5Gclose(ecs_grp_id);
1479 throw InternalErr(__FILE__,__LINE__,
"Obtain XMLmetadata suffix error.");
1481 if (-1 == xmlmeta_num )
1482 total_xmlmeta_value = finstr;
1483 else if (xmlmeta_value[xmlmeta_num]!=
"") {
1484 string msg =
"The xmlmeta value array at this index should be empty string ";
1485 H5Gclose(ecs_grp_id);
1487 throw InternalErr(__FILE__, __LINE__, msg);
1491 xmlmeta_value[xmlmeta_num] = finstr;
1496 if (othermeta_num_total < 0) {
1497 string msg =
"There may be no othermetadata or other metadata is not counted ";
1498 H5Gclose(ecs_grp_id);
1500 throw InternalErr(__FILE__, __LINE__, msg);
1502 total_othermeta_value = total_othermeta_value + finstr;
1507 string msg =
"Unsupported metadata type ";
1508 H5Gclose(ecs_grp_id);
1510 throw InternalErr(__FILE__, __LINE__, msg);
1523 if (strmeta_num_total > 0) {
1525 if (strmeta_num != -1) {
1526 for (
int i = 0; i <strmeta_num_total; i++)
1527 total_strmeta_value +=strmeta_value[i];
1532 if (
false == s_st_only) {
1534 if (coremeta_num_total >0) {
1535 if (coremeta_num != -1) {
1536 for(
int i = 0; i <coremeta_num_total; i++)
1537 total_coremeta_value +=coremeta_value[i];
1541 if (archmeta_num_total >0) {
1542 if (archmeta_num != -1) {
1543 for(
int i = 0; i <archmeta_num_total; i++)
1544 total_archmeta_value +=archmeta_value[i];
1548 if (submeta_num_total >0) {
1549 if (submeta_num != -1) {
1550 for(
int i = 0; i <submeta_num_total; i++)
1551 total_submeta_value +=submeta_value[i];
1555 if (xmlmeta_num_total >0) {
1556 if (xmlmeta_num != -1) {
1557 for(
int i = 0; i <xmlmeta_num_total; i++)
1558 total_xmlmeta_value +=xmlmeta_value[i];
1562 if (prometa_num_total >0) {
1563 if (prometa_num != -1) {
1564 for(
int i = 0; i <prometa_num_total; i++)
1565 total_prometa_value +=prometa_value[i];
1569 H5Gclose(ecs_grp_id);
1577 size_t dot_pos = meta_str.find(
".");
1578 if (dot_pos == string::npos)
1580 else if (meta_str.find_first_of(
".") == meta_str.find_last_of(
".")) {
1581 string num_str = meta_str.substr(dot_pos+1);
1582 stringstream ssnum(num_str);
1586 throw InternalErr(__FILE__,__LINE__,
"Suffix after dots is not a number.");
1590 string str_after_first_dot = meta_str.substr(dot_pos+1);
1591 if (str_after_first_dot.find_first_of(
".") != str_after_first_dot.find_last_of(
"."))
1592 throw InternalErr(__FILE__,__LINE__,
"Currently don't support metadata names containing more than two dots.");
1597 size_t second_dot_pos = str_after_first_dot.find(
".");
1598 string num_str = str_after_first_dot.substr(second_dot_pos+1);
1599 stringstream ssnum(num_str);
This class provides a way to map HDF5 Str to DAP Str for the CF option.
bool check_grids_support_projcode(HE5Parser *p)
void Check_Aura_Product_Status()
Check if the HDF-EOS5 file is an Aura file. Special CF operations need to be used.
yy_buffer_state * he5das_scan_string(const char *str)
Buffer state for NASA EOS metadata scanner.
const string & getFullPath() const
Get the full path of this variable.
int getRank() const
Get the dimension rank of this variable.
void Add_Dim_Name(HE5Parser *)
Add the dimension name for HDF-EOS5 files.
This class specifies the retrieval of special coordinate variable values for HDF-EOS5 products...
void Handle_SpVar()
Handle special variables for HDF-EOS5 files.
int he5dasparse(libdap::parser_arg *arg)
This class provides a way to map HDF5 unsigned 16-bit integer to DAP uint16 for the CF option...
yy_buffer_state * he5dds_scan_string(const char *str)
void Handle_Obj_NameClashing(bool)
Handle the object name clashing for HDF-EOS5 products.
This class provides a way to map HDF5 float to DAP float for the CF option.
#define HANDLE_CASE(tid, type)
void Handle_Unsupported_Dtype(bool)
Handle unsupported HDF5 datatypes for HDF-EOS5 products.
static void replace_double_quote(string &str)
static bool check_beskeys(const string key)
void Adjust_EOS5Dim_Info(HE5Parser *strmeta_info)
Adjust HDF-EOS5 dimension information.
const vector< Attribute * > & getAttributes() const
Public interface to obtain information of all attributes under the root group.
void gen_eos5_cfdas(DAS &das, hid_t file_id, HDF5CF::EOS5File *f)
This class provides a way to map HDF5 int16 to DAP int16 for the CF option.
void gen_dap_oneobj_das(AttrTable *at, const HDF5CF::Attribute *attr, const HDF5CF::Var *var)
bool check_grids_unknown_parameters(HE5Parser *p)
int he5ddsparse(HE5Parser *he5parser)
This class provides a way to map HDF5 64-bit floating-point(double) to DAP 64-bit floating-point for ...
void Adjust_Var_Dim_NewName_Before_Flattening()
Adjust variable dimension names before the flattening for HDF-EOS5 files.
void Handle_DimNameClashing()
Handle dimension name clashing. Since COARDS requires the change of cv names, So we need to handle di...
void Handle_CVar()
Handle coordinate variable for HDF-EOS5 files.
This class is a derived class of CVar. It represents a coordinate variable for HDF-EOS5 files...
This class specifies the retrieval of the missing lat/lon values for HDF-EOS5 products.
This class specifies the retrieval of the missing lat/lon values for HDFEOS5 products.
float getPointRight() const
void map_eos5_cfdas(DAS &das, hid_t file_id, const string &filename)
H5DataType getType() const
Get the data type of this variable(Not HDF5 datatype id)
EOS5GridOriginType getOrigin() const
EOS5GridPCType getProjCode() const
void Adjust_Obj_Name()
This method is a no-op operation. Leave here since the method in the base class is pure virtual...
void set_grids_missing_pixreg_orig(HE5Parser *p)
void Handle_Unsupported_Dspace()
Handle unsupported HDF5 dataspaces for HDF-EOS5 products.
Map and generate DDS and DAS for the CF option for HDF-EOS5 products.
void map_eos5_cfdds(DDS &dds, hid_t file_id, const string &filename)
void Adjust_Var_NewName_After_Parsing()
Adjust variable names for HDF-EOS5 files.
float getPointLeft() const
CVType getCVType() const
Get the coordinate variable type of this variable.
const hid_t getFileID() const
Obtain the HDF5 file ID.
int get_metadata_num(const string &meta_str)
const string & getNewName() const
Get the new name of this variable.
const string & getPath() const
Obtain the path of the file.
This class provides a way to map HDF5 32-bit integer to DAP Int32 for the CF option.
This class includes the methods to read data array into DAP buffer from an HDF5 dataset for the CF op...
void Handle_SpVar_Attr()
Handle special variables for HDF-EOS5 files.
This class is a derived class of File. It includes methods applied to HDF-EOS5 files only...
const vector< Dimension * > & getDimensions() const
Get the list of the dimensions.
const vector< EOS5CVar * > & getCVars() const
Obtain coordinate variables for HDF-EOS5 products.
void Add_EOS5File_Info(HE5Parser *, bool)
Add HDF-EOS5 dimension and coordinate variable related info. to EOS5Grid,EOS5Swath etc...
EOS5GridPRType getPixelReg() const
void Retrieve_H5_Info(const char *path, hid_t file_id, bool include_attr)
Retrieve DDS information from the HDF5 file; a real implementation for HDF-EOS5 products.
A class for parsing NASA HDF-EOS5 StructMetadata.
Helper functions for generating DAS attributes and a function to check BES Key.
void Flatten_Obj_Name(bool include_attr)
Flatten the object name for HDF-EOS5 files.
This class provides a way to map HDF5 unsigned 32-bit integer to DAP uint32 for the CF option...
void Set_COARDS_Status()
Set COARDS flag.
bool check_grids_multi_latlon_coord_vars(HE5Parser *p)
void Add_Supplement_Attrs(bool)
Add the supplemental attributes for HDF-EOS5 products.
const vector< Var * > & getVars() const
Public interface to obtain information of all variables.
virtual const char * what() const
const vector< Group * > & getGroups() const
Public interface to obtain all the group info.
A class for parsing NASA HDF-EOS5 StructMetadata.
float getPointLower() const
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
void Adjust_Attr_Info()
Adjust the attribute info for HDF-EOS5 products.
void gen_dap_onevar_dds(DDS &dds, const HDF5CF::Var *var, const hid_t file_id, const string &filename)
This class provides a way to map HDF5 byte to DAP byte for the CF option.
void gen_dap_oneeos5cvar_dds(DDS &dds, const HDF5CF::EOS5CVar *cvar, const hid_t file_id, const string &filename)
void gen_eos5_cfdds(DDS &dds, HDF5CF::EOS5File *f)
bool check_grids_missing_projcode(HE5Parser *p)
void Retrieve_H5_Supported_Attr_Values()
Retrieve attribute values for the supported HDF5 datatypes for HDF-EOS5 products. ...
float getPointUpper() const
void read_ecs_metadata(hid_t s_file_id, string &total_strmeta_value, string &total_coremeta_value, string &total_archmeta_value, string &total_xmlmeta_value, string &total_submeta_value, string &total_prometa_value, string &total_othermeta_value, bool s_st_only)
void Adjust_Dim_Name()
Adjust the dimension name for HDF-EOS5 products.
void Handle_Coor_Attr()
Handle the coordinates attribute for HDF-EOS5 products.