MeteoIODoc  MeteoIODoc-2.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CosmoXMLIO.h
Go to the documentation of this file.
1 /***********************************************************************************/
2 /* Copyright 2014 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
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 CosmoXMLIO_H
19 #define CosmoXMLIO_H
20 
21 #include <meteoio/IOInterface.h>
22 
23 #include <string>
24 #include <libxml/parser.h>
25 #include <libxml/xpath.h>
26 
27 namespace mio {
28 
38 class CosmoXMLIO : public IOInterface {
39  public:
40  CosmoXMLIO(const std::string& configfile);
41  CosmoXMLIO(const CosmoXMLIO&);
42  CosmoXMLIO(const Config& cfg);
43  ~CosmoXMLIO() throw();
44 
46 
47  virtual void readStationData(const Date& date, std::vector<StationData>& vecStation);
48  virtual void readMeteoData(const Date& dateStart, const Date& dateEnd, std::vector< std::vector<MeteoData> >& vecMeteo);
49 
50  private:
51  typedef enum METEOREADSTATUS { read_ok, read_continue, read_stop } MeteoReadStatus;
52 
53  void init(const Config& cfg);
54  void scanMeteoPath(const std::string& meteopath_in, std::vector< std::pair<Date,std::string> > &meteo_files) const;
55  size_t getFileIdx(const Date& start_date) const;
56  void openIn_XML(const std::string& in_meteofile);
57  void closeIn_XML() throw();
58  bool parseStationData(const std::string& station_id, const xmlXPathContextPtr& xpathCtx, StationData &sd);
59  MeteoReadStatus parseMeteoDataPoint(const Date& dateStart, const Date& dateEnd, const xmlNodePtr &element, MeteoData &md) const;
60 
61  bool parseMeteoData(const Date& dateStart, const Date& dateEnd, const std::string& station_id,
62  const StationData& sd, const xmlXPathContextPtr& xpathCtx, std::vector<MeteoData> &vecMeteo) const;
63 
64  std::vector< std::pair<Date,std::string> > cache_meteo_files; //cache of meteo files in METEOPATH
65  std::map<std::string, std::string> xml_stations_id; //mapping between true station ID and the messy id used in the xml
66  std::vector<std::string> input_id; //user specified stations to read
67  std::string meteo_prefix, meteo_ext; //for the file naming scheme
68  double plugin_nodata; //plugin specific no data value
69  bool imis_stations; //to make the station ID like an IMIS station ID
70  bool use_model_loc; //for each station, use the model location instead of the true station location (default=true)
71 
72  xmlDocPtr in_doc;
73  xmlParserCtxtPtr in_ctxt; //in case we had to use an alternate method for opening the file
74  xmlXPathContextPtr in_xpathCtx;
75  xmlCharEncoding in_encoding;
76 
77  static const double in_tz; //plugin specific time zones
78  static const xmlChar* xml_attribute;
79  static const xmlChar* xml_namespace;
80  static const xmlChar* xml_namespace_abrev;
81  static const char* StationData_xpath;
82  static const char* MeteoData_xpath;
83 
84  std::string coordin, coordinparam; //projection parameters
85 };
86 
87 } //namespace
88 #endif
CosmoXMLIO & operator=(const CosmoXMLIO &)
Assignement operator, required because of pointer member.
Definition: CosmoXMLIO.cc:194
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
~CosmoXMLIO()
Definition: CosmoXMLIO.cc:209
virtual void readStationData(const Date &date, std::vector< StationData > &vecStation)
Fill vecStation with StationData objects for a certain date of interest.
Definition: CosmoXMLIO.cc:429
Reading of FieldExtra XML meteorological data. This is the plugin for reading the XML data generated ...
Definition: CosmoXMLIO.h:38
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:475
CosmoXMLIO(const std::string &configfile)
Definition: CosmoXMLIO.cc:121
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