28 #ifndef _UgridUtilities_h 29 #define _UgridUtilities_h 1 31 #include <gridfields/array.h> 45 #define CF_ROLE "cf_role" 46 #define CF_STANDARD_NAME "standard_name" 47 #define UGRID_MESH_TOPOLOGY "mesh_topology" 48 #define UGRID_NODE_COORDINATES "node_coordinates" 49 #define UGRID_FACE_NODE_CONNECTIVITY "face_node_connectivity" 51 #define UGRID_TOPOLOGY_DIMENSION "topology_dimension" 52 #define UGRID_DIMENSION "dimension" // Old-style; still using in some ugrids. jhrg 5/19/15 53 #define UGRID_LOCATION "location" 54 #define UGRID_GRID_LOCATION "grid_location" 55 #define UGRID_NODE "node" 56 #define UGRID_EDGE "edge" 57 #define UGRID_FACE "face" 58 #define UGRID_MESH "mesh" 59 #define UGRID_START_INDEX "start_index" 64 #define UGRID_EDGE_NODE_CONNECTIVITY "edge_node_connectivity" 66 #define UGRID_FACE_COORDINATES "face_coordinates" 67 #define UGRID_EDGE_COORDINATES "edge_coordinates" 68 #define UGRID_FACE_EDGE_CONNECTIVITY "face_edge_connectivity" 69 #define UGRID_FACE_FACE_CONNECTIVITY "face_face_connectivity" 71 GF::Array *extractGridFieldArray(libdap::Array *a, vector<int*> *sharedIntArrays, vector<float*> *sharedFloatArrays);
72 GF::Array *newGFIndexArray(
string name,
long size, vector<int*> *sharedIntArrays);
74 string getAttributeValue(libdap::BaseType *bt,
string aName);
75 bool matchesCfRoleOrStandardName(libdap::BaseType *bt,
string aValue);
77 bool checkAttributeValue(libdap::BaseType *bt,
string aName,
string aValue);
79 vector<string> split(
const string &s,
char delim);
80 vector<string> &split(
const string &s,
char delim, vector<string> &elems);
82 int getNfrom3byNArray(libdap::Array *array);
91 template<
typename DODS,
typename T> T *extract_array_helper(libdap::Array *a)
93 int length = a->length();
95 DODS *src =
new DODS[length];
99 T *dest =
new T[length];
101 for (
int i = 0; i < length; ++i)
102 dest[i] = (T) src[i];
126 template<
typename T> T *extractArray(libdap::Array *a)
130 if ((a->type() == libdap::dods_array_c && !a->var()->is_simple_type()) || a->var()->type() == libdap::dods_str_c
131 || a->var()->type() == libdap::dods_url_c)
132 throw libdap::Error(malformed_expr,
"The function requires a DAP numeric-type array argument.");
140 switch (a->var()->type()) {
141 case libdap::dods_byte_c:
142 return extract_array_helper<libdap::dods_byte, T>(a);
144 case libdap::dods_uint16_c:
145 return extract_array_helper<libdap::dods_uint16, T>(a);
147 case libdap::dods_int16_c:
148 return extract_array_helper<libdap::dods_int16, T>(a);
150 case libdap::dods_uint32_c:
151 return extract_array_helper<libdap::dods_uint32, T>(a);
153 case libdap::dods_int32_c:
154 return extract_array_helper<libdap::dods_int32, T>(a);
156 case libdap::dods_float32_c:
158 return extract_array_helper<libdap::dods_float32, T>(a);
160 case libdap::dods_float64_c:
161 return extract_array_helper<libdap::dods_float64, T>(a);
164 throw libdap::InternalErr(__FILE__, __LINE__,
165 "The argument list built by the CE parser contained an unsupported numeric type.");
171 #endif // _UgridUtilities_h