110 DBG(cerr << __func__ <<
"() - BEGIN (name:" <<
name() <<
")(type:" <<
type_name() <<
")(root:'" << root->
name()
111 <<
"':" << (
void *)root <<
")(container:'" << container->
name() <<
"':" << (
void *)container <<
")"
114 vector<Array *> d4_map_arrays;
123 DBG(cerr << __func__ <<
"() - Processing Map Array: '" << (*i)->name() <<
"' (" << (
void *)(*i) <<
")"
130 Array *the_map_array;
131 Array *container_map_array =
static_cast<Array *
>(container->
var((*i)->name()));
132 if (!container_map_array) {
133 DBG(cerr << __func__ <<
"() - No Map Array '" << (*i)->name() <<
"' present in the current DAP4 container ("
134 << container->
name() <<
":" << (
void *)container <<
"). Let's fix that..." << endl;);
136 Array *root_map_array =
static_cast<Array *
>(root->
var((*i)->name()));
137 if (!root_map_array) {
139 DBG(cerr << __func__ <<
"() - No Map Array '" << (*i)->name() <<
"' present in the root Group ("
140 << root->
name() <<
":" << (
void *)root <<
"). Let's fix that..." << endl;);
142 (*i)->transform_to_dap4(root, container);
144 the_map_array =
static_cast<Array *
>(container->
var((*i)->name()));
145 DBG(cerr << __func__ <<
"() - Transformed array '" << the_map_array->
name() <<
"' to DAP4 Array ("
146 << (
void *)the_map_array <<
") added to container: '" << container->
name() <<
"'" << endl;);
148 the_map_array = root_map_array;
149 DBG(cerr << __func__ <<
"() - Located Map Array '" << the_map_array->
name() <<
"' ("
150 << (
void *)the_map_array <<
") present in the root group (" << root->
name() <<
":"
151 << (
void *)root <<
")" << endl;);
154 the_map_array = container_map_array;
155 DBG(cerr << __func__ <<
"() - Located Map Array '" << the_map_array->
name() <<
"' ("
156 << (
void *)the_map_array <<
") present in the current DAP4 container (" << container->
name() <<
":"
157 << (
void *)container <<
")" << endl;);
160 d4_map_arrays.push_back(the_map_array);
168 DBG(cerr << __func__ <<
"() - Transformed and added DAP4 coverage Array '" << coverage->
name()
169 <<
"' to parent container: '" << container->
name() <<
"'" << endl;);
173 DBG(cerr << __func__ <<
"() - " <<
"Coverage Array '" << coverage->
name() <<
"' attributes: " << endl;
179 for (; d4aItr != end; d4aItr++) {
180 Array *the_map_array = *d4aItr;
186 D4Map *d4_map =
new D4Map(the_map_array->
FQN(), the_map_array);
191 DBG(cerr << __func__ <<
"() - Added DAP4 Map Array: '" << d4_map->
name() <<
"' (" << (
void *)d4_map->
array()
192 <<
") to coverage: '" << coverage->
name() <<
"'" << endl;);
194 DBG(cerr << __func__ <<
"() - END (grid:" <<
name() <<
")" << endl;);
218 throw InternalErr(__FILE__, __LINE__,
"Passing NULL pointer as variable to be added.");
221 throw Error(
string(
"A method usable only with DAP2 variables was called on a DAP4 variable (")
226 if (part ==
array && d_is_array_set ) {
229 "Error: Grid::add_var called with part==Array, but the array was already set!");
233 if (!
dynamic_cast<Array *
>(bt)) {
234 throw InternalErr(__FILE__, __LINE__,
"Grid::add_var(): object is not an Array!");
251 d_vars.push_back(bt_clone);
255 if (!d_is_array_set ) {
262 d_vars.push_back(bt_clone);
285 throw InternalErr(__FILE__, __LINE__,
"Passing NULL pointer as variable to be added.");
288 throw Error(
string(
"A method usable only with DAP2 variables was called on a DAP4 variable (")
293 if (part ==
array && d_is_array_set ) {
296 "Error: Grid::add_var called with part==Array, but the array was already set!");
300 if (!
dynamic_cast<Array *
>(bt)) {
301 throw InternalErr(__FILE__, __LINE__,
"Grid::add_var(): object is not an Array!");
320 if (!d_is_array_set ) {
346 throw InternalErr(__FILE__, __LINE__,
"Grid::set_array(): Cannot set to null!");
361 d_vars.push_back(p_new_arr);
362 }
else if (!d_is_array_set ) {
370 d_is_array_set =
true;
401 throw InternalErr(__FILE__, __LINE__,
"Grid::add_map(): cannot have p_new_map null!");
408 d_vars.push_back(p_new_map);
453 return d_is_array_set ?
d_vars.begin() + 1 :
d_vars.begin();
497 if ((*i)->send_p()) {
515 <<
" (at_container:" << at_container->
get_name() <<
":" << (
void *)at_container <<
")" << endl;);
520 DBG(cerr << __func__ <<
"() - Found AttrTable (" << at->
get_name() <<
":" << (
void *)at <<
")" << endl;);
542 (*map)->transfer_attributes(at);
552 DBG(cerr << __func__ <<
"() - " <<
"Adding unclaimed Attribute (" << at->
get_type(at_p) <<
":"
553 << at->
get_name(at_p) <<
":" << (
void *)(*map) <<
") from AttrTable (" << at->
get_name() <<
":"
554 << (
void *)at <<
")" <<
" to the variable " <<
type_name() <<
" " <<
name() << endl;);
560 (*at_p)->is_utf8_str);
566 DBG(cerr << __func__ <<
"() - No AttrTable named '" <<
name() <<
"' was found in at_container ("
567 << at_container->
get_name() <<
":" << (
void *)at <<
")" << endl;);
569 DBG(cerr << __func__ <<
"() - END " <<
type_name() <<
" " <<
name() <<
" (at_container:" << at_container->
get_name()
570 <<
":" << (
void *)at_container <<
")" << endl;);
619 valid = map.dimension_start(fd,
true) == a->
dimension_start(d,
true) &&
639void Grid::print_decl(FILE *out,
string space,
bool print_semi,
bool constraint_info,
bool constrained) {
641 print_decl(oss, space, print_semi, constraint_info, constrained);
642 fwrite(oss.str().data(),
sizeof(
char), oss.str().length(), out);
645void Grid::print_decl(ostream &out,
string space,
bool print_semi,
bool constraint_info,
bool constrained) {
646 if (constrained && !
send_p())
651 out << space <<
"Structure {\n";
656 (*i)->print_decl(out, space +
" ",
true, constraint_info, constrained);
665 out << space <<
" Array:\n";
668 out << space <<
" Maps:\n";
670 (*i)->print_decl(out, space +
" ",
true, constraint_info, constrained);
676 if (constraint_info) {
678 out <<
": Send True";
680 out <<
": Send False";
708 if (constrained && !
send_p())
712 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar *)
"Structure") < 0)
713 throw InternalErr(__FILE__, __LINE__,
"Could not write Structure element");
715 if (!
name().empty() &&
716 xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"name", (
const xmlChar *)
name().c_str()) < 0)
717 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
726 auto a =
dynamic_cast<Array *
>(*m);
728 throw InternalErr(__FILE__, __LINE__,
"Expected an Array.");
729 a->print_xml_writer_core(xml, constrained,
"Array");
732 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
733 throw InternalErr(__FILE__, __LINE__,
"Could not end Structure element");
737 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar *)
"Grid") < 0)
738 throw InternalErr(__FILE__, __LINE__,
"Could not write Grid element");
741 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"name",
742 (
const xmlChar *)
name().c_str()) < 0)
743 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
752 auto a =
dynamic_cast<Array *
>(*m);
754 throw InternalErr(__FILE__, __LINE__,
"Expected an Array.");
755 a->print_xml_writer_core(xml, constrained,
"Map");
758 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
759 throw InternalErr(__FILE__, __LINE__,
"Could not end Grid element");
766 fwrite(oss.str().data(),
sizeof(
char), oss.str().length(), out);
791 (*i)->print_val(out,
"",
false);
813 msg +=
"Null grid base array in `" +
name() +
"'\n";
819 msg +=
"Grid `" +
name() +
"'s' member `" +
get_array()->
name() +
"' must be an array\n";
827 msg +=
"The field variable `" + this->
name() +
828 "' must be an array of simple type elements (e.g., int32, String)\n";
835 "The number of map variables for grid `" + this->
name() +
"' does not match the number of dimensions of `";
836 msg += av->
name() +
"'\n";
840 const string array_var_name = av->
name();
847 if (array_var_name == mv->
name()) {
849 "Grid map variable `" + mv->
name() +
"' conflicts with the grid array name in grid `" +
name() +
"'\n";
854 msg +=
"Grid map variable `" + mv->
name() +
"' is not an array\n";
862 msg +=
"The field variable `" + this->
name() +
863 "' must be an array of simple type elements (e.g., int32, String)\n";
869 msg +=
"Grid map variable `" + mv_a->
name() +
"' must be only one dimension\n";
876 if (mv_a_size != av_size) {
877 msg +=
"Grid map variable `" + mv_a->
name() +
"'s' size does not match the size of array variable '";
878 msg +=
get_array()->
name() +
"'s' cooresponding dimension\n";
887 if (!(*mvi)->check_semantics(msg,
true)) {
905 strm <<
DapIndent::LMarg <<
"Grid::dump - (" << (
void *)
this <<
")" << endl;
A multidimensional array of identical data types.
virtual int dimension_start(Dim_iter i, bool constrained=false)
Return the start index of a dimension.
virtual void clear_constraint()
Clears the projection; add each projected dimension explicitly using add_constraint.
virtual int dimension_stop(Dim_iter i, bool constrained=false)
Return the stop index of the constraint.
void print_decl(ostream &out, string space=" ", bool print_semi=true, bool constraint_info=false, bool constrained=false) override
Prints a DDS entry for the Array.
void print_val(ostream &out, string space="", bool print_decl_p=true) override
Prints the value of the variable.
BaseType * ptr_duplicate() override
std::vector< dimension >::iterator Dim_iter
virtual int dimension_size(Dim_iter i, bool constrained=false)
Returns the size of the dimension.
void print_xml_writer(XMLWriter &xml, bool constrained=false) override
virtual unsigned int dimensions(bool constrained=false)
Return the total number of dimensions in the array.
virtual int dimension_stride(Dim_iter i, bool constrained=false)
Returns the stride value of the constraint.
Contains the attributes for a dataset.
virtual AttrTable * append_container(const string &name)
Add a container to the attribute table.
virtual AttrTable * get_attr_table(const string &name)
Get an attribute container.
virtual Attr_iter attr_end()
virtual string get_type(const string &name)
Get the type name of an attribute within this attribute table.
virtual bool is_global_attribute() const
virtual vector< string > * get_attr_vector(const string &name)
Get a vector-valued attribute.
virtual unsigned int append_attr(const string &name, const string &type, const string &value)
Add an attribute to the table.
virtual Attr_iter attr_begin()
void print_dap4(XMLWriter &xml)
virtual string get_name() const
Get the name of this attribute table.
virtual void set_is_global_attribute(bool ga)
void print_xml_writer(XMLWriter &xml)
std::vector< entry * >::iterator Attr_iter
virtual AttrType get_attr_type(const string &name)
Get the type of an attribute.
The basic data type for the DODS DAP types.
virtual string type_name() const
Returns the type of the class instance as a string.
virtual AttrTable & get_attr_table()
virtual string name() const
Returns the name of the class instance.
virtual void set_parent(BaseType *parent)
virtual bool is_dap4() const
virtual D4Attributes * attributes()
virtual std::string FQN() const
virtual bool send_p()
Should this variable be sent?
virtual bool is_simple_type() const
Returns true if the instance is a numeric, string or URL type variable.
virtual BaseType * ptr_duplicate()=0
virtual void transform_to_dap4(D4Group *root, Constructor *container)
DAP2 to DAP4 transform.
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.
virtual Type type() const
Returns the type of the class instance.
BaseType * var(const string &name, bool exact_match=true, btp_stack *s=nullptr) override
btp_stack no longer needed; use back pointers (BaseType::get_parent())
std::vector< BaseType * > d_vars
Constructor & operator=(const Constructor &rhs)
Constructor(const string &name, const Type &type, bool is_dap4=false)
void dump(ostream &strm) const override
dumps information about this object
void transform_to_dap4(AttrTable &at)
copy attributes from DAP2 to DAP4
Array * array(D4Group *root)
This will always return the correct pointer for a valid data set.
const string & name() const
static ostream & LMarg(ostream &strm)
A class for error processing.
virtual BaseType * ptr_duplicate()
std::vector< BaseType * >::const_iterator Map_citer
BaseType * array_var()
Returns the Grid Array.
virtual void transform_to_dap4(D4Group *root, Constructor *container)
DAP2 to DAP4 transform.
virtual void print_xml(ostream &out, string space=" ", bool constrained=false)
Map_iter map_begin()
Returns an iterator referencing the first Map vector.
Map_iter get_map_iter(int i)
virtual void set_array(Array *p_new_arr)
virtual void clear_constraint()
virtual void print_val(ostream &out, string space="", bool print_decl_p=true)
Prints the value of the variable.
virtual void print_decl(ostream &out, string space=" ", bool print_semi=true, bool constraint_info=false, bool constrained=false)
Print an ASCII representation of the variable structure.
virtual Array * prepend_map(Array *p_new_map, bool add_copy)
std::vector< BaseType * >::reverse_iterator Map_riter
Grid(const string &n)
The Grid constructor.
void m_duplicate(const Grid &s)
std::vector< BaseType * >::iterator Map_iter
Array * get_array()
Returns the Grid Array. This method returns the array using an Array*, so no cast is required.
virtual void transfer_attributes(AttrTable *at_container)
virtual bool projection_yields_grid()
virtual void dump(ostream &strm) const
dumps information about this object
virtual Array * add_map(Array *p_new_map, bool add_copy)
virtual int components(bool constrained=false)
Returns the number of components in the Grid object.
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
virtual bool check_semantics(string &msg, bool all=false)
Return true if this Grid is well formed.
virtual void add_var(BaseType *bt, Part part)
Grid & operator=(const Grid &rhs)
virtual void add_var_nocopy(BaseType *bt, Part part)
Map_riter map_rbegin()
Returns an iterator referencing the first Map vector.
virtual bool is_dap2_only_type()
A class for software fault reporting.
BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=nullptr) override
unsigned int get_doc_size()
xmlTextWriterPtr get_writer() const
top level DAP object to house generic methods
Part
Names the parts of multi-section constructor data types.
string id2www(string in, const string &allowable)