MeteoIODoc  2.10.0
libacdd.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-or-later
2 /***********************************************************************************/
3 /* Copyright 2020 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
4 /***********************************************************************************/
5 /* This file is part of MeteoIO.
6  MeteoIO is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  MeteoIO is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef LIBACDD_H
20 #define LIBACDD_H
21 
22 #include <meteoio/IOUtils.h>
23 #include <meteoio/Config.h>
26 
27 #include <string>
28 #include <vector>
29 
30 namespace mio {
98 class ACDD {
99  public:
101 
106  ACDD(const bool& set_enable) : name(), cfg_key(), value(), enabled(set_enable) {defaultInit();}
107 
112  void setEnabled(const bool& i_enable) {enabled=i_enable;}
113  void setUserConfig(const mio::Config& cfg, const std::string& section, const bool& allow_multi_line=true);
114 
115  void addAttribute(const std::string& att_name, const std::string& att_value, const std::string& att_cfg_key="", Mode mode=MERGE);
116  void addAttribute(const std::string& att_name, const double& att_value, const std::string& att_cfg_key="", const Mode& mode=MERGE);
117 
122  bool isEnabled() const {return enabled;}
123  void getAttribute(const size_t ii, std::string &att_name, std::string & att_value) const;
124  size_t getNrAttributes() const {if(enabled) return name.size(); else return 0;}
125 
126  void setGeometry(const mio::Grid2DObject& grid, const bool& isLatLon);
127  void setGeometry(const std::vector< std::vector<mio::MeteoData> >& vecMeteo, const bool& isLatLon);
128  void setGeometry(const mio::Coords& location, const bool& isLatLon);
129  void setGeometry(const std::vector< mio::Coords >& vecLocation, const bool& isLatLon);
130 
131  void setTimeCoverage(const std::vector< std::vector<mio::MeteoData> >& vecMeteo);
132  void setTimeCoverage(const std::vector<mio::MeteoData>& vecMeteo);
133  void setTimeCoverage(const std::vector<std::string>& vec_timestamp, const double& TZ);
134 
135  private:
136  void defaultInit();
137  size_t find(const std::string& search_name) const;
138 
139  std::vector<std::string> name, cfg_key, value;
140  bool enabled; //helper boolean for callers to know if this object should be used or not
141 };
142 
143 } //namespace
144 #endif
This class contains and handles NetCDF Attribute Conventions Dataset Discovery attributes (see ACDD).
Definition: libacdd.h:98
size_t getNrAttributes() const
Definition: libacdd.h:124
void setUserConfig(const mio::Config &cfg, const std::string &section, const bool &allow_multi_line=true)
Read all config keys from the selected section and apply some special processing for some keys.
Definition: libacdd.cc:43
ACDD(const bool &set_enable)
Constructor, the argument allows the object to know if the acdd metadata should be written out or not...
Definition: libacdd.h:106
void setTimeCoverage(const std::vector< std::vector< mio::MeteoData > > &vecMeteo)
Definition: libacdd.cc:342
void setEnabled(const bool &i_enable)
Set an internal boolean as a helper for the caller to know if ACDD support should be enabled or not.
Definition: libacdd.h:112
void getAttribute(const size_t ii, std::string &att_name, std::string &att_value) const
Definition: libacdd.cc:164
Mode
Definition: libacdd.h:100
@ APPEND
Definition: libacdd.h:100
@ REPLACE
Definition: libacdd.h:100
@ MERGE
Definition: libacdd.h:100
void addAttribute(const std::string &att_name, const std::string &att_value, const std::string &att_cfg_key="", Mode mode=MERGE)
Add an attribute and its content to the internal list.
Definition: libacdd.cc:122
bool isEnabled() const
Get an internal boolean as a helper for the caller to know if ACDD support should be enabled or not.
Definition: libacdd.h:122
void setGeometry(const mio::Grid2DObject &grid, const bool &isLatLon)
Definition: libacdd.cc:189
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition: Config.h:79
A class to handle geographic coordinate systems. This class offers an easy way to transparently conve...
Definition: Coords.h:82
A class to represent 2D Grids. Typical application as DEM or Landuse Model.
Definition: Grid2DObject.h:42
Definition: Config.cc:30