34#include "grid_utils.h"
35#include "gse_parser.h"
39#include "GridGeoConstraint.h"
45void gse_restart(FILE * in);
48void gse_delete_buffer(
void *buffer);
49void *gse_string(
const char *yy_str);
59void get_grids(
BaseType *bt, vector<Grid *> *grids)
65 grids->push_back(
static_cast<Grid*
>(bt));
68 case dods_structure_c: {
90void get_grids(
DDS &dds, vector<Grid *> *grids)
112bool is_geo_grid(
Grid *grid)
115 GridGeoConstraint gc(grid);
125void parse_gse_expression(gse_arg *arg,
BaseType *expr)
130 bool status = gse_parse(arg) == 0;
131 gse_delete_buffer(cls);
133 throw Error(malformed_expr,
"Error parsing grid selection.");
136static void apply_grid_selection_expr(
Grid *grid, GSEClause *clause)
140 Grid::Map_iter map_i = grid->map_begin();
141 while (map_i != grid->map_end() && (*map_i)->name() != clause->get_map_name())
144 if (map_i == grid->map_end())
145 throw Error(malformed_expr,
"The map vector '" + clause->get_map_name()
146 +
"' is not in the grid '" + grid->name() +
"'.");
149 Array::Dim_iter grid_dim = (grid->get_array()->dim_begin() + (map_i - grid->map_begin()));
151 Array *map =
dynamic_cast < Array *
>((*map_i));
153 throw InternalErr(__FILE__, __LINE__,
"Expected an Array");
154 int start = max(map->dimension_start(map->dim_begin()), clause->get_start());
155 int stop = min(map->dimension_stop(map->dim_begin()), clause->get_stop());
160 <<
"The expressions passed to grid() do not result in an inclusive \n"
161 <<
"subset of '" << clause->get_map_name()
162 <<
"'. The map's values range " <<
"from "
163 << clause->get_map_min_value() <<
" to "
164 << clause->get_map_max_value() <<
".";
165 throw Error(malformed_expr,msg.str());
168 DBG(cerr <<
"Setting constraint on " << map->name() <<
"[" << start <<
":" << stop <<
"]" << endl);
171 map->add_constraint(map->dim_begin(), start, 1, stop);
172 grid->get_array()->add_constraint(grid_dim, start, 1, stop);
175void apply_grid_selection_expressions(
Grid * grid, vector < GSEClause * >clauses)
177 vector < GSEClause * >::iterator clause_i = clauses.begin();
178 while (clause_i != clauses.end())
179 apply_grid_selection_expr(grid, *clause_i++);
181 grid->set_read_p(
false);
A multidimensional array of identical data types.
std::vector< dimension >::iterator Dim_iter
The basic data type for the DODS DAP types.
Vars_iter var_end()
Return an iterator.
A class for error processing.
Holds the Grid data type.
A class for software fault reporting.
Holds a structure (aggregate) type.
top level DAP object to house generic methods
string extract_string_argument(BaseType *arg)