MeteoIODoc  MeteoIODoc-2.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DBO.h
Go to the documentation of this file.
1 /***********************************************************************************/
2 /* Copyright 2017 SLF */
3 /***********************************************************************************/
4 /* This file is part of MeteoIO.
5  MeteoIO is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  MeteoIO is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef DBO_H
19 #define DBO_H
20 
21 #include <meteoio/IOInterface.h>
22 
23 #include <string>
24 #include <vector>
25 
26 #ifdef _MSC_VER
27  #pragma warning(disable:4512) //we don't need any = operator!
28 #endif
29 
30 namespace mio {
31 
40 class DBO : public IOInterface {
41  public:
42  DBO(const std::string& configfile);
43  DBO(const DBO&);
44  DBO(const Config&);
45 
46  virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
47  virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
48  std::vector< std::vector<MeteoData> >& vecMeteo);
49 
50  typedef struct ts_Meta {
51  ts_Meta(const Date& i_since, const Date& i_until, const std::string& i_agg_type, const double& i_ts_id, const unsigned int& i_interval)
52  : since(i_since), until(i_until), agg_type(i_agg_type), ts_id(i_ts_id), interval(i_interval) {}
53 
54  std::string toString() {
55  std::ostringstream os;
56  os << ts_id << " [";
57  os << ((since.isUndef())? "-∞" : since.toString(Date::ISO)) << " - ";
58  os << ((until.isUndef())? "∞" : until.toString(Date::ISO)) << "] ";
59  os << agg_type << " - " << interval << " s";
60  return os.str();
61  }
62 
63  Date since, until;
64  std::string agg_type;
65  double ts_id;
66  unsigned int interval;
67  } tsMeta;
68  private:
69  void fillStationMeta();
70  void readData(const Date& dateStart, const Date& dateEnd, std::vector<MeteoData>& vecMeteo, const size_t& stationindex);
71  void readTimeSerie(const unsigned int& ts_id, const MeteoData::Parameters& param, const Date& dateStart, const Date& dateEnd, const StationData& sd, std::vector<MeteoData>& vecMeteo);
72 
73  void initDBOConnection();
74  static size_t data_write(void* buf, size_t size, size_t nmemb, void* userp);
75  bool curl_read(const std::string& url, std::ostream& os);
76 
77  const Config cfg;
78  std::vector<std::string> vecStationName;
79  std::vector<StationData> vecMeta;
80  std::vector< std::map<std::string, std::vector<DBO::tsMeta> > > vecTsMeta;
81  std::string coordin, coordinparam, coordout, coordoutparam;
82  std::string endpoint;
83  double default_timezone;
84  int http_timeout; //time out for http connections
85  bool dbo_debug;
86 
87  static const int http_timeout_dflt;
88  static const std::string metadata_endpoint, data_endpoint, null_string;
89 };
90 
91 } //end namespace mio
92 
93 #endif
std::string agg_type
Definition: DBO.h:64
std::string toString()
Definition: DBO.h:54
A class representing the IO Layer of the software Alpine3D. For each type of IO (File, DB, Webservice, etc) a derived class is to be created that holds the specific implementation of the appropriate virtual methods. The IOHandler class is a wrapper class that is able to deal with all above implementations of the IOInterface abstract base class.
Definition: IOInterface.h:43
ISO 8601 extended format combined date: YYYY-MM-DDTHH:mm:SS (fields might be dropped, in the least to the most significant order)
Definition: Date.h:83
double ts_id
Definition: DBO.h:65
virtual void readMeteoData(const Date &dateStart, const Date &dateEnd, std::vector< std::vector< MeteoData > > &vecMeteo)
Fill vecMeteo with a time series of objects corresponding to the interval indicated by dateStart and ...
Definition: DBO.cc:424
virtual void readStationData(const Date &date, std::vector< StationData > &vecStation)
Fill vecStation with StationData objects for a certain date of interest.
Definition: DBO.cc:417
This class enables the access to the DBO RESTful web service.
Definition: DBO.h:40
Parameters
Definition: MeteoData.h:119
ts_Meta(const Date &i_since, const Date &i_until, const std::string &i_agg_type, const double &i_ts_id, const unsigned int &i_interval)
Definition: DBO.h:51
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition: Config.h:58
Definition: DBO.h:50
DBO(const std::string &configfile)
Definition: DBO.cc:382
Date until
Definition: DBO.h:63
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:79
unsigned int interval
Definition: DBO.h:66