MeteoIODoc 20250714.1a830fbd
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 <vector>
26
27#include <map>
28
29namespace mio {
30
41 public:
42 //Constructors
46 StationData(void);
47
54 StationData(const Coords& i_position, const std::string& i_id="", const std::string& i_name="");
55
56 //Specific getter functions
57 std::string getStationID() const {return stationID;}
58 std::string getStationName() const {return stationName;}
59 Coords getPosition() const {return position;}
60 std::string getHash() const {return stationID+"::"+stationName;}
61 double getAltitude() const {return position.getAltitude();}
62
67 double getSlopeAngle() const {return slope;}
68
73 double getAzimuth() const {return azi;}
74
81 void setStationData(const Coords& i_position, const std::string& i_id="", const std::string& i_name="");
82
88 void setSlope(const double& in_slope_angle, const double& in_azimuth);
89
90 const std::string toString() const;
91 friend std::ostream& operator<<(std::ostream& os, const StationData& station);
92 friend std::istream& operator>>(std::istream& is, StationData& station);
93
94 //Comparison operators
100 bool operator==(const StationData&) const;
101 bool operator!=(const StationData&) const;
102
111 static StationData merge(StationData sd1, const StationData& sd2);
112
119 void merge(const StationData& sd2);
120
127 static bool unique(std::vector<StationData> &vecStation, const bool& position_only=false);
128
129 public:
131 std::string stationID;
132 std::string stationName;
133 std::map<std::string, std::string> extra;
134
135 private:
136 double slope;
137 double azi;
138
139 public:
140 bool isValid() const;
141 bool isEmpty() const;
142};
143
144typedef std::vector<StationData> STATIONS_SET;
145
146} //end namespace
147
148#endif
A class to handle geographic coordinate systems. This class offers an easy way to transparently conve...
Definition: Coords.h:83
double getAltitude() const
Definition: Coords.h:124
A class to represent meteo stations with attributes like longitude, latitude, etc.
Definition: StationData.h:40
double getAzimuth() const
Get local slope azimuth.
Definition: StationData.h:73
std::string getHash() const
Definition: StationData.h:60
Coords position
Definition: StationData.h:130
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:72
bool operator!=(const StationData &) const
Operator that tests for inequality.
Definition: StationData.cc:68
bool operator==(const StationData &) const
Equality operator check all parameters but the station name.
Definition: StationData.cc:61
std::string stationID
ID of the Station, typically a short string.
Definition: StationData.h:131
static bool unique(std::vector< StationData > &vecStation, const bool &position_only=false)
Remove duplicate stations from a vector.
Definition: StationData.cc:87
double getSlopeAngle() const
Get local slope angle.
Definition: StationData.h:67
void setSlope(const double &in_slope_angle, const double &in_azimuth)
Slope information setter.
Definition: StationData.cc:43
std::string stationName
Name of the Station, detailed description.
Definition: StationData.h:132
StationData(void)
The default constructor initializing every double attribute to nodata and strings to "".
Definition: StationData.cc:30
bool isValid() const
Definition: StationData.cc:204
const std::string toString() const
Definition: StationData.cc:122
bool isEmpty() const
Definition: StationData.cc:209
std::string getStationID() const
Definition: StationData.h:57
friend std::istream & operator>>(std::istream &is, StationData &station)
Definition: StationData.cc:170
friend std::ostream & operator<<(std::ostream &os, const StationData &station)
Definition: StationData.cc:141
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:133
double getAltitude() const
Definition: StationData.h:61
Coords getPosition() const
Definition: StationData.h:59
void setStationData(const Coords &i_position, const std::string &i_id="", const std::string &i_name="")
General setter function.
Definition: StationData.cc:36
std::string getStationName() const
Definition: StationData.h:58
Definition: Config.cc:34
std::vector< StationData > STATIONS_SET
Definition: StationData.h:144