OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
HE5Checker.cc
Go to the documentation of this file.
1 // This file is part of the hdf5 data handler for the OPeNDAP data server.
3 //
4 // Author: Hyo-Kyung Lee <hyoklee@hdfgroup.org>
5 // MuQun Yang <myang6@hdfgroup.org>
6 //
7 // Copyright (c) 2007-2013 The HDF Group, Inc. and OPeNDAP, Inc.
10 //
11 // This is free software; you can redistribute it and/or modify it under the
12 // terms of the GNU Lesser General Public License as published by the Free
13 // Software Foundation; either version 2.1 of the License, or (at your
14 // option) any later version.
15 //
16 // This software is distributed in the hope that it will be useful, but
17 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19 // License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public
22 // License along with this library; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 //
25 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
26 // You can contact The HDF Group, Inc. at 1800 South Oak Street,
27 // Suite 203, Champaign, IL 61820
36 #include <map>
37 #include <math.h>
38 #include "HE5Checker.h"
39 
40 using namespace std;
41 
42 
43 bool
45 {
46  bool flag = false;
47  for (unsigned int i = 0; i <p->grid_list.size(); i++) {
48  HE5Grid g = p->grid_list.at(i);
49  if (HE5_GCTP_MISSING == g.projection) {
50  flag = true;
51  break;
52  }
53  }
54  return flag;
55 }
56 
57 bool
59 {
60  HE5Grid g;
61  bool flag = false;
62  for (unsigned int i = 0; i <p->grid_list.size(); i++) {
63  g = p->grid_list.at(i);
64  if (HE5_GCTP_UNKNOWN == g.projection ||
67  flag = true;
68  break;
69  }
70  }
71  return flag;
72 }
73 
74 void
76 {
77  unsigned int i = 0;
78 #if 0
79  cerr << "HE5Checker::set_missing_values(Grid Size="
80  << p->grid_list.size() << ")" << endl;
81 #endif
82  for(i=0; i < p->grid_list.size(); i++) {
83 #if 0
84 // Unnecessary
85  unsigned int j = 0;
86  for(j=0; j < g.dim_list.size(); j++) {
87  HE5Dim d = g.dim_list.at(j);
88  cout << "Grid Dim Name=" << d.name;
89  cout << " Size=" << d.size << endl;
90  }
91  for(j=0; j < g.data_var_list.size(); j++) {
92  HE5Var v = g.data_var_list.at(j);
93  unsigned int k = 0;
94  for(k=0; k < v.dim_list.size(); k++) {
95  HE5Dim d = v.dim_list.at(k);
96  cout << "Grid Var Dim Name=" << d.name << endl;
97  }
98  }
99  if(g.projection == -1){
100  flag = true;
101  cerr << "Grid projection is not set or the projection code is wrong. Name=" << g.name
102  << endl;
103  }
104 #endif
105 
106  if (HE5_HDFE_MISSING == (p->grid_list)[i].pixelregistration)
107  (p->grid_list)[i].pixelregistration = HE5_HDFE_CENTER;
108 
109  if (HE5_HDFE_GD_MISSING == (p->grid_list)[i].gridorigin)
110  (p->grid_list)[i].gridorigin = HE5_HDFE_GD_UL;
111 
112  }
113 }
114 
115 bool
117 {
118 
119  // No need to check for the file that only has one grid or no grid.
120  if (1 == p->grid_list.size() ||
121  0 == p->grid_list.size() ) return false;
122 
123  unsigned int i = 0;
124  // Store name size pair.
125  typedef map<string, int> Dimmap;
126  Dimmap dim_map;
127  bool flag = false;
128 
129  for(i=0; i < p->grid_list.size(); i++) {
130  HE5Grid g = p->grid_list.at(i);
131  unsigned int j = 0;
132  for(j=0; j < g.dim_list.size(); j++) {
133  HE5Dim d = g.dim_list.at(j);
134  Dimmap::iterator iter = dim_map.find(d.name);
135  if(iter != dim_map.end()){
136  if(d.size != iter->second){
137 #if 0
138  cerr << "Dimension size mismatch is found."
139  << " Name=" << d.name
140  << " Size=" << d.size << endl;
141 #endif
142  flag = true;
143  break;
144  }
145 
146  }
147  else{
148  dim_map[d.name] = d.size;
149  }
150  }
151  if (true == flag) break;
152 
153  }
154 
155 
156  if (false == flag) {
157 
158  HE5Grid g = p->grid_list.at(0);
159  EOS5GridPCType projcode = g.projection;
160  EOS5GridPRType pixelreg = g.pixelregistration;
161  EOS5GridOriginType pixelorig = g.gridorigin;
162 
163  float lowercoor = g.point_lower;
164  float uppercoor = g.point_upper;
165  float leftcoor =g.point_left;
166  float rightcoor= g.point_right;
167 
168 
169 
170  for(i=1; i < p->grid_list.size(); i++) {
171  g = p->grid_list.at(i);
172  if (projcode != g.projection ||
173  pixelreg != g.pixelregistration ||
174  pixelorig!= g.gridorigin ||
175  fabs(lowercoor-g.point_lower) >0.001 ||
176  fabs(uppercoor-g.point_upper) >0.001 ||
177  fabs(leftcoor-g.point_left) >0.001 ||
178  fabs(rightcoor-g.point_right) >0.001 ){
179  flag = true;
180  break;
181  }
182  }
183  }
184 
185  return flag;
186 }
187 
189 
190  bool flag = false;
191  for (unsigned int i = 0; i <p->grid_list.size(); i++) {
192  HE5Grid g = p->grid_list.at(i);
193  if (g.projection != HE5_GCTP_GEO) {
194  flag = true;
195  break;
196  }
197  }
198  return flag;
199 
200 
201 }
202 
bool check_grids_support_projcode(HE5Parser *p)
Definition: HE5Checker.cc:188
Definition: HE5Dim.h:8
vector< HE5Dim > dim_list
Definition: HE5Var.h:11
float point_right
The rightmost coordinate value of a Grid.
Definition: HE5Grid.h:26
STL namespace.
string name
Definition: HE5Dim.h:9
EOS5GridPRType pixelregistration
Definition: HE5Grid.h:35
bool check_grids_unknown_parameters(HE5Parser *p)
Definition: HE5Checker.cc:58
float point_left
The leftmost coordinate value of a Grid.
Definition: HE5Grid.h:24
EOS5GridPCType projection
Definition: HE5Grid.h:42
void set_grids_missing_pixreg_orig(HE5Parser *p)
Definition: HE5Checker.cc:75
EOS5GridPRType
This file defines a few enum types used by HDF-EOS5 products.
Definition: HE5GridPara.h:3
float point_lower
The bottom coordinate value of a Grid.
Definition: HE5Grid.h:20
float point_upper
The top coordinate value of a Grid.
Definition: HE5Grid.h:22
int size
Definition: HE5Dim.h:10
EOS5GridOriginType gridorigin
Definition: HE5Grid.h:39
bool check_grids_multi_latlon_coord_vars(HE5Parser *p)
Definition: HE5Checker.cc:116
EOS5GridOriginType
Definition: HE5GridPara.h:8
vector< HE5Grid > grid_list
Definition: HE5Parser.h:55
A class for parsing NASA HDF-EOS5 StructMetadata.
vector< HE5Dim > dim_list
Definition: HE5Grid.h:16
bool check_grids_missing_projcode(HE5Parser *p)
Definition: HE5Checker.cc:44
Definition: HE5Var.h:9
EOS5GridPCType
Definition: HE5GridPara.h:13