32#include <BESInternalError.h>
37#include "FONcAttributes.h"
62 _grid =
dynamic_cast<Grid *
>(b);
64 string s = (string)
"File out netcdf, FONcGrid was passed a " +
"variable that is not a DAP Grid";
80 vector<FONcMap *>::iterator i = _maps.begin();
81 while (i != _maps.end()) {
107 BESDEBUG(
"fonc",
"FOncGrid::define - defining grid " << _varname << endl);
109 for (
auto map: _maps)
118 BESDEBUG(
"fonc",
"FOncGrid::define - done defining grid " << _varname << endl);
141 FONcBaseType::convert(embed, _dap4, is_dap4_group);
142 BESDEBUG(
"fonc",
"FONcGrid:: version: '" << _ncVersion <<
"'" << endl);
144 BESDEBUG(
"fonc",
"FONcGrid::convert - converting grid " << _varname << endl);
148 Grid::Map_iter mi = _grid->map_begin();
149 Grid::Map_iter me = _grid->map_end();
150 for (; mi != me; mi++) {
154 if ((*mi)->send_p()) {
156 Array *map =
dynamic_cast<Array *
>((*mi));
158 string err = (string)
"file out netcdf, grid " + _varname +
" map is not an array";
162 vector<string> map_embed;
164 map->intern_data(*get_eval(), *get_dds());
166 FONcMap *map_found = FONcGrid::InMaps(map);
176 fa->
convert(map_embed, _dap4,is_dap4_group);
177 map_found =
new FONcMap(fa,
true);
188 _maps.push_back(map_found);
195 if (_grid->get_array()->send_p()) {
196 _arr =
new FONcArray(_grid->get_array());
200 _arr->
convert(_embed, _dap4,is_dap4_group);
203 BESDEBUG(
"fonc",
"FONcGrid::convert - done converting grid " << _varname << endl);
218 BESDEBUG(
"fonc",
"FOncGrid::define - writing grid " << _varname << endl);
222 vector<FONcMap *>::iterator i = _maps.begin();
223 vector<FONcMap *>::iterator e = _maps.end();
224 for (; i != e; i++) {
235 BESDEBUG(
"fonc",
"FOncGrid::define - done writing grid " << _varname << endl);
244 return _grid->name();
257 strm << BESIndent::LMarg <<
"FONcGrid::dump - (" << (
void *)
this <<
")" << endl;
259 strm << BESIndent::LMarg <<
"name = " << _grid->name() <<
" { " << endl;
261 strm << BESIndent::LMarg <<
"maps:";
265 vector<FONcMap *>::const_iterator i = _maps.begin();
266 vector<FONcMap *>::const_iterator e = _maps.end();
267 for (; i != e; i++) {
271 BESIndent::UnIndent();
274 strm <<
" empty" << endl;
276 BESIndent::UnIndent();
277 strm << BESIndent::LMarg <<
"}" << endl;
278 strm << BESIndent::LMarg <<
"array:";
283 BESIndent::UnIndent();
286 strm <<
" not set" << endl;
288 BESIndent::UnIndent();
292FONcGrid::InMaps(Array *array)
298 for (; vi != ve && !found; vi++) {
303 found = map_found->
compare(array);
exception thrown if internal error encountered
A DAP Array with file out netcdf information included.
virtual void dump(std::ostream &strm) const override
dumps information about this object for debugging purposes
virtual void define(int ncid) override
define the DAP Array in the netcdf file
virtual void convert(std::vector< std::string > embed, bool _dap4=false, bool is_dap4_group=false) override
Converts the DAP Array to a FONcArray.
virtual void write(int ncid) override
Write the array out to the netcdf file.
A DAP BaseType with file out netcdf information included.
virtual void setNC4DataModel(const string &nc4_datamodel)
Identifies the netCDF4 data model (CLASSIC or ENHANCED)
virtual void setVersion(const std::string &version)
Identifies variable with use of NetCDF4 features.
FONcGrid(libdap::BaseType *b)
Constructor for FONcGrid that takes a DAP Grid.
virtual ~FONcGrid()
Destructor that cleans up the grid.
virtual void define(int ncid) override
define the DAP Grid in the netcdf file
virtual void convert(vector< string > embed, bool _dap4, bool is_dap4_group) override
convert the DAP Grid to a set of embedded variables
string name() override
returns the name of the DAP Grid
static vector< FONcMap * > Maps
global list of maps that could be shared amongst the different grids
virtual void write(int ncid) override
Write the maps and array for the grid.
static bool InGrid
tells whether we are converting or defining a grid.
virtual void dump(ostream &strm) const override
dumps information about this object for debugging purposes
A map of a DAP Grid with file out netcdf information included.
virtual void clear_embedded()
clear the embedded names for the FONcArray kept by this instance
virtual void dump(std::ostream &strm) const
dumps information about this object for debugging purposes
virtual void add_grid(const std::string &name)
Add the name of the grid as a grid that uses this map.
virtual bool compare(libdap::Array *arr)
a method to compare two grid maps, or possible grid maps.
static string gen_name(const vector< string > &embed, const string &name, string &original)
generate a new name for the embedded variable