12 using namespace swift::misc::physical_quantities;
13 using namespace swift::misc::aviation;
17 namespace swift::misc::weather
19 CMetar::CMetar() { setCavok(); }
21 void CMetar::setMessage(
const QString &message) { m_metarMessage = message; }
23 bool CMetar::hasMessage()
const {
return !this->getMessage().isEmpty(); }
25 void CMetar::setReportType(
ReportType type) { m_reportType = type; }
31 m_reportDay = reportDay;
32 m_reportTime = reportTime;
35 void CMetar::setAutomated(
bool isAutomated) { m_isAutomated = isAutomated; }
37 void CMetar::setCavok()
40 m_presentWeathers.clear();
41 m_cloudLayers.clear();
44 void CMetar::setWindLayer(
const CWindLayer &windLayer) { m_windLayer = windLayer; }
52 m_presentWeathers.push_back(presentWeather);
55 void CMetar::addCloudLayer(
const CCloudLayer &cloudLayer) { m_cloudLayers.push_back(cloudLayer); }
65 QString CMetar::getMetarText()
const
67 QString presentWeathers;
68 for (
const auto &presentWeather : m_presentWeathers)
70 if (!presentWeathers.isEmpty()) presentWeathers +=
",";
71 presentWeathers += u
' ' % presentWeather.
toQString();
75 for (
const auto &layer : m_cloudLayers)
77 if (!clouds.isEmpty()) clouds +=
",";
78 clouds += u
' ' % layer.toQString();
81 const QString metarDescription =
82 QStringLiteral(
"Station: %1 \n").arg(m_airport.getIcaoCode()) %
83 QStringLiteral(
"Date/Time: %1 %2 UTC\n").arg(m_reportDay).arg(m_reportTime.formattedHrsMin()) %
84 m_windLayer.toQString() % u
'\n' % QStringLiteral(
"Visibility: %1\n").arg(m_visibility.toQString()) %
85 u
"Weather: " % presentWeathers.simplified() % u
'\n' % u
"Clouds:" % clouds % u
'\n' %
86 QStringLiteral(
"Temperature: %1\n").arg(m_temperature.toQString()) %
87 QStringLiteral(
"Dewpoint: %1\n").arg(m_dewPoint.toQString()) %
88 QStringLiteral(
"Altimeter: %1\n").arg(m_altimeter.toQString());
90 return metarDescription;
93 QString CMetar::convertToQString(
bool i18n)
const
96 QString s(m_airport.getIcaoCode());
Value object encapsulating information of airport ICAO data.
QString toQString(bool i18n=false) const
Cast as QString.
Physical unit length (length)
static CLengthUnit km()
Kilometer km.
Physical unit temperature.
Value object for a cloud layer.
Value object for present weather flags.
Value object for a wind layer.
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.