bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
HDFDMRArray_SPLL.cc
1
2// This file is part of the hdf4 data handler for the OPeNDAP data server.
3// It retrieves HDF4 SDS values for a direct DMR-mapping DAP4 response.
4// Each SDS will be mapped to a DAP variable.
5
6// Authors: Kent Yang <myang6@hdfgroup.org>
7// Copyright (c) The HDF Group
9
10
11#include "HDFDMRArray_SPLL.h"
12#include "hdf.h"
13#include "mfhdf.h"
14#include <iostream>
15#include <sstream>
16#include <libdap/debug.h>
17#include <libdap/InternalErr.h>
18#include <BESDebug.h>
19
20using namespace std;
21using namespace libdap;
22
23
24bool
25HDFDMRArray_SPLL::read ()
26{
27
28 BESDEBUG("h4","Coming to HDFDMRArray_SPLL read "<<endl);
29
30 // Declaration of offset,count and step
31 vector<int>offset;
32 offset.resize(sds_rank);
33 vector<int>count;
34 count.resize(sds_rank);
35 vector<int>step;
36 step.resize(sds_rank);
37
38 // Obtain offset,step and count from the client expression constraint
39 int nelms = format_constraint(offset.data(),step.data(),count.data());
40
41 if (sp_type != 0)
42 throw InternalErr (__FILE__, __LINE__, "Currently we only support TRMM version 7");
43 vector<float> val;
44 val.resize(nelms);
45 for (int i = 0; i < nelms; ++i)
46 val[i] = ll_start+offset[0]*ll_res+ll_res/2 + i*ll_res*step[0];
47 set_value((dods_float32*)val.data(),nelms);
48 return true;
49}
50
51// Standard way to pass the coordinates of the subsetted region from the client to the handlers
52// Returns the number of elements
53int
54HDFDMRArray_SPLL::format_constraint (int *offset, int *step, int *count)
55{
56 int nels = 1;
57 int id = 0;
58
59 Dim_iter p = dim_begin ();
60 while (p != dim_end ()) {
61
62 int start = dimension_start (p, true);
63 int stride = dimension_stride (p, true);
64 int stop = dimension_stop (p, true);
65
66 // Check for illegal constraint
67 if (start > stop) {
68 ostringstream oss;
69 oss << "Array/Grid hyperslab start point "<< start <<
70 " is greater than stop point " << stop <<".";
71 throw Error(malformed_expr, oss.str());
72 }
73
74 offset[id] = start;
75 step[id] = stride;
76 count[id] = ((stop - start) / stride) + 1; // count of elements
77 nels *= count[id]; // total number of values for variable
78
79 BESDEBUG ("h4",
80 "=format_constraint():"
81 << "id=" << id << " offset=" << offset[id]
82 << " step=" << step[id]
83 << " count=" << count[id]
84 << endl);
85
86 id++;
87 p++;
88 }
89
90 return nels;
91}
92
93