bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
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-2023 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 410 E University Ave,
24// Suite 200, 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() = default;
34
35HE5Parser::~HE5Parser() = default;
36
37
38void HE5Parser::print() const
39{
40
41 if(err_msg != ""){
42 cerr<< "Parse error:" << err_msg << endl;
43 }
44 cout << "ZA Size=" << za_list.size() << endl;
45 for (const auto &z:za_list) {
46 cout << "ZA Name=" << z.name << endl;
47 cout << "ZA Dim Size=" << z.dim_list.size() << endl;
48 for (const auto &d:z.dim_list) {
49 cout << "ZA Dim Name=" << d.name;
50 cout << " Size=" << d.size << endl;
51 }
52
53 cout << "ZA Var Size=" << z.data_var_list.size()
54 << endl;
55 for (const auto &v:z.data_var_list) {
56 cout << "ZA Var Name=" << v.name << endl;
57 cout << "ZA Var Dim Size=" << v.dim_list.size() << endl;
58 for (const auto &d:v.dim_list)
59 cout << "ZA Var Dim Name=" << d.name << endl;
60 }
61 }
62
63 cout << "Swath Size=" << swath_list.size() << endl;
64 for (const auto &s:swath_list) {
65 cout << "Swath Name=" << s.name << endl;
66 cout << "Swath Dim Size=" << s.dim_list.size() << endl;
67 for (const auto &d:s.dim_list) {
68 cout << "Swath Dim Name=" << d.name;
69 cout << " Size=" << d.size << endl;
70 }
71
72 cout << "Swath Geo Var Size=" << s.geo_var_list.size()
73 << endl;
74 for (const auto &v:s.geo_var_list) {
75 cout << "Swath Geo Var Name=" << v.name << endl;
76 cout << "Swath Geo Var Dim Size=" << v.dim_list.size() << endl;
77 for (const auto &d:v.dim_list) {
78 cout << "Swath Geo Var Dim Name=" << d.name;
79 cout << " Size=" << d.size << endl;
80 }
81 }
82
83 cout << "Swath Data Var Size=" << s.data_var_list.size()
84 << endl;
85 for (const auto &v:s.data_var_list) {
86 cout << "Swath Data Var Name=" << v.name << endl;
87 cout << "Swath Data Var Number Dim =" << v.dim_list.size() << endl;
88 for (const auto &d:v.dim_list) {
89 cout << "Swath Data Var Dim Name=" << d.name << endl;
90 cout <<"Swath Data Var Dim Size= "<< d.size<<endl;
91 }
92// UNCOMMENT OUT the block below to retrieve the maximum dimension list. ALSO NEED TO ADD MAX_DIMENSION_LIST at he5dds.lex.
93#if 0
94 for (const auto &d:v.max_dim_list) {
95 cout << "Swath Data Var Max Dim Name=" << d.name << endl;
96 cout <<"Swath Data Var Dim Size= "<< d.size<<endl;
97 }
98#endif
99 }
100 }
101
102 cout << "Grid Size=" << grid_list.size() << endl;
103 for (const auto &g:grid_list) {
104 cout << "Grid Name=" << g.name << endl;
105
106 cout << "Grid point_lower=" << g.point_lower << endl;
107 cout << "Grid point_upper=" << g.point_upper << endl;
108 cout << "Grid point_left=" << g.point_left << endl;
109 cout << "Grid point_right=" << g.point_right << endl;
110 cout << "Grid Sphere code =" <<g.sphere <<endl;
111
112 cout << "Grid Dim Size=" << g.dim_list.size() << endl;
113 for (const auto &d:g.dim_list) {
114 cout << "Grid Dim Name=" << d.name;
115 cout << " Size=" << d.size << endl;
116 }
117
118 cout << "Grid Var Size=" << g.data_var_list.size()
119 << endl;
120 for(const auto &v:g.data_var_list) {
121 cout << "Grid Var Name=" << v.name << endl;
122 cout << "Grid Var Dim Size=" << v.dim_list.size() << endl;
123 for (const auto &d:v.dim_list)
124 cout << "Grid Var Dim Name=" << d.name << endl;
125#if 0
126 for(k=0; k < v.max_dim_list.size(); k++) {
127 HE5Dim d = v.max_dim_list.at(k);
128 cout << "Grid Var Max Dim Name=" << d.name << endl;
129 }
130#endif
131 }
132 cout << "Grid pixelregistration=" <<
133 g.pixelregistration
134 << endl;
135 cout << "Grid origin=" <<
136 g.gridorigin
137 << endl;
138 cout << "Grid projection=" <<
139 g.projection
140 << endl;
141
142 cout <<"Grid zone= "<< g.zone<<endl;
143 cout <<"Grid sphere= "<<g.sphere<<endl;
144
145 cout<<"Grid projection parameters are "<<endl;
146 for(const auto &gp:g.param)
147 cout<<gp<<endl;
148 }
149
150}
151
152void HE5Parser::add_projparams(const string & st_str) {
153
154 string projparms = "ProjParams=(";
155 char parms_end_marker = ')';
156 size_t parms_spos = st_str.find(projparms);
157 int grid_index = 0;
158 while(parms_spos!=string::npos) {
159 size_t parms_epos = st_str.find(parms_end_marker,parms_spos);
160 if(parms_epos == string::npos)
161 throw libdap::InternalErr(__FILE__,__LINE__,"HDF-EOS5 Grid ProjParms syntax error: ProjParams doesn't end with ')'. ");
162 string projparms_raw_values = st_str.substr(parms_spos+projparms.size(),parms_epos-parms_spos-projparms.size());
163 vector<string> projparms_values;
164 HDF5CFUtil::Split(projparms_raw_values.c_str(),',',projparms_values);
165
166 for(unsigned int i = 0; i<projparms_values.size();i++) {
167 grid_list[grid_index].param[i] = strtod(projparms_values[i].c_str(),nullptr);
168 }
169#if 0
170for(vector<string>::iterator istr=projparms_values.begin();istr!=projparms_values.end();++istr)
171cerr<<"projparms value is "<<*istr<<endl;
172#endif
173 parms_spos = st_str.find(projparms,parms_epos);
174 grid_index++;
175 }
176
177}
This file includes several helper functions for translating HDF5 to CF-compliant.
A class for parsing NASA HDF-EOS5 StructMetadata.
void print() const
Print the information about the members of the Vector list.
Definition HE5Parser.cc:38
std::string err_msg
Have any parse error message.
Definition HE5Parser.h:71
static void Split(const char *s, int len, char sep, std::vector< std::string > &names)
Definition HE5Dim.h:7