38 #include "GridFunction.h" 39 #include "gse_parser.h" 40 #include "grid_utils.h" 76 function_grid(
int argc, BaseType *argv[], DDS &, BaseType **btpp)
78 DBG(cerr <<
"Entering function_grid..." << endl);
81 string(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") +
82 "<function name=\"grid\" version=\"1.0\" href=\"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#grid\">\n" +
86 Str *response =
new Str(
"info");
87 response->set_value(info);
92 Grid *original_grid = dynamic_cast < Grid * >(argv[0]);
94 throw Error(malformed_expr,
"The first argument to grid() must be a Grid variable!");
98 BaseType *btp = original_grid->ptr_duplicate();
99 Grid *l_grid = dynamic_cast < Grid * >(btp);
102 throw InternalErr(__FILE__, __LINE__,
"Expected a Grid.");
105 DBG(cerr <<
"grid: past initialization code" << endl);
113 Grid::Map_iter i = l_grid->map_begin();
114 while (i != l_grid->map_end())
115 (*i++)->set_send_p(
true);
119 DBG(cerr <<
"grid: past map read" << endl);
125 vector < GSEClause * > clauses;
126 gse_arg *arg =
new gse_arg(l_grid);
127 for (
int i = 1; i < argc; ++i) {
128 parse_gse_expression(arg, argv[i]);
129 clauses.push_back(arg->get_gsec());
134 apply_grid_selection_expressions(l_grid, clauses);
136 DBG(cerr <<
"grid: past gse application" << endl);
138 l_grid->get_array()->set_send_p(
true);
157 bool GridFunction::canOperateOn(DDS &dds) {
159 vector<Grid *> grids;
160 getGrids(dds, &grids);
162 return !grids.empty();