38#include "GeoGridFunction.h"
39#include "GridGeoConstraint.h"
40#include "gse_parser.h"
41#include "grid_utils.h"
82function_geogrid(
int argc, BaseType *argv[], DDS &, BaseType **btpp)
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.");
126 Grid *l_grid =
dynamic_cast < Grid *
>(argv[0]->
ptr_duplicate());
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;
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);
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(): ")
217 get_grids(dds, &grids);
225 for(git=grids.begin(); !usable && git!=grids.end() ; git++){
227 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)