MeteoIODoc  2.10.0
StationData.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-or-later
2 /***********************************************************************************/
3 /* Copyright 2009 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 STATIONDATA_H
20 #define STATIONDATA_H
21 
23 
24 #include <string>
25 #include <iomanip>
26 #include <vector>
27 
28 #include <map>
29 
30 namespace mio {
31 
41 class StationData {
42  public:
43  //Constructors
47  StationData(void);
48 
55  StationData(const Coords& i_position, const std::string& i_id="", const std::string& i_name="");
56 
57  //Specific getter functions
58  std::string getStationID() const {return stationID;}
59  std::string getStationName() const {return stationName;}
60  Coords getPosition() const {return position;}
61  std::string getHash() const {return stationID+"::"+stationName;}
62  double getAltitude() const {return position.getAltitude();}
63 
68  double getSlopeAngle() const {return slope;}
69 
74  double getAzimuth() const {return azi;}
75 
82  void setStationData(const Coords& i_position, const std::string& i_id="", const std::string& i_name="");
83 
89  void setSlope(const double& in_slope_angle, const double& in_azimuth);
90 
91  const std::string toString() const;
92  friend std::ostream& operator<<(std::ostream& os, const StationData& station);
93  friend std::istream& operator>>(std::istream& is, StationData& station);
94 
95  //Comparison operators
101  bool operator==(const StationData&) const;
102  bool operator!=(const StationData&) const;
103 
112  static StationData merge(StationData sd1, const StationData& sd2);
113 
120  void merge(const StationData& sd2);
121 
128  static bool unique(std::vector<StationData> &vecStation, const bool& position_only=false);
129 
130  public:
132  std::string stationID;
133  std::string stationName;
134  std::map<std::string, std::string> extra;
135 
136  private:
137  double slope;
138  double azi;
139 };
140 
141 typedef std::vector<StationData> STATIONS_SET;
142 
143 } //end namespace
144 
145 #endif
A class to handle geographic coordinate systems. This class offers an easy way to transparently conve...
Definition: Coords.h:82
double getAltitude() const
Definition: Coords.h:122
A class to represent meteo stations with attributes like longitude, latitude, etc.
Definition: StationData.h:41
double getAzimuth() const
Get local slope azimuth.
Definition: StationData.h:74
std::string getHash() const
Definition: StationData.h:61
Coords position
Definition: StationData.h:131
friend std::istream & operator>>(std::istream &is, StationData &station)
Definition: StationData.cc:169
static StationData merge(StationData sd1, const StationData &sd2)
Simple merge strategy. If some fields of the first argument are empty, they will be filled by the mat...
Definition: StationData.cc:71
bool operator!=(const StationData &) const
Operator that tests for inequality.
Definition: StationData.cc:67
bool operator==(const StationData &) const
Equality operator check all parameters but the station name.
Definition: StationData.cc:60
std::string stationID
ID of the Station, typically a short string.
Definition: StationData.h:132
static bool unique(std::vector< StationData > &vecStation, const bool &position_only=false)
Remove duplicate stations from a vector.
Definition: StationData.cc:86
double getSlopeAngle() const
Get local slope angle.
Definition: StationData.h:68
void setSlope(const double &in_slope_angle, const double &in_azimuth)
Slope information setter.
Definition: StationData.cc:42
std::string stationName
Name of the Station, detailed description.
Definition: StationData.h:133
StationData(void)
The default constructor initializing every double attribute to nodata and strings to "".
Definition: StationData.cc:29
friend std::ostream & operator<<(std::ostream &os, const StationData &station)
Definition: StationData.cc:140
const std::string toString() const
Definition: StationData.cc:121
std::string getStationID() const
Definition: StationData.h:58
std::map< std::string, std::string > extra
Additional metadata, such as sensor types, etc. A better solution will be implemented at some point,...
Definition: StationData.h:134
double getAltitude() const
Definition: StationData.h:62
Coords getPosition() const
Definition: StationData.h:60
void setStationData(const Coords &i_position, const std::string &i_id="", const std::string &i_name="")
General setter function.
Definition: StationData.cc:35
std::string getStationName() const
Definition: StationData.h:59
Definition: Config.cc:30
std::vector< StationData > STATIONS_SET
Definition: StationData.h:141