38#include "GeoGridFunction.h"
39#include "GridGeoConstraint.h"
40#include "grid_utils.h"
41#include "gse_parser.h"
81void function_geogrid(
int argc, BaseType *argv[], DDS &, BaseType **btpp) {
82 string info = string(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") +
83 "<function name=\"geogrid\" version=\"1.2\" "
84 "href=\"http://docs.opendap.org/index.php/Server_Side_Processing_Functions#geogrid\">\n" +
88 Str *response =
new Str(
"version");
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!");
110 "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 "
119 "given (lon map missing)!");
121 grid_lat_lon_form =
true;
123 if (grid_lat_lon_form && argc < 7)
126 "Wrong number of arguments to geogrid() (expected at least 7 args). See geogrid() for more information.");
129 Grid *l_grid =
dynamic_cast < Grid *
>(argv[0]->
ptr_duplicate());
131 throw Error(malformed_expr,
"The first argument to geogrid() must be a Grid variable!");
145 (*i++)->set_send_p(
true);
155 int min_arg_count = (grid_lat_lon_form) ? 7 : 5;
156 if (argc > min_arg_count) {
159 vector<GSEClause *> clauses;
161 for (
int i = min_arg_count; i < argc; ++i) {
162 parse_gse_expression(arg, argv[i]);
163 clauses.push_back(arg->get_gsec());
168 apply_grid_selection_expressions(l_grid, clauses);
178 int box_index_offset = (grid_lat_lon_form) ? 3 : 1;
183 gc.set_bounding_box(top, left, bottom, right);
184 DBG(cerr <<
"geogrid: past bounding box set" << endl);
187 gc.apply_constraint_to_data();
188 DBG(cerr <<
"geogrid: past apply constraint" << endl);
192 *btpp = gc.get_constrained_grid();
196 }
catch (exception &e) {
197 throw InternalErr(
string(
"A C++ exception was thrown from inside geogrid(): ") + e.what());
212 vector<Grid *> grids;
213 get_grids(dds, &grids);
216 if (!grids.empty()) {
221 for (git = grids.begin(); !usable && git != grids.end(); git++) {
223 usable = is_geo_grid(grid);
bool canOperateOn(libdap::DDS &dds)
virtual BaseType * ptr_duplicate()=0
bool read() override
Read the elements of Constructor marked for transmission.
Holds the Grid data type.
Map_iter map_begin()
Returns an iterator referencing the first Map vector.
Array * get_array()
Returns the Grid Array. This method returns the array using an Array*, so no cast is required.
virtual bool set_value(const string &value)
void set_read_p(bool state) override
Indicates that the data is ready to send.
top level DAP object to house generic methods
double extract_double_value(BaseType *arg)