27#include <libdap/InternalErr.h>
40HE5Parser::~HE5Parser()
50 cerr<<
"Parse error:" <<
err_msg << endl;
52 cout <<
"ZA Size=" << za_list.size() << endl;
53 for(i=0; i < za_list.size(); i++) {
54 HE5Za z = za_list.at(i);
55 cout <<
"ZA Name=" << z.name << endl;
56 cout <<
"ZA Dim Size=" << z.dim_list.size() << endl;
58 for(j=0; j < z.dim_list.size(); j++) {
59 HE5Dim d = z.dim_list.at(j);
60 cout <<
"ZA Dim Name=" << d.name;
61 cout <<
" Size=" << d.size << endl;
64 cout <<
"ZA Var Size=" << z.data_var_list.size()
66 for(j=0; j < z.data_var_list.size(); j++) {
67 HE5Var v = z.data_var_list.at(j);
68 cout <<
"ZA Var Name=" << v.name << endl;
69 cout <<
"ZA Var Dim Size=" << v.dim_list.size() << endl;
70 for(
unsigned int k=0; k < v.dim_list.size(); k++) {
71 HE5Dim d = v.dim_list.at(k);
72 cout <<
"ZA Var Dim Name=" << d.name << endl;
77 cout <<
"Swath Size=" << swath_list.size() << endl;
78 for(i=0; i < swath_list.size(); i++) {
80 cout <<
"Swath Name=" << s.name << endl;
81 cout <<
"Swath Dim Size=" << s.dim_list.size() << endl;
83 for(j=0; j < s.dim_list.size(); j++) {
84 HE5Dim d = s.dim_list.at(j);
85 cout <<
"Swath Dim Name=" << d.name;
86 cout <<
" Size=" << d.size << endl;
89 cout <<
"Swath Geo Var Size=" << s.geo_var_list.size()
91 for(j=0; j < s.geo_var_list.size(); j++) {
92 HE5Var v = s.geo_var_list.at(j);
93 cout <<
"Swath Geo Var Name=" << v.name << endl;
94 cout <<
"Swath Geo Var Dim Size=" << v.dim_list.size() << endl;
95 for(
unsigned int k=0; k < v.dim_list.size(); k++) {
96 HE5Dim d = v.dim_list.at(k);
97 cout <<
"Swath Geo Var Dim Name=" << d.name;
98 cout <<
" Size=" << d.size << endl;
102 cout <<
"Swath Data Var Size=" << s.data_var_list.size()
104 for(j=0; j < s.data_var_list.size(); j++) {
105 HE5Var v = s.data_var_list.at(j);
106 cout <<
"Swath Data Var Name=" << v.name << endl;
107 cout <<
"Swath Data Var Number Dim =" << v.dim_list.size() << endl;
108 for(
unsigned int k=0; k < v.dim_list.size(); k++) {
109 HE5Dim d = v.dim_list.at(k);
110 cout <<
"Swath Data Var Dim Name=" << d.name << endl;
111 cout <<
"Swath Data Var Dim Size= "<< d.size<<endl;
115 for(k=0; k < v.max_dim_list.size(); k++) {
116 HE5Dim d = v.max_dim_list.at(k);
117 cout <<
"Swath Data Var Max Dim Name=" << d.name << endl;
118 cout <<
"Swath Data Var Dim Size= "<< d.size<<endl;
124 cout <<
"Grid Size=" << grid_list.size() << endl;
125 for(i=0; i < grid_list.size(); i++) {
127 cout <<
"Grid Name=" << g.name << endl;
129 cout <<
"Grid point_lower=" << g.
point_lower << endl;
130 cout <<
"Grid point_upper=" << g.
point_upper << endl;
131 cout <<
"Grid point_left=" << g.
point_left << endl;
132 cout <<
"Grid point_right=" << g.
point_right << endl;
133 cout <<
"Grid Sphere code =" <<g.sphere <<endl;
135 cout <<
"Grid Dim Size=" << g.dim_list.size() << endl;
137 for(j=0; j < g.dim_list.size(); j++) {
138 HE5Dim d = g.dim_list.at(j);
139 cout <<
"Grid Dim Name=" << d.name;
140 cout <<
" Size=" << d.size << endl;
143 cout <<
"Grid Var Size=" << g.data_var_list.size()
145 for(j=0; j < g.data_var_list.size(); j++) {
146 HE5Var v = g.data_var_list.at(j);
147 cout <<
"Grid Var Name=" << v.name << endl;
148 cout <<
"Grid Var Dim Size=" << v.dim_list.size() << endl;
149 for(
unsigned int k=0; k < v.dim_list.size(); k++) {
150 HE5Dim d = v.dim_list.at(k);
151 cout <<
"Grid Var Dim Name=" << d.name << endl;
154 for(k=0; k < v.max_dim_list.size(); k++) {
155 HE5Dim d = v.max_dim_list.at(k);
156 cout <<
"Grid Var Max Dim Name=" << d.name << endl;
160 cout <<
"Grid pixelregistration=" <<
163 cout <<
"Grid origin=" <<
166 cout <<
"Grid projection=" <<
170 cout <<
"Grid zone= "<< g.zone<<endl;
171 cout <<
"Grid sphere= "<<g.sphere<<endl;
173 cout<<
"Grid projection parameters are "<<endl;
175 cout<<g.param[j]<<endl;
180void HE5Parser::add_projparams(
const string & st_str) {
182 string projparms =
"ProjParams=(";
183 char parms_end_marker =
')';
184 size_t parms_spos = st_str.find(projparms);
186 while(parms_spos!=string::npos) {
187 size_t parms_epos = st_str.find(parms_end_marker,parms_spos);
188 if(parms_epos == string::npos)
189 throw libdap::InternalErr(__FILE__,__LINE__,
"HDF-EOS5 Grid ProjParms syntax error: ProjParams doesn't end with ')'. ");
190 string projparms_raw_values = st_str.substr(parms_spos+projparms.size(),parms_epos-parms_spos-projparms.size());
191 vector<string> projparms_values;
194 for(
unsigned int i = 0; i<projparms_values.size();i++) {
195 grid_list[grid_index].param[i] = strtod(projparms_values[i].c_str(),NULL);
198for(vector<string>::iterator istr=projparms_values.begin();istr!=projparms_values.end();++istr)
199cerr<<
"projparms value is "<<*istr<<endl;
201 parms_spos = st_str.find(projparms,parms_epos);
This file includes several helper functions for translating HDF5 to CF-compliant.
A class for parsing NASA HDF-EOS5 StructMetadata.
int structure_state
Have the parser's state in terms of structure.
std::string err_msg
Have any parse error message.
void print()
Print the information about the members of the Vector list.
int parser_state
Have the StructMetadata parser's state.
static void Split(const char *s, int len, char sep, std::vector< std::string > &names)
double point_right
The rightmost coordinate value of a Grid.
double point_upper
The top coordinate value of a Grid.
double point_left
The leftmost coordinate value of a Grid.
double point_lower
The bottom coordinate value of a Grid.