36 #include <Structure.h>
42 #include <ServerFunctionsList.h>
60 static void check_number_type_array(BaseType *btp,
unsigned int rank)
63 throw InternalErr(__FILE__, __LINE__,
"roi() function called with null variable.");
65 if (btp->type() != dods_array_c)
66 throw Error(
"In function roi(): Expected argument '" + btp->name() +
"' to be an Array.");
68 Array *a =
static_cast<Array *
>(btp);
69 if (!a->var()->is_simple_type() || a->var()->type() == dods_str_c || a->var()->type() == dods_url_c)
70 throw Error(
"In function roi(): Expected argument '" + btp->name() +
"' to be an Array of numeric types.");
72 if (a->dimensions() < rank)
73 throw Error(
"In function roi(): Expected the array '" + a->name() +
"' to be rank " + long_to_string(rank) +
" or greater.");
100 const string wrong_args =
"Wrong number of arguments to roi(). Expected one or more Arrays and bounding box";
109 throw Error(malformed_expr, wrong_args);
113 for (
int i = 0; i < argc-1; ++i)
114 check_number_type_array(argv[i], rank);
118 auto_ptr<Structure> response(
new Structure(
"roi_subset"));
120 Array *bbox =
static_cast<Array*
>(argv[argc-1]);
122 for (
int i = 0; i < argc-1; ++i) {
124 Array *the_array =
static_cast<Array*
>(argv[i]);
125 BESDEBUG(
"roi",
"the_array: " << the_array->name() <<
": " << (
void*)the_array << endl);
134 unsigned int num_dims = the_array->dimensions();
136 for (
int i = rank-1; i >= 0; --i) {
143 Array::Dim_iter iter = the_array->dim_begin() + d;
147 if (the_array->dimension_name(iter) != name)
148 throw Error(
"In function roi(): Dimension name (" + the_array->dimension_name(iter) +
") and slice name (" + name +
") don't match");
151 BESDEBUG(
"roi",
"Dimension: " << i <<
", Start: " << start <<
", Stop: " << stop << endl);
152 the_array->add_constraint(iter, start, 1 , stop);
157 the_array->set_send_p(
true);
163 the_array->set_read_p(
false);
165 the_array->set_read_p(
true);
167 response->add_var(the_array);
170 response->set_send_p(
true);
171 response->set_read_p(
true);
173 *btpp = response.release();
188 throw Error(malformed_expr,
"Not yet implemented for DAP4 functions.");
void roi_bbox_get_slice_data(Array *slices, unsigned int i, int &start, int &stop, string &name)
This method extracts values from one element of the Bounding Box (i.e., Array of Structures).
BaseType * function_dap4_roi(D4RValueList *, DMR &)
Return the bounding box for an array.
unsigned int roi_valid_bbox(BaseType *btp)
Is the bound box valid?
static class NCMLUtil overview
void function_dap2_roi(int argc, BaseType *argv[], DDS &, BaseType **btpp)
Subset the N arrays using index slicing information.
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream