83 string(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") +
84 "<function name=\"geogrid\" version=\"1.2\" href=\"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#geogrid\">\n"+
88 Str *response =
new Str(
"version");
89 response->set_value(info);
103 if (argc < 1 || !(l_grid = dynamic_cast < Grid * >(argv[0]->ptr_duplicate())))
104 throw Error(malformed_expr,
"The first argument to geogrid() must be a Grid variable!");
108 throw Error(malformed_expr,
"Wrong number of arguments to geogrid() (expected at least 5 args). See geogrid() for more information.");
110 bool grid_lat_lon_form;
113 if (!(l_lat = dynamic_cast < Array * >(argv[1])))
114 grid_lat_lon_form =
false;
115 else if (!(l_lon = dynamic_cast < Array * >(argv[2])))
116 throw Error(malformed_expr,
"When using the Grid, Lat, Lon form of geogrid() both the lat and lon maps must be given (lon map missing)!");
118 grid_lat_lon_form =
true;
120 if (grid_lat_lon_form && argc < 7)
121 throw Error(malformed_expr,
"Wrong number of arguments to geogrid() (expected at least 7 args). See geogrid() for more information.");
124 Grid *l_grid = dynamic_cast < Grid * >(argv[0]->ptr_duplicate());
126 throw Error(malformed_expr,
"The first argument to geogrid() must be a Grid variable!");
138 Grid::Map_iter i = l_grid->map_begin();
139 while (i != l_grid->map_end())
140 (*i++)->set_send_p(
true);
146 l_grid->get_array()->set_read_p(
false);
150 int min_arg_count = (grid_lat_lon_form) ? 7 : 5;
151 if (argc > min_arg_count) {
154 vector < GSEClause * > clauses;
156 for (
int i = min_arg_count; i < argc; ++i) {
173 int box_index_offset = (grid_lat_lon_form) ? 3 : 1;
174 double top = extract_double_value(argv[box_index_offset]);
175 double left = extract_double_value(argv[box_index_offset + 1]);
176 double bottom = extract_double_value(argv[box_index_offset + 2]);
177 double right = extract_double_value(argv[box_index_offset + 3]);
179 DBG(cerr <<
"geogrid: past bounding box set" << endl);
183 DBG(cerr <<
"geogrid: past apply constraint" << endl);
193 catch (exception & e) {
196 (
"A C++ exception was thrown from inside geogrid(): ")
222 vector<Grid *>::iterator git;
223 for(git=grids.begin(); !usable && git!=grids.end() ; git++){
void getGrids(BaseType *bt, vector< Grid * > *grids)
Recursively traverses the BaseType bt (if its a constructor type) and collects pointers to all of the...
void apply_grid_selection_expressions(Grid *grid, vector< GSEClause * >clauses)
bool isGeoGrid(Grid *grid)
Evaluates a Grid to see if has suitable semantics for use with function_geogrid.
void set_bounding_box(double top, double left, double bottom, double right)
Set the bounding box for this constraint.
virtual Grid * get_constrained_grid() const
Argument to the GSE parser.
bool canOperateOn(DDS &dds)
The passed DDS parameter dds is evaluated to see if it contains Grid objects whose semantics allow th...
void parse_gse_expression(gse_arg *arg, BaseType *expr)
void function_geogrid(int argc, BaseType *argv[], DDS &, BaseType **btpp)
The geogrid function returns the part of a Grid which includes a geographically specified rectangle...
Geographical constraint applied to a grid.
virtual void apply_constraint_to_data()
Once the bounding box is set use this method to apply the constraint.