mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-08 12:08:15 +08:00
Use nested namespaces (C++17 feature)
This commit is contained in:
@@ -17,148 +17,145 @@
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackMisc
|
||||
namespace BlackMisc::Weather
|
||||
{
|
||||
namespace Weather
|
||||
CMetar::CMetar()
|
||||
{
|
||||
CMetar::CMetar()
|
||||
setCavok();
|
||||
}
|
||||
|
||||
void CMetar::setMessage(const QString &message)
|
||||
{
|
||||
m_metarMessage = message;
|
||||
}
|
||||
|
||||
bool CMetar::hasMessage() const
|
||||
{
|
||||
return !this->getMessage().isEmpty();
|
||||
}
|
||||
|
||||
void CMetar::setReportType(ReportType type)
|
||||
{
|
||||
m_reportType = type;
|
||||
}
|
||||
|
||||
void CMetar::setAirportIcaoCode(const CAirportIcaoCode &icao)
|
||||
{
|
||||
m_airport = icao;
|
||||
}
|
||||
|
||||
void CMetar::setDayTime(int reportDay, const PhysicalQuantities::CTime &reportTime)
|
||||
{
|
||||
m_reportDay = reportDay;
|
||||
m_reportTime = reportTime;
|
||||
}
|
||||
|
||||
void CMetar::setAutomated(bool isAutomated)
|
||||
{
|
||||
m_isAutomated = isAutomated;
|
||||
}
|
||||
|
||||
void CMetar::setCavok()
|
||||
{
|
||||
m_visibility = CLength(10000, CLengthUnit::km());
|
||||
m_presentWeathers.clear();
|
||||
m_cloudLayers.clear();
|
||||
}
|
||||
|
||||
void CMetar::setWindLayer(const CWindLayer &windLayer)
|
||||
{
|
||||
m_windLayer = windLayer;
|
||||
}
|
||||
|
||||
void CMetar::setVisibility(const PhysicalQuantities::CLength &visibility)
|
||||
{
|
||||
m_visibility = visibility;
|
||||
}
|
||||
|
||||
PhysicalQuantities::CLength CMetar::getVisibility() const
|
||||
{
|
||||
return m_visibility;
|
||||
}
|
||||
|
||||
void CMetar::addPresentWeather(const CPresentWeather &presentWeather)
|
||||
{
|
||||
m_presentWeathers.push_back(presentWeather);
|
||||
}
|
||||
|
||||
void CMetar::addCloudLayer(const CCloudLayer &cloudLayer)
|
||||
{
|
||||
m_cloudLayers.push_back(cloudLayer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CMetar::setTemperature(const PhysicalQuantities::CTemperature &temperature)
|
||||
{
|
||||
m_temperature = temperature;
|
||||
}
|
||||
|
||||
PhysicalQuantities::CTemperature CMetar::getTemperature() const
|
||||
{
|
||||
return m_temperature;
|
||||
}
|
||||
|
||||
void CMetar::setDewPoint(const PhysicalQuantities::CTemperature &dewPoint)
|
||||
{
|
||||
m_dewPoint = dewPoint;
|
||||
}
|
||||
|
||||
|
||||
void CMetar::setAltimeter(const PhysicalQuantities::CPressure &altimeter)
|
||||
{
|
||||
m_altimeter = altimeter;
|
||||
}
|
||||
|
||||
QString CMetar::getMetarText() const
|
||||
{
|
||||
QString presentWeathers;
|
||||
for (const auto &presentWeather : m_presentWeathers)
|
||||
{
|
||||
setCavok();
|
||||
if (!presentWeathers.isEmpty()) presentWeathers += ",";
|
||||
presentWeathers += u' ' % presentWeather.toQString();
|
||||
}
|
||||
|
||||
void CMetar::setMessage(const QString &message)
|
||||
QString clouds;
|
||||
for (const auto &layer : m_cloudLayers)
|
||||
{
|
||||
m_metarMessage = message;
|
||||
if (!clouds.isEmpty()) clouds += ",";
|
||||
clouds += u' ' % layer.toQString();
|
||||
}
|
||||
|
||||
bool CMetar::hasMessage() const
|
||||
{
|
||||
return !this->getMessage().isEmpty();
|
||||
}
|
||||
const QString metarDescription =
|
||||
QStringLiteral("Station: %1 \n").arg(m_airport.getIcaoCode())
|
||||
% QStringLiteral("Date/Time: %1 %2 UTC\n").arg(m_reportDay).arg(m_reportTime.formattedHrsMin())
|
||||
% m_windLayer.toQString()
|
||||
% u'\n'
|
||||
% QStringLiteral("Visibility: %1\n").arg(m_visibility.toQString())
|
||||
% u"Weather: "
|
||||
% presentWeathers.simplified()
|
||||
% u'\n'
|
||||
% u"Clouds:"
|
||||
% clouds
|
||||
% u'\n'
|
||||
% QStringLiteral("Temperature: %1\n").arg(m_temperature.toQString())
|
||||
% QStringLiteral("Dewpoint: %1\n").arg(m_dewPoint.toQString())
|
||||
% QStringLiteral("Altimeter: %1\n").arg(m_altimeter.toQString());
|
||||
|
||||
void CMetar::setReportType(ReportType type)
|
||||
{
|
||||
m_reportType = type;
|
||||
}
|
||||
return metarDescription;
|
||||
}
|
||||
|
||||
void CMetar::setAirportIcaoCode(const CAirportIcaoCode &icao)
|
||||
{
|
||||
m_airport = icao;
|
||||
}
|
||||
QString CMetar::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
QString s(m_airport.getIcaoCode());
|
||||
return s;
|
||||
}
|
||||
|
||||
void CMetar::setDayTime(int reportDay, const PhysicalQuantities::CTime &reportTime)
|
||||
{
|
||||
m_reportDay = reportDay;
|
||||
m_reportTime = reportTime;
|
||||
}
|
||||
|
||||
void CMetar::setAutomated(bool isAutomated)
|
||||
{
|
||||
m_isAutomated = isAutomated;
|
||||
}
|
||||
|
||||
void CMetar::setCavok()
|
||||
{
|
||||
m_visibility = CLength(10000, CLengthUnit::km());
|
||||
m_presentWeathers.clear();
|
||||
m_cloudLayers.clear();
|
||||
}
|
||||
|
||||
void CMetar::setWindLayer(const CWindLayer &windLayer)
|
||||
{
|
||||
m_windLayer = windLayer;
|
||||
}
|
||||
|
||||
void CMetar::setVisibility(const PhysicalQuantities::CLength &visibility)
|
||||
{
|
||||
m_visibility = visibility;
|
||||
}
|
||||
|
||||
PhysicalQuantities::CLength CMetar::getVisibility() const
|
||||
{
|
||||
return m_visibility;
|
||||
}
|
||||
|
||||
void CMetar::addPresentWeather(const CPresentWeather &presentWeather)
|
||||
{
|
||||
m_presentWeathers.push_back(presentWeather);
|
||||
}
|
||||
|
||||
void CMetar::addCloudLayer(const CCloudLayer &cloudLayer)
|
||||
{
|
||||
m_cloudLayers.push_back(cloudLayer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CMetar::setTemperature(const PhysicalQuantities::CTemperature &temperature)
|
||||
{
|
||||
m_temperature = temperature;
|
||||
}
|
||||
|
||||
PhysicalQuantities::CTemperature CMetar::getTemperature() const
|
||||
{
|
||||
return m_temperature;
|
||||
}
|
||||
|
||||
void CMetar::setDewPoint(const PhysicalQuantities::CTemperature &dewPoint)
|
||||
{
|
||||
m_dewPoint = dewPoint;
|
||||
}
|
||||
|
||||
|
||||
void CMetar::setAltimeter(const PhysicalQuantities::CPressure &altimeter)
|
||||
{
|
||||
m_altimeter = altimeter;
|
||||
}
|
||||
|
||||
QString CMetar::getMetarText() const
|
||||
{
|
||||
QString presentWeathers;
|
||||
for (const auto &presentWeather : m_presentWeathers)
|
||||
{
|
||||
if (!presentWeathers.isEmpty()) presentWeathers += ",";
|
||||
presentWeathers += u' ' % presentWeather.toQString();
|
||||
}
|
||||
|
||||
QString clouds;
|
||||
for (const auto &layer : m_cloudLayers)
|
||||
{
|
||||
if (!clouds.isEmpty()) clouds += ",";
|
||||
clouds += u' ' % layer.toQString();
|
||||
}
|
||||
|
||||
const QString metarDescription =
|
||||
QStringLiteral("Station: %1 \n").arg(m_airport.getIcaoCode())
|
||||
% QStringLiteral("Date/Time: %1 %2 UTC\n").arg(m_reportDay).arg(m_reportTime.formattedHrsMin())
|
||||
% m_windLayer.toQString()
|
||||
% u'\n'
|
||||
% QStringLiteral("Visibility: %1\n").arg(m_visibility.toQString())
|
||||
% u"Weather: "
|
||||
% presentWeathers.simplified()
|
||||
% u'\n'
|
||||
% u"Clouds:"
|
||||
% clouds
|
||||
% u'\n'
|
||||
% QStringLiteral("Temperature: %1\n").arg(m_temperature.toQString())
|
||||
% QStringLiteral("Dewpoint: %1\n").arg(m_dewPoint.toQString())
|
||||
% QStringLiteral("Altimeter: %1\n").arg(m_altimeter.toQString());
|
||||
|
||||
return metarDescription;
|
||||
}
|
||||
|
||||
QString CMetar::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
QString s(m_airport.getIcaoCode());
|
||||
return s;
|
||||
}
|
||||
|
||||
CMetar CMetar::CAVOK()
|
||||
{
|
||||
CMetar metar;
|
||||
metar.setCavok();
|
||||
return metar;
|
||||
}
|
||||
} // namespace
|
||||
CMetar CMetar::CAVOK()
|
||||
{
|
||||
CMetar metar;
|
||||
metar.setCavok();
|
||||
return metar;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user