38 #include "GeoGridFunction.h" 39 #include "GridGeoConstraint.h" 40 #include "gse_parser.h" 41 #include "grid_utils.h" 85 string(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") +
86 "<function name=\"geogrid\" version=\"1.2\" href=\"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#geogrid\">\n"+
90 Str *response =
new Str(
"version");
105 if (argc < 1 || !(l_grid = dynamic_cast < Grid * >(argv[0]->ptr_duplicate())))
106 throw Error(malformed_expr,
"The first argument to geogrid() must be a Grid variable!");
110 throw Error(malformed_expr,
"Wrong number of arguments to geogrid() (expected at least 5 args). See geogrid() for more information.");
112 bool grid_lat_lon_form;
115 if (!(l_lat = dynamic_cast < Array * >(argv[1])))
116 grid_lat_lon_form =
false;
117 else if (!(l_lon = dynamic_cast < Array * >(argv[2])))
118 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)!");
120 grid_lat_lon_form =
true;
122 if (grid_lat_lon_form && argc < 7)
123 throw Error(malformed_expr,
"Wrong number of arguments to geogrid() (expected at least 7 args). See geogrid() for more information.");
128 throw Error(malformed_expr,
"The first argument to geogrid() must be a Grid variable!");
142 (*i++)->set_send_p(
true);
152 int min_arg_count = (grid_lat_lon_form) ? 7 : 5;
153 if (argc > min_arg_count) {
156 vector < GSEClause * > clauses;
157 gse_arg *arg =
new gse_arg(l_grid);
158 for (
int i = min_arg_count; i < argc; ++i) {
159 parse_gse_expression(arg, argv[i]);
160 clauses.push_back(arg->get_gsec());
165 apply_grid_selection_expressions(l_grid, clauses);
171 GridGeoConstraint gc(l_grid);
175 int box_index_offset = (grid_lat_lon_form) ? 3 : 1;
180 gc.set_bounding_box(top, left, bottom, right);
181 DBG(cerr <<
"geogrid: past bounding box set" << endl);
184 gc.apply_constraint_to_data();
185 DBG(cerr <<
"geogrid: past apply constraint" << endl);
189 *btpp = gc.get_constrained_grid();
195 catch (exception & e) {
198 (
"A C++ exception was thrown from inside geogrid(): ")
210 bool GeoGridFunction::canOperateOn(
DDS &dds)
217 get_grids(dds, &grids);
224 vector<Grid *>::iterator git;
225 for(git=grids.begin(); !usable && git!=grids.end() ; git++){
227 usable = is_geo_grid(grid);
virtual void set_read_p(bool state)
Indicates that the data is ready to send.
top level DAP object to house generic methods
A class for software fault reporting.
Holds character string data.
Map_iter map_begin()
Returns an iterator referencing the first Map vector.
virtual bool read()
simple implementation of read that iterates through vars and calls read on them
Holds the Grid data type.
virtual bool set_value(const string &value)
Array * get_array()
Returns the Grid Array. This method returns the array using an Array*, so no cast is required...
double extract_double_value(BaseType *arg)
virtual BaseType * ptr_duplicate()=0
The basic data type for the DODS DAP types.
A class for error processing.
A multidimensional array of identical data types.