bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
HDFEOS2GeoCF1D.cc
1
2// This file is part of the hdf4 data handler for the OPeNDAP data server.
3// Authors: Kent Yang <myang6@hdfgroup.org>
4// Copyright (c) The HDF Group
6#ifdef USE_HDFEOS2_LIB
7
8#include "HDFEOS2GeoCF1D.h"
9#include <iostream>
10#include <sstream>
11#include <cassert>
12#include <libdap/debug.h>
13
14#include <libdap/InternalErr.h>
15#include <BESDebug.h>
16
17using namespace libdap;
18
19bool HDFEOS2GeoCF1D::read()
20{
21 if (length() == 0)
22 return true;
23
24 // Declaration of offset,count and step
25 vector<int> offset;
26 offset.resize(1);
27 vector<int> count;
28 count.resize(1);
29 vector<int> step;
30 step.resize(1);
31
32 // Obtain offset,step and count from the client expression constraint
33 int nelms = -1;
34 nelms = format_constraint(offset.data(), step.data(), count.data());
35
37 val.resize(tnumelm);
38
39 //HFRHANDLER-303, the number of element represents cells according
40 //to the data scientist at LP DAAC.
41
42
43 double step_v = (evalue - svalue)/tnumelm;
44
45 // Use meter instead of km. KY 2016-04-22
46 val[0] = svalue;
47 for(int i = 1;i<tnumelm; i++)
48 val[i] = val[i-1] + step_v;
49
50 if (nelms == tnumelm) {
51 set_value((dods_float64 *) val.data(), nelms);
52 }
53 else {
54 vector<double>val_subset;
55 val_subset.resize(nelms);
56 for (int i = 0; i < count[0]; i++)
57 val_subset[i] = val[offset[0] + step[0] * i];
58 set_value((dods_float64 *) val_subset.data(), nelms);
59 }
60
61 return false;
62}
63
64// Standard way of DAP handlers to pass the coordinates of the subsetted region to the handlers
65// Return the number of elements to read.
66int
67HDFEOS2GeoCF1D::format_constraint (int *offset, int *step, int *count)
68{
69
70 int nels = 1;
71 int id = 0;
72
73 Dim_iter p = dim_begin ();
74 while (p != dim_end ()) {
75
76 int start = dimension_start (p, true);
77 int stride = dimension_stride (p, true);
78 int stop = dimension_stop (p, true);
79
80 // Check for illegal constraint
81 if (start > stop) {
82 ostringstream oss;
83 oss << "Array/Grid hyperslab start point "<< start <<
84 " is greater than stop point " << stop <<".";
85 throw Error(malformed_expr, oss.str());
86 }
87
88 offset[id] = start;
89 step[id] = stride;
90 count[id] = ((stop - start) / stride) + 1; // count of elements
91 nels *= count[id]; // total number of values for variable
92
93 BESDEBUG ("h4",
94 "=format_constraint():"
95 << "id=" << id << " offset=" << offset[id]
96 << " step=" << step[id]
97 << " count=" << count[id]
98 << endl);
99
100 id++;
101 p++;
102 }
103
104 return nels;
105}
106
107
108#endif
STL class.
STL class.