bes Updated for version 3.20.13
HE5Parser.cc
1
2// This file is part of the hdf5 data handler for the OPeNDAP data server.
3//
4// Author: Hyo-Kyung Lee <hyoklee@hdfgroup.org>
5//
6// Copyright (c) 2007-2016 The HDF Group, Inc. and OPeNDAP, Inc.
7//
8// This is free software; you can redistribute it and/or modify it under the
9// terms of the GNU Lesser General Public License as published by the Free
10// Software Foundation; either version 2.1 of the License, or (at your
11// option) any later version.
12//
13// This software is distributed in the hope that it will be useful, but
14// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16// License for more details.
17//
18// You should have received a copy of the GNU Lesser General Public
19// License along with this library; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21//
22// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
23// You can contact The HDF Group, Inc. at 1800 South Oak Street,
24// Suite 203, Champaign, IL 61820
25
26#include "HE5Parser.h"
27#include <libdap/InternalErr.h>
28#include <HDF5CFUtil.h>
29#include <stdlib.h>
30
31using namespace std;
32
33HE5Parser::HE5Parser()
34{
35}
36
37HE5Parser::~HE5Parser()
38{
39}
40
41
43{
44 unsigned int i = 0;
45
46 if(err_msg != ""){
47 cerr<< "Parse error:" << err_msg << endl;
48 }
49 cout << "ZA Size=" << za_list.size() << endl;
50 for(i=0; i < za_list.size(); i++) {
51 HE5Za z = za_list.at(i);
52 cout << "ZA Name=" << z.name << endl;
53 cout << "ZA Dim Size=" << z.dim_list.size() << endl;
54 unsigned int j = 0;
55 for(j=0; j < z.dim_list.size(); j++) {
56 HE5Dim d = z.dim_list.at(j);
57 cout << "ZA Dim Name=" << d.name;
58 cout << " Size=" << d.size << endl;
59 }
60
61 cout << "ZA Var Size=" << z.data_var_list.size()
62 << endl;
63 for(j=0; j < z.data_var_list.size(); j++) {
64 HE5Var v = z.data_var_list.at(j);
65 cout << "ZA Var Name=" << v.name << endl;
66 cout << "ZA Var Dim Size=" << v.dim_list.size() << endl;
67 for(unsigned int k=0; k < v.dim_list.size(); k++) {
68 HE5Dim d = v.dim_list.at(k);
69 cout << "ZA Var Dim Name=" << d.name << endl;
70 }
71 }
72 }
73
74 cout << "Swath Size=" << swath_list.size() << endl;
75 for(i=0; i < swath_list.size(); i++) {
76 HE5Swath s = swath_list.at(i);
77 cout << "Swath Name=" << s.name << endl;
78 cout << "Swath Dim Size=" << s.dim_list.size() << endl;
79 unsigned int j = 0;
80 for(j=0; j < s.dim_list.size(); j++) {
81 HE5Dim d = s.dim_list.at(j);
82 cout << "Swath Dim Name=" << d.name;
83 cout << " Size=" << d.size << endl;
84 }
85
86 cout << "Swath Geo Var Size=" << s.geo_var_list.size()
87 << endl;
88 for(j=0; j < s.geo_var_list.size(); j++) {
89 HE5Var v = s.geo_var_list.at(j);
90 cout << "Swath Geo Var Name=" << v.name << endl;
91 cout << "Swath Geo Var Dim Size=" << v.dim_list.size() << endl;
92 for(unsigned int k=0; k < v.dim_list.size(); k++) {
93 HE5Dim d = v.dim_list.at(k);
94 cout << "Swath Geo Var Dim Name=" << d.name;
95 cout << " Size=" << d.size << endl;
96 }
97 }
98
99 cout << "Swath Data Var Size=" << s.data_var_list.size()
100 << endl;
101 for(j=0; j < s.data_var_list.size(); j++) {
102 HE5Var v = s.data_var_list.at(j);
103 cout << "Swath Data Var Name=" << v.name << endl;
104 cout << "Swath Data Var Number Dim =" << v.dim_list.size() << endl;
105 for(unsigned int k=0; k < v.dim_list.size(); k++) {
106 HE5Dim d = v.dim_list.at(k);
107 cout << "Swath Data Var Dim Name=" << d.name << endl;
108 cout <<"Swath Data Var Dim Size= "<< d.size<<endl;
109 }
110// UNCOMMENT OUT the block below to retrieve the maximum dimension list. ALSO NEED TO ADD MAX_DIMENSION_LIST at he5dds.lex.
111#if 0
112 for(k=0; k < v.max_dim_list.size(); k++) {
113 HE5Dim d = v.max_dim_list.at(k);
114 cout << "Swath Data Var Max Dim Name=" << d.name << endl;
115 cout <<"Swath Data Var Dim Size= "<< d.size<<endl;
116 }
117#endif
118 }
119 }
120
121 cout << "Grid Size=" << grid_list.size() << endl;
122 for(i=0; i < grid_list.size(); i++) {
123 HE5Grid g = grid_list.at(i);
124 cout << "Grid Name=" << g.name << endl;
125
126 cout << "Grid point_lower=" << g.point_lower << endl;
127 cout << "Grid point_upper=" << g.point_upper << endl;
128 cout << "Grid point_left=" << g.point_left << endl;
129 cout << "Grid point_right=" << g.point_right << endl;
130 cout << "Grid Sphere code =" <<g.sphere <<endl;
131
132 cout << "Grid Dim Size=" << g.dim_list.size() << endl;
133 unsigned int j = 0;
134 for(j=0; j < g.dim_list.size(); j++) {
135 HE5Dim d = g.dim_list.at(j);
136 cout << "Grid Dim Name=" << d.name;
137 cout << " Size=" << d.size << endl;
138 }
139
140 cout << "Grid Var Size=" << g.data_var_list.size()
141 << endl;
142 for(j=0; j < g.data_var_list.size(); j++) {
143 HE5Var v = g.data_var_list.at(j);
144 cout << "Grid Var Name=" << v.name << endl;
145 cout << "Grid Var Dim Size=" << v.dim_list.size() << endl;
146 for(unsigned int k=0; k < v.dim_list.size(); k++) {
147 HE5Dim d = v.dim_list.at(k);
148 cout << "Grid Var Dim Name=" << d.name << endl;
149 }
150#if 0
151 for(k=0; k < v.max_dim_list.size(); k++) {
152 HE5Dim d = v.max_dim_list.at(k);
153 cout << "Grid Var Max Dim Name=" << d.name << endl;
154 }
155#endif
156 }
157 cout << "Grid pixelregistration=" <<
158 g.pixelregistration
159 << endl;
160 cout << "Grid origin=" <<
161 g.gridorigin
162 << endl;
163 cout << "Grid projection=" <<
164 g.projection
165 << endl;
166
167 cout <<"Grid zone= "<< g.zone<<endl;
168 cout <<"Grid sphere= "<<g.sphere<<endl;
169
170 cout<<"Grid projection parameters are "<<endl;
171 for(j= 0;j<13;j++)
172 cout<<g.param[j]<<endl;
173 }
174
175}
176
177void HE5Parser::add_projparams(const string & st_str) {
178
179 string projparms = "ProjParams=(";
180 char parms_end_marker = ')';
181 size_t parms_spos = st_str.find(projparms);
182 int grid_index = 0;
183 while(parms_spos!=string::npos) {
184 size_t parms_epos = st_str.find(parms_end_marker,parms_spos);
185 if(parms_epos == string::npos)
186 throw libdap::InternalErr(__FILE__,__LINE__,"HDF-EOS5 Grid ProjParms syntax error: ProjParams doesn't end with ')'. ");
187 string projparms_raw_values = st_str.substr(parms_spos+projparms.size(),parms_epos-parms_spos-projparms.size());
188 vector<string> projparms_values;
189 HDF5CFUtil::Split(projparms_raw_values.c_str(),',',projparms_values);
190
191 for(unsigned int i = 0; i<projparms_values.size();i++) {
192 grid_list[grid_index].param[i] = strtod(projparms_values[i].c_str(),nullptr);
193 }
194#if 0
195for(vector<string>::iterator istr=projparms_values.begin();istr!=projparms_values.end();++istr)
196cerr<<"projparms value is "<<*istr<<endl;
197#endif
198 parms_spos = st_str.find(projparms,parms_epos);
199 grid_index++;
200 }
201
202}
This file includes several helper functions for translating HDF5 to CF-compliant.
A class for parsing NASA HDF-EOS5 StructMetadata.
std::string err_msg
Have any parse error message.
Definition: HE5Parser.h:71
void print()
Print the information about the members of the Vector list.
Definition: HE5Parser.cc:42
static void Split(const char *s, int len, char sep, std::vector< std::string > &names)
Definition: HDF5CFUtil.cc:343
Definition: HE5Dim.h:7
double point_right
The rightmost coordinate value of a Grid.
Definition: HE5Grid.h:25
double point_upper
The top coordinate value of a Grid.
Definition: HE5Grid.h:21
double point_left
The leftmost coordinate value of a Grid.
Definition: HE5Grid.h:23
double point_lower
The bottom coordinate value of a Grid.
Definition: HE5Grid.h:19
Definition: HE5Var.h:8
Definition: HE5Za.h:6