MeteoIODoc  MeteoIODoc-2.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GSNIO.h
Go to the documentation of this file.
1 /***********************************************************************************/
2 /* Copyright 2009 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 GSNIO_H
19 #define GSNIO_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 
41 class GSNIO : public IOInterface {
42  public:
43  GSNIO(const std::string& configfile);
44  GSNIO(const GSNIO&);
45  GSNIO(const Config&);
46 
47  virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
48  virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
49  std::vector< std::vector<MeteoData> >& vecMeteo);
50 
51  private:
52  void convertUnits(MeteoData& meteo) const;
53  bool buildStation(const std::string& vs_name, const std::string& full_name, const double& lat, const double& lon,
54  const double& alt, const double& slope_angle, const double& slope_azi, StationData &sd) const;
55  bool parseMetadata(std::stringstream& ss, StationData &sd, std::string &fields, std::string &units) const;
56  void readData(const Date& dateStart, const Date& dateEnd, std::vector<MeteoData>& vecMeteo, const size_t& stationindex);
57  void map_parameters(const std::string& fields, const std::string& units, MeteoData& md, std::vector<size_t>& index);
58  void parse_streamElement(const std::string& line, const std::vector<size_t>& index, MeteoData& tmpmeteo) const;
59 
60  void initGSNConnection();
61  static size_t data_write(void* buf, size_t size, size_t nmemb, void* userp);
62  bool curl_read(const std::string& url, std::ostream& os);
63 
64  const Config cfg;
65  std::vector<std::string> vecStationName;
66  std::map<size_t, double> multiplier, offset;
67  std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
68  std::string endpoint, userid, passwd;
69  double default_timezone;
70  int http_timeout; //time out for http connections
71  bool gsn_debug;
72 
73  static const int http_timeout_dflt;
74  static const std::string sensors_endpoint, sensors_format, null_string;
75 };
76 
77 } //end namespace mio
78 
79 #endif
virtual void readStationData(const Date &date, std::vector< StationData > &vecStation)
Fill vecStation with StationData objects for a certain date of interest.
Definition: GSNIO.cc:126
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
GSNIO(const std::string &configfile)
Definition: GSNIO.cc:88
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: GSNIO.cc:226
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition: Config.h:58
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:79
A class to represent meteo stations with attributes like longitude, latitude, etc.
Definition: StationData.h:38
A class to represent a singular measurement received from one station at a certain time (represented ...
Definition: MeteoData.h:101
This class enables the access to the GSN RESTful web service.
Definition: GSNIO.h:41