MeteoIODoc 2.11.0
CosmoXMLIO.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2/***********************************************************************************/
3/* Copyright 2014 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
4/***********************************************************************************/
5/* This file is part of MeteoIO.
6MeteoIO is free software: you can redistribute it and/or modify
7it under the terms of the GNU Lesser General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11MeteoIO is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU Lesser General Public License for more details.
15
16You should have received a copy of the GNU Lesser General Public License
17along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef CosmoXMLIO_H
20#define CosmoXMLIO_H
21
22#include <meteoio/IOInterface.h>
23
24#include <string>
25#include <libxml/parser.h>
26#include <libxml/xpath.h>
27
28namespace mio {
29
39class CosmoXMLIO : public IOInterface {
40 public:
41 CosmoXMLIO(const std::string& configfile);
43 CosmoXMLIO(const Config& cfg);
44 ~CosmoXMLIO() noexcept;
45
46 CosmoXMLIO& operator=(const CosmoXMLIO&);
47
48 virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
49 virtual void readMeteoData(const Date& dateStart, const Date& dateEnd, std::vector< std::vector<MeteoData> >& vecMeteo);
50
51 private:
52 typedef enum METEOREADSTATUS { read_ok, read_continue, read_stop } MeteoReadStatus;
53
54 void init(const Config& cfg);
55 void scanMeteoPath(const std::string& meteopath_in, std::vector< std::pair<Date,std::string> > &meteo_files) const;
56 size_t getFileIdx(const Date& start_date) const;
57 void openIn_XML(const std::string& in_meteofile);
58 void closeIn_XML() noexcept;
59 bool parseStationData(const std::string& station_id, const xmlXPathContextPtr& xpathCtx, StationData &sd);
60 MeteoReadStatus parseMeteoDataPoint(const Date& dateStart, const Date& dateEnd, const xmlNodePtr &element, MeteoData &md) const;
61
62 bool parseMeteoData(const Date& dateStart, const Date& dateEnd, const std::string& station_id,
63 const StationData& sd, const xmlXPathContextPtr& xpathCtx, std::vector<MeteoData> &vecMeteo) const;
64
65 std::vector< std::pair<Date,std::string> > cache_meteo_files; //cache of meteo files in METEOPATH
66 std::map<std::string, std::string> xml_stations_id; //mapping between true station ID and the messy id used in the xml
67 std::vector<std::string> input_id; //user specified stations to read
68 std::string meteo_prefix, meteo_ext; //for the file naming scheme
69 double plugin_nodata; //plugin specific no data value
70 bool imis_stations; //to make the station ID like an IMIS station ID
71 bool use_model_loc; //for each station, use the model location instead of the true station location (default=true)
72
73 xmlDocPtr in_doc;
74 xmlParserCtxtPtr in_ctxt; //in case we had to use an alternate method for opening the file
75 xmlXPathContextPtr in_xpathCtx;
76 xmlCharEncoding in_encoding;
77
78 static const double in_tz; //plugin specific time zones
79 static const xmlChar* xml_attribute;
80 static const xmlChar* xml_namespace;
81 static const xmlChar* xml_namespace_abrev;
82 static const char* StationData_xpath;
83 static const char* MeteoData_xpath;
84
85 std::string coordin, coordinparam; //projection parameters
86};
87
88} //namespace
89#endif
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition: Config.h:79
Reading of FieldExtra XML meteorological data. This is the plugin for reading the XML data generated ...
Definition: CosmoXMLIO.h:39
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: CosmoXMLIO.cc:474
CosmoXMLIO(const CosmoXMLIO &)
virtual void readStationData(const Date &date, std::vector< StationData > &vecStation)
Fill vecStation with StationData objects for a certain date of interest.
Definition: CosmoXMLIO.cc:428
~CosmoXMLIO() noexcept
Definition: CosmoXMLIO.cc:209
CosmoXMLIO(const std::string &configfile)
Definition: CosmoXMLIO.cc:122
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:98
A class to represent a singular measurement received from one station at a certain time (represented ...
Definition: MeteoData.h:107
A class to represent meteo stations with attributes like longitude, latitude, etc.
Definition: StationData.h:41
Definition: Config.cc:31