bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
h5commoncfdap.h
Go to the documentation of this file.
1// This file is part of hdf5_handler: an HDF5 file handler for the OPeNDAP
2// data server.
3
4// Copyright (c) 2011-2023 The HDF Group, Inc. and OPeNDAP, Inc.
5//
6// This is free software; you can redistribute it and/or modify it under the
7// terms of the GNU Lesser General Public License as published by the Free
8// Software Foundation; either version 2.1 of the License, or (at your
9// option) any later version.
10//
11// This software is distributed in the hope that it will be useful, but
12// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14// License for more details.
15//
16// You should have received a copy of the GNU Lesser General Public
17// License along with this library; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19//
20// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
21// You can contact The HDF Group, Inc. at 410 E University Ave,
22// Suite 200, Champaign, IL 61820
23
32
33#ifndef _H5COMMONCFDAP_H
34#define _H5COMMONCFDAP_H
35
36#include <string>
37#include <unordered_map>
38#include <unordered_set>
39#include <memory>
40
41#include <libdap/DMR.h>
42#include <libdap/DDS.h>
43#include <libdap/DAS.h>
44#include <libdap/D4Attributes.h>
45#include <libdap/D4Maps.h>
46#include "hdf5.h"
47
48#include "HDF5CF.h"
49
50
51void gen_dap_onevar_dds(libdap::DDS &dds, const HDF5CF::Var*, hid_t, const std::string &);
52void gen_dap_onevar_dds_sca_64bit_int(const HDF5CF::Var *var, const std::string &filename);
53void gen_dap_onevar_dds_sca_atomic(libdap::DDS &dds, const HDF5CF::Var *var, const std::string &filename);
54void gen_dap_onevar_dds_array(libdap::DDS &dds, const HDF5CF::Var *var, hid_t file_id, const std::string &filename,
55 const std::vector<HDF5CF::Dimension *>& dims);
56void gen_dap_oneobj_das(libdap::AttrTable*, const HDF5CF::Attribute*, const HDF5CF::Var*);
57
58void gen_dap_onevar_dmr(libdap::D4Group*, const HDF5CF::Var*, hid_t, const std::string &);
59void gen_dap_onevar_dmr_sca(libdap::D4Group* d4_grp, const HDF5CF::Var* var, const std::string & filename);
60void gen_dap_onevar_dmr_array(libdap::D4Group* d4_grp, const HDF5CF::Var* var, hid_t file_id,
61 const std::string &filename, const std::vector<HDF5CF::Dimension *>& dims);
62
63void map_cfh5_var_attrs_to_dap4(const HDF5CF::Var*var,libdap::BaseType*new_var);
64void map_cfh5_grp_attr_to_dap4(libdap::D4Group*, const HDF5CF::Attribute*);
65void map_cfh5_attr_container_to_dap4(libdap::D4Attribute *, const HDF5CF::Attribute*);
66
67void add_cf_grid_mapping_attr(libdap::DAS &das, const std::vector<HDF5CF::Var*>& vars, const std::string& cf_projection,
68 const std::string & dim0name, hsize_t dim0size, const std::string &dim1name, hsize_t dim1size);
69
70void add_cf_grid_cv_attrs(libdap::DAS & das, const std::vector<HDF5CF::Var*>& vars, EOS5GridPCType cv_proj_code,
71 const std::vector<HDF5CF::Dimension*>& dims,const std::vector<double>& params, unsigned short);
72
73void add_cf_projection_attrs(libdap::DAS &,EOS5GridPCType ,const std::vector<double> &,const std::string&);
74void add_cf_grid_cvs(libdap::DDS & dds, EOS5GridPCType cv_proj_code, float cv_point_lower, float cv_point_upper,
75 float cv_point_left, float cv_point_right, const std::vector<HDF5CF::Dimension*>& dims);
76
77void add_cf_grid_mapinfo_var(libdap::DDS &dds, EOS5GridPCType, unsigned short);
78bool need_special_attribute_handling(const HDF5CF::Attribute*, const HDF5CF::Var*);
79void gen_dap_special_oneobj_das(libdap::AttrTable*, const HDF5CF::Attribute*, const HDF5CF::Var*);
80bool is_fvalue_valid(H5DataType, const HDF5CF::Attribute*);
81void gen_dap_str_attr(libdap::AttrTable*, const HDF5CF::Attribute *);
82void add_ll_valid_range(libdap::AttrTable*, bool is_lat);
83void map_cfh5_var_attrs_to_dap4_int64(const HDF5CF::Var*var,libdap::BaseType*new_var);
84bool need_attr_values_for_dap4(const HDF5CF::Var*var);
85void check_update_int64_attr(const std::string &, const HDF5CF::Attribute *);
86void handle_coor_attr_for_int64_var(const HDF5CF::Attribute *, const std::string &,std::string&,bool);
87
88libdap::D4Attribute *gen_dap4_attr(const HDF5CF::Attribute *);
89
90std::string get_cf_string(std::string & s);
91std::string get_cf_string_helper(std::string & s);
92
93void add_gm_spcvs(libdap::D4Group *d4_root, EOS5GridPCType cv_proj_code, float cv_point_lower, float cv_point_upper,
94 float cv_point_left, float cv_point_right, const std::vector<HDF5CF::Dimension*>& dims);
95void add_gm_spcvs_attrs(libdap::BaseType *d4_var, bool is_dim0);
96
97void add_cf_grid_cv_dap4_attrs(libdap::D4Group *d4_root, const std::string& cf_projection,
98 const std::vector<HDF5CF::Dimension*>&dims, const std::vector<std::string> &);
99void add_cf_grid_cv_dap4_attrs_helper(libdap::Array *t_a, const std::string &dim0name, hsize_t dim0size, bool &has_dim0,
100 const std::string &dim1name, hsize_t dim1size, bool &has_dim1);
101
102void add_gm_oneproj_var_dap4_attrs(libdap::BaseType *d4_var,EOS5GridPCType cv_proj_code,
103 const std::vector<double> &eos5_proj_params);
104
105void add_var_dap4_attr(libdap::BaseType *d4_var,const std::string& attr_name, D4AttributeType attr_type,
106 const std::string& attr_value);
107
108void add_grp_dap4_attr(libdap::D4Group *d4_grp,const std::string& attr_name, D4AttributeType attr_type,
109 const std::string& attr_value);
110
111void add_dap4_coverage(libdap::D4Group* d4_grp, const std::vector<std::string>& map_array, bool is_coard);
112void add_dap4_coverage_set_up(unordered_map<std::string, libdap::Array*> &d4map_array_maps,
113 std::vector<libdap::Array *> &has_map_arrays, libdap::Array *t_a,
114 const std::vector<std::string>& coord_var_names, const std::string & vname);
115void add_dap4_coverage_grid(unordered_map<std::string, libdap::Array*> &d4map_array_maps,
116 std::vector<libdap::Array *> &has_map_arrays);
117void add_dap4_coverage_swath(unordered_map<std::string, libdap::Array*> &d4map_array_maps,
118 const std::vector<libdap::Array *> &has_map_arrays);
119void add_dap4_coverage_swath_coords(unordered_map<std::string, libdap::Array*> &d4map_array_maps,
120 libdap::Array *has_map_array,const std::vector<std::string> &coord_names,
121 unordered_set<std::string> &coord_dim_names);
122
123static inline libdap::AttrTable * obtain_new_attr_table() {
124 auto new_attr_table_unique = make_unique<libdap::AttrTable>();
125 return new_attr_table_unique.release();
126}
127
128#endif
This class specifies the core engineering of mapping HDF5 to DAP by following CF.
This class represents one attribute.
Definition HDF5CF.h:185
This class represents one HDF5 dataset(CF variable)
Definition HDF5CF.h:252
void gen_dap_str_attr(AttrTable *at, const HDF5CF::Attribute *attr)
Transfer string attributes to a DAP2 AttrTable.