bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
HDFEOS2ArrayMissField.cc
1
2// This file is part of the hdf4 data handler for the OPeNDAP data server.
3// It retrieves the missing "third-dimension" values of the HDF-EOS2 Grid.
4// Some third-dimension coordinate variable values are not provided.
5// What we do here is to provide natural number series(1,2,3, ...) for
6// these missing values. It doesn't make sense to visualize or analyze
7// with vertical cross-section. One can check the data level by level.
8// Authors: Kent Yang <myang6@hdfgroup.org>
9// Copyright (c) The HDF Group
11#ifdef USE_HDFEOS2_LIB
12
13#include "HDFEOS2ArrayMissField.h"
14#include <iostream>
15#include <sstream>
16#include <cassert>
17#include <libdap/debug.h>
18
19#include <libdap/InternalErr.h>
20#include <BESDebug.h>
21
22#include "HDFEOS2.h"
23
24using namespace libdap;
25using namespace std;
26// Now we use the vector to replace new []. KY 2012-12-30
27bool HDFEOS2ArrayMissGeoField::read()
28{
29
30 if (length() == 0)
31 return true;
32 // Declaration of offset,count and step
33 vector<int> offset;
34 offset.resize(rank);
35 vector<int> count;
36 count.resize(rank);
37 vector<int> step;
38 step.resize(rank);
39
40 // Obtain offset,step and count from the client expression constraint
41 int nelms = -1;
42 nelms = format_constraint(offset.data(), step.data(), count.data());
43
44 vector<int> val;
45 val.resize(nelms);
46
47 // Since we always assign the the missing Z dimension as 32-bit
48 // integer, so no need to check the type. The missing Z-dim is always
49 // 1-D with natural number 1,2,3,....
50 if (nelms == tnumelm) {
51 for (int i = 0; i < nelms; i++)
52 val[i] = i;
53 set_value((dods_int32 *) val.data(), nelms);
54 }
55 else {
56 if (rank != 1) {
57 throw InternalErr(__FILE__, __LINE__, "Currently the rank of the missing field should be 1");
58 }
59 for (int i = 0; i < count[0]; i++)
60 val[i] = offset[0] + step[0] * i;
61 set_value((dods_int32 *) val.data(), nelms);
62 }
63
64 return false;
65}
66
67// Standard way of DAP handlers to pass the coordinates of the subsetted region to the handlers
68// Return the number of elements to read.
69int
70HDFEOS2ArrayMissGeoField::format_constraint (int *offset, int *step, int *count)
71{
72 int nels = 1;
73 int id = 0;
74
75 Dim_iter p = dim_begin ();
76 while (p != dim_end ()) {
77
78 int start = dimension_start (p, true);
79 int stride = dimension_stride (p, true);
80 int stop = dimension_stop (p, true);
81
82 // Check for illegal constraint
83 if (start > stop) {
84 ostringstream oss;
85 oss << "Array/Grid hyperslab start point "<< start <<
86 " is greater than stop point " << stop <<".";
87 throw Error(malformed_expr, oss.str());
88 }
89
90 offset[id] = start;
91 step[id] = stride;
92 count[id] = ((stop - start) / stride) + 1; // count of elements
93 nels *= count[id]; // total number of values for variable
94
95 BESDEBUG ("h4",
96 "=format_constraint():"
97 << "id=" << id << " offset=" << offset[id]
98 << " step=" << step[id]
99 << " count=" << count[id]
100 << endl);
101
102 id++;
103 p++;
104 }
105
106 return nels;
107}
108
109#endif
STL class.
STL class.