MeteoIODoc 20260620.13b5b0a5
Environmental timeseries pre-processing
Loading...
Searching...
No Matches
MySQLIO.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2/***********************************************************************************/
3/* Copyright 2022 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 MYSQLIO_H
20#define MYSQLIO_H
21
22#include <meteoio/IOInterface.h>
23
24#include <string>
25#include <map>
26
27namespace mio {
28
37class MYSQLIO : public IOInterface {
38 public:
39 MYSQLIO(const std::string& configfile);
40 MYSQLIO(const Config& cfgreader);
41
42 virtual void readStationData(const Date& date, std::vector<StationData>& vecStation) override;
43 virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
44 std::vector< std::vector<MeteoData> >& vecMeteo) override;
45
46 private:
47 void readConfig();
48 void readStationIDs();
49 std::pair<std::string, std::string> parseStationID(const std::string& stationID);
50 void readStationMetaData();
51 void readData(const Date& dateStart, const Date& dateEnd, std::vector< std::vector<MeteoData> >& vecMeteo,
52 const size_t& stationindex) const;
53
54 const Config cfg;
55 std::vector<std::string> vecStationIDs;
56 std::map<std::string, std::string> stationIDtoIndex; // Maps station abbreviation to index string for composite ID schemas
57 std::vector<StationData> vecStationMetaData;
58 std::string mysqlhost, mysqldb, mysqluser, mysqlpass;
59 std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
60 double in_dflt_TZ, out_dflt_TZ;
61 unsigned int mysql_options;
62 bool hasCompositeIDs=false; //set to true when the db schema stores the stationID as a string field and an int index field.
63};
64
65} //namespace
66#endif
67
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 timestamps. This class handles conversion between different time display formats (I...
Definition Date.h:87
A class representing the IO Layer of the software Alpine3D. For each type of IO (File,...
Definition IOInterface.h:121
Definition MySQLIO.h:37
virtual void readMeteoData(const Date &dateStart, const Date &dateEnd, std::vector< std::vector< MeteoData > > &vecMeteo) override
Fill vecMeteo with a time series of objects corresponding to the interval indicated by dateStart and ...
Definition MySQLIO.cc:311
virtual void readStationData(const Date &date, std::vector< StationData > &vecStation) override
Fill vecStation with StationData objects for a certain date of interest.
Definition MySQLIO.cc:303
Definition Config.cc:34