42#include <dods-datatypes.h>
44#include <InternalErr.h>
60compare(T elem, relop op,
double value)
65 case dods_greater_equal_op:
69 case dods_less_equal_op:
73 case dods_not_equal_op:
76 throw Error(malformed_expr,
"Attempt to use NOP in Grid selection.");
78 throw Error(malformed_expr,
"Unknown relational operator in Grid selection.");
85GSEClause::set_map_min_max_value(T min, T max)
87 DBG(cerr <<
"Inside set map min max value " << min <<
", " << max << endl);
88 std::ostringstream oss1;
90 d_map_min_value = oss1.str();
92 std::ostringstream oss2;
94 d_map_max_value = oss2.str();
100GSEClause::set_start_stop()
102 T *vals =
new T[d_map->
length()];
107 set_map_min_max_value<T>(vals[d_start], vals[d_stop]);
116 while (i <= end && !compare<T>(vals[i], d_op1, d_value1))
124 while (i >= 0 && !compare<T>(vals[i], d_op1, d_value1))
132 if (d_op2 != dods_nop_op) {
135 while (i <= end && !compare<T>(vals[i], d_op2, d_value2))
141 while (i >= 0 && !compare<T>(vals[i], d_op2, d_value2))
151GSEClause::compute_indices()
153 switch (d_map->
var()->
type()) {
155 set_start_stop<dods_byte>();
158 set_start_stop<dods_int16>();
161 set_start_stop<dods_uint16>();
164 set_start_stop<dods_int32>();
167 set_start_stop<dods_uint32>();
170 set_start_stop<dods_float32>();
173 set_start_stop<dods_float64>();
176 throw Error(malformed_expr,
177 "Grid selection using non-numeric map vectors is not supported");
185GSEClause::GSEClause(
Grid *grid,
const string &map,
const double value,
188 d_value1(value), d_value2(0), d_op1(op), d_op2(dods_nop_op),
189 d_map_min_value(
""), d_map_max_value(
"")
191 d_map =
dynamic_cast<Array *
>(grid->
var(map));
193 throw Error(
string(
"The map variable '") + map
194 +
string(
"' does not exist in the grid '")
195 + grid->
name() +
string(
"'."));
197 DBG(cerr << d_map->toString());
201 d_start = d_map->dimension_start(iter);
202 d_stop = d_map->dimension_stop(iter);
208GSEClause::GSEClause(
Grid *grid,
const string &map,
const double value1,
209 const relop op1,
const double value2,
const relop op2)
211 d_value1(value1), d_value2(value2), d_op1(op1), d_op2(op2),
212 d_map_min_value(
""), d_map_max_value(
"")
214 d_map =
dynamic_cast<Array *
>(grid->
var(map));
216 throw Error(
string(
"The map variable '") + map
217 +
string(
"' does not exist in the grid '")
218 + grid->
name() +
string(
"'."));
220 DBG(cerr << d_map->toString());
224 d_start = d_map->dimension_start(iter);
225 d_stop = d_map->dimension_stop(iter);
230GSEClause::~GSEClause()
251GSEClause::get_map()
const
269GSEClause::get_map_name()
const
271 return d_map->
name();
278GSEClause::get_start()
const
286GSEClause::set_start(
int start)
295GSEClause::get_stop()
const
297 DBG(cerr <<
"Returning stop index value of: " << d_stop << endl);
304GSEClause::set_stop(
int stop)
314GSEClause::get_map_min_value()
const
316 return d_map_min_value;
324GSEClause::get_map_max_value()
const
326 return d_map_max_value;
A multidimensional array of identical data types.
std::vector< dimension >::iterator Dim_iter
virtual string name() const
Returns the name of the class instance.
virtual Type type() const
Returns the type of the class instance.
BaseType * var(const string &name, bool exact_match=true, btp_stack *s=nullptr) override
btp_stack no longer needed; use back pointers (BaseType::get_parent())
A class for error processing.
Holds the Grid data type.
int length() const override
Returns the number of elements in the vector. Note that some child classes of Vector use the length o...
BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=nullptr) override
top level DAP object to house generic methods