OGS
Station.cpp
Go to the documentation of this file.
1
15#include "Station.h"
16
17#include <cstdlib>
18#include <utility>
19
20#include "BaseLib/Logging.h"
21#include "BaseLib/StringTools.h"
22
23namespace GeoLib
24{
25Station::Station(double const x, double const y, double const z,
26 std::string name)
27 : Point(x, y, z), _name(std::move(name))
28{
29}
30
31Station::Station(Point const* const coords, std::string name)
32 : Point(*coords), _name(std::move(name))
33{
34}
35
37 : Point(src),
38 _name(src._name),
39 _station_value(src._station_value),
40 _sensor_data(src._sensor_data.get() != nullptr
41 ? new SensorData(*(src._sensor_data.get()))
42 : nullptr)
43{
44}
45
46Station* Station::createStation(const std::string& line)
47{
48 std::list<std::string> fields = BaseLib::splitString(line, '\t');
49
50 if (fields.size() < 3)
51 {
52 INFO("Station::createStation() - Unexpected file format.");
53 return nullptr;
54 }
55
56 auto it = fields.begin();
57 std::string name = *it;
58 auto const x = std::strtod(
59 (BaseLib::replaceString(",", ".", *(++it))).c_str(), nullptr);
60 auto const y = std::strtod(
61 (BaseLib::replaceString(",", ".", *(++it))).c_str(), nullptr);
62 auto z = 0.0;
63 if (++it != fields.end())
64 {
65 z = std::strtod((BaseLib::replaceString(",", ".", *it)).c_str(),
66 nullptr);
67 }
68 return new Station(x, y, z, name);
69}
70
71Station* Station::createStation(const std::string& name, double x, double y,
72 double z)
73{
74 return new Station(x, y, z, name);
75}
76
77bool isStation(GeoLib::Point const* pnt)
78{
79 auto const* bh(dynamic_cast<GeoLib::Station const*>(pnt));
80 return bh != nullptr;
81}
82
83} // namespace GeoLib
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
Definition of the Station class.
Definition of string helper functions.
A Station (observation site) is basically a Point with some additional information.
Definition Station.h:37
Station(double x=0.0, double y=0.0, double z=0.0, std::string name="")
Constructor.
Definition Station.cpp:25
static Station * createStation(const std::string &line)
Definition Station.cpp:46
A container for sensor data at an observation site. The class stores a number of time series and has ...
Definition SensorData.h:63
std::string replaceString(const std::string &searchString, const std::string &replaceString, std::string stringToReplace)
std::vector< std::string > splitString(std::string const &str)
bool isStation(GeoLib::Point const *pnt)
Definition Station.cpp:77