37 #include "FONcUtils.h"
41 #include "FONcUByte.h"
43 #include "FONcShort.h"
44 #include "FONcUShort.h"
47 #include "FONcInt64.h"
48 #include "FONcUInt64.h"
49 #include "FONcFloat.h"
50 #include "FONcDouble.h"
51 #include "FONcStructure.h"
53 #include "FONcArray.h"
54 #include "FONcSequence.h"
56 #include <BESInternalError.h>
58 #include <D4Dimensions.h>
70 FONcArray::Dimensions.clear();
72 FONcDim::DimNameNum = 0;
87 string allowed =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+_.@";
90 string first =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
92 string::size_type i = 0;
94 while ((i = in.find_first_not_of(allowed, i)) != string::npos) {
95 in.replace(i, 1,
"_");
99 if (first.find(in[0]) == string::npos) {
114 nc_type x_type = NC_NAT;
116 string var_type = element->type_name();
117 if (var_type ==
"Byte") {
123 else if(var_type ==
"Int8") {
127 else if(var_type ==
"UInt8") {
131 else if (var_type ==
"String")
133 else if (var_type ==
"Int16")
140 else if (var_type ==
"UInt16"){
146 else if (var_type ==
"Int32")
148 else if (var_type ==
"UInt32"){
154 else if (var_type ==
"Int64")
159 else if (var_type ==
"UInt64"){
165 else if (var_type ==
"Float32")
167 else if (var_type ==
"Float64")
192 vector<string>::const_iterator i = embed.begin();
193 vector<string>::const_iterator e = embed.end();
195 for (; i != e; i++) {
199 new_name += FONC_EMBEDDED_SEPARATOR + (*i);
205 new_name += FONC_EMBEDDED_SEPARATOR + name;
226 map<string,int>fdimname_to_id;
228 return convert(v,ncdf_version, is_classic_model,fdimname_to_id,rds_nums);
244 FONcUtils::convert(BaseType *v,
const string &ncdf_version,
const bool is_classic_model, map<string,int>&fdimname_to_id,vector<int>&rbs_nums)
249 bool is_netcdf4_enhanced =
false;
250 if(ncdf_version == RETURNAS_NETCDF4 && is_classic_model ==
false)
251 is_netcdf4_enhanced =
true;
260 if(
true == is_netcdf4_enhanced)
267 if(
true == is_netcdf4_enhanced)
274 case dods_uint16_c: {
275 if(
true == is_netcdf4_enhanced)
284 case dods_uint32_c: {
285 if(
true == is_netcdf4_enhanced)
294 case dods_uint64_c: {
295 if(
true == is_netcdf4_enhanced)
302 if(
true == is_netcdf4_enhanced)
320 if(fdimname_to_id.size()>0) {
322 vector<bool> use_d4_dim_ids;
323 Array *t_a =
dynamic_cast<Array *
>(v);
324 Array::Dim_iter di = t_a->dim_begin();
325 Array::Dim_iter de = t_a->dim_end();
331 for (; di != de; di++) {
332 D4Dimension * d4_dim = t_a->dimension_D4dim(di);
334 BESDEBUG(
"fonc",
"FONcArray() - constructor is dap4: dimension name is "<< d4_dim->name() <<endl);
335 if(fdimname_to_id.find(d4_dim->fully_qualified_name())!= fdimname_to_id.end()) {
336 int dim_id = fdimname_to_id[d4_dim->fully_qualified_name()];
338 dim_ids.push_back(dim_id);
339 use_d4_dim_ids.push_back(
true);
342 dim_ids.push_back(0);
343 use_d4_dim_ids.push_back(
false);
347 dim_ids.push_back(0);
348 use_d4_dim_ids.push_back(
false);
352 b =
new FONcArray(v,dim_ids,use_d4_dim_ids,rbs_nums);
359 case dods_structure_c:
362 case dods_sequence_c:
366 string err = (string)
"file out netcdf, unable to " +
"write unknown variable type";
372 if(ncdf_version == RETURNAS_NETCDF4) {
401 assert(stax != NC_NOERR);
exception thrown if internal error encountered
A DAP Array with file out netcdf information included.
A DAP BaseType with file out netcdf information included.
virtual void setVersion(std::string version)
Identifies variable with use of NetCDF4 features.
virtual void setNC4DataModel(std::string nc4_datamodel)
Identifies the netCDF4 data model (CLASSIC or ENHANCED)
A class representing the DAP Byte class for file out netcdf.
A DAP Float64 with file out netcdf information included.
A DAP Float32 with file out netcdf information included.
A DAP Grid with file out netcdf information included.
static vector< FONcMap * > Maps
global list of maps that could be shared amongst the different grids
A DAP Int64 with file out netcdf information included.
A class representing the DAP4 int8 class for file out netcdf.
A DAP Int32 and UInt32 with file out netcdf information included.
A DAP Sequence with file out netcdf information included.
A DAP Int16 and UInt16 with file out netcdf information included.
A class representing the DAP Str class for file out netcdf.
A DAP Structure with file out netcdf information included.
A class representing the DAP Byte class for file out netcdf.
A DAP UInt32 with file out netcdf information included.
A DAP UInt32 with file out netcdf information included.
A DAP UInt16 with file out netcdf information included.
static void handle_error(int stax, const string &err, const string &file, int line)
handle any netcdf errors
static string name_prefix
If a variable name, dimension name, or attribute name begins with a character that is not supported b...
static void reset()
Resets the FONc transformation for a new input and out file.
static string id2netcdf(string in)
convert the provided string to a netcdf allowed identifier.
static nc_type get_nc_type(BaseType *element, bool isNC4_ENHANCED)
translate the OPeNDAP data type to a netcdf data type
static FONcBaseType * convert(BaseType *v, const string &version, const bool classic_model)
Creates a FONc object for the given DAP object.
static string gen_name(const vector< string > &embed, const string &name, string &original)
generate a new name for the embedded variable