mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +08:00
refactor: clang format line length
This commit is contained in:
@@ -14,28 +14,22 @@ SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::misc::weather, CCloudLayer)
|
||||
namespace swift::misc::weather
|
||||
{
|
||||
|
||||
CCloudLayer::CCloudLayer(const swift::misc::aviation::CAltitude &base,
|
||||
const swift::misc::aviation::CAltitude &top,
|
||||
Coverage coverage) : m_base(base), m_top(top)
|
||||
CCloudLayer::CCloudLayer(const swift::misc::aviation::CAltitude &base, const swift::misc::aviation::CAltitude &top,
|
||||
Coverage coverage)
|
||||
: m_base(base), m_top(top)
|
||||
{
|
||||
setCoverage(coverage);
|
||||
}
|
||||
|
||||
CCloudLayer::CCloudLayer(const swift::misc::aviation::CAltitude &base,
|
||||
const swift::misc::aviation::CAltitude &top,
|
||||
double precipitationRate,
|
||||
Precipitation precipitation,
|
||||
Clouds clouds,
|
||||
Coverage coverage) : m_base(base), m_top(top), m_precipitationRate(precipitationRate),
|
||||
m_precipitation(precipitation), m_clouds(clouds)
|
||||
CCloudLayer::CCloudLayer(const swift::misc::aviation::CAltitude &base, const swift::misc::aviation::CAltitude &top,
|
||||
double precipitationRate, Precipitation precipitation, Clouds clouds, Coverage coverage)
|
||||
: m_base(base), m_top(top), m_precipitationRate(precipitationRate), m_precipitation(precipitation),
|
||||
m_clouds(clouds)
|
||||
{
|
||||
setCoverage(coverage);
|
||||
}
|
||||
|
||||
void CCloudLayer::setCoverage(Coverage coverage)
|
||||
{
|
||||
m_coveragePercent = 100 * coverage / 4;
|
||||
}
|
||||
void CCloudLayer::setCoverage(Coverage coverage) { m_coveragePercent = 100 * coverage / 4; }
|
||||
|
||||
CCloudLayer::Coverage CCloudLayer::getCoverage() const
|
||||
{
|
||||
@@ -52,20 +46,13 @@ namespace swift::misc::weather
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexBase:
|
||||
return QVariant::fromValue(m_base);
|
||||
case IndexTop:
|
||||
return QVariant::fromValue(m_top);
|
||||
case IndexPrecipitationRate:
|
||||
return QVariant::fromValue(m_precipitationRate);
|
||||
case IndexPrecipitation:
|
||||
return QVariant::fromValue(m_precipitation);
|
||||
case IndexClouds:
|
||||
return QVariant::fromValue(m_clouds);
|
||||
case IndexCoveragePercent:
|
||||
return QVariant::fromValue(m_coveragePercent);
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
case IndexBase: return QVariant::fromValue(m_base);
|
||||
case IndexTop: return QVariant::fromValue(m_top);
|
||||
case IndexPrecipitationRate: return QVariant::fromValue(m_precipitationRate);
|
||||
case IndexPrecipitation: return QVariant::fromValue(m_precipitation);
|
||||
case IndexClouds: return QVariant::fromValue(m_clouds);
|
||||
case IndexCoveragePercent: return QVariant::fromValue(m_coveragePercent);
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,38 +66,20 @@ namespace swift::misc::weather
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexBase:
|
||||
setBase(variant.value<CAltitude>());
|
||||
break;
|
||||
case IndexTop:
|
||||
setTop(variant.value<CAltitude>());
|
||||
break;
|
||||
case IndexPrecipitationRate:
|
||||
setPrecipitationRate(variant.value<int>());
|
||||
break;
|
||||
case IndexPrecipitation:
|
||||
setPrecipitation(variant.value<Precipitation>());
|
||||
break;
|
||||
case IndexClouds:
|
||||
setClouds(variant.value<Clouds>());
|
||||
break;
|
||||
case IndexCoveragePercent:
|
||||
setCoveragePercent(variant.value<int>());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
case IndexBase: setBase(variant.value<CAltitude>()); break;
|
||||
case IndexTop: setTop(variant.value<CAltitude>()); break;
|
||||
case IndexPrecipitationRate: setPrecipitationRate(variant.value<int>()); break;
|
||||
case IndexPrecipitation: setPrecipitation(variant.value<Precipitation>()); break;
|
||||
case IndexClouds: setClouds(variant.value<Clouds>()); break;
|
||||
case IndexCoveragePercent: setCoveragePercent(variant.value<int>()); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
|
||||
QString CCloudLayer::convertToQString(bool /** i18n **/) const
|
||||
{
|
||||
static const QHash<Coverage, QString> hash = {
|
||||
{ None, "" },
|
||||
{ Few, "few" },
|
||||
{ Scattered, "scattered" },
|
||||
{ Broken, "broken" },
|
||||
{ Overcast, "overcast" }
|
||||
{ None, "" }, { Few, "few" }, { Scattered, "scattered" }, { Broken, "broken" }, { Overcast, "overcast" }
|
||||
};
|
||||
|
||||
return QStringLiteral("%1 from %2 to %3").arg(hash.value(getCoverage()), m_base.toQString(), m_top.toQString());
|
||||
|
||||
@@ -71,17 +71,12 @@ namespace swift::misc::weather
|
||||
CCloudLayer() = default;
|
||||
|
||||
//! Constructor
|
||||
CCloudLayer(const swift::misc::aviation::CAltitude &base,
|
||||
const swift::misc::aviation::CAltitude &top,
|
||||
CCloudLayer(const swift::misc::aviation::CAltitude &base, const swift::misc::aviation::CAltitude &top,
|
||||
Coverage coverage);
|
||||
|
||||
//! Constructor
|
||||
CCloudLayer(const swift::misc::aviation::CAltitude &base,
|
||||
const swift::misc::aviation::CAltitude &top,
|
||||
double precipitationRate,
|
||||
Precipitation precipitation,
|
||||
Clouds clouds,
|
||||
Coverage coverage);
|
||||
CCloudLayer(const swift::misc::aviation::CAltitude &base, const swift::misc::aviation::CAltitude &top,
|
||||
double precipitationRate, Precipitation precipitation, Clouds clouds, Coverage coverage);
|
||||
|
||||
//! Set base
|
||||
void setBase(const swift::misc::aviation::CAltitude &base) { m_base = base; }
|
||||
|
||||
@@ -12,13 +12,9 @@ SWIFT_DEFINE_SEQUENCE_MIXINS(swift::misc::weather, CCloudLayer, CCloudLayerList)
|
||||
|
||||
namespace swift::misc::weather
|
||||
{
|
||||
CCloudLayerList::CCloudLayerList(const CSequence<CCloudLayer> &other) : CSequence<CCloudLayer>(other)
|
||||
{}
|
||||
CCloudLayerList::CCloudLayerList(const CSequence<CCloudLayer> &other) : CSequence<CCloudLayer>(other) {}
|
||||
|
||||
bool CCloudLayerList::containsBase(const CAltitude &base) const
|
||||
{
|
||||
return contains(&CCloudLayer::getBase, base);
|
||||
}
|
||||
bool CCloudLayerList::containsBase(const CAltitude &base) const { return contains(&CCloudLayer::getBase, base); }
|
||||
|
||||
CCloudLayer CCloudLayerList::findByBase(const CAltitude &base) const
|
||||
{
|
||||
|
||||
@@ -29,9 +29,7 @@ namespace swift::misc
|
||||
/*!
|
||||
* Value object encapsulating a set of cloud layers
|
||||
*/
|
||||
class SWIFT_MISC_EXPORT CCloudLayerList :
|
||||
public CSequence<CCloudLayer>,
|
||||
public mixin::MetaType<CCloudLayerList>
|
||||
class SWIFT_MISC_EXPORT CCloudLayerList : public CSequence<CCloudLayer>, public mixin::MetaType<CCloudLayerList>
|
||||
{
|
||||
public:
|
||||
SWIFT_MISC_DECLARE_USING_MIXIN_METATYPE(CCloudLayerList)
|
||||
|
||||
@@ -17,30 +17,15 @@ SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::misc::weather, CMetar)
|
||||
|
||||
namespace swift::misc::weather
|
||||
{
|
||||
CMetar::CMetar()
|
||||
{
|
||||
setCavok();
|
||||
}
|
||||
CMetar::CMetar() { setCavok(); }
|
||||
|
||||
void CMetar::setMessage(const QString &message)
|
||||
{
|
||||
m_metarMessage = message;
|
||||
}
|
||||
void CMetar::setMessage(const QString &message) { m_metarMessage = message; }
|
||||
|
||||
bool CMetar::hasMessage() const
|
||||
{
|
||||
return !this->getMessage().isEmpty();
|
||||
}
|
||||
bool CMetar::hasMessage() const { return !this->getMessage().isEmpty(); }
|
||||
|
||||
void CMetar::setReportType(ReportType type)
|
||||
{
|
||||
m_reportType = type;
|
||||
}
|
||||
void CMetar::setReportType(ReportType type) { m_reportType = type; }
|
||||
|
||||
void CMetar::setAirportIcaoCode(const CAirportIcaoCode &icao)
|
||||
{
|
||||
m_airport = icao;
|
||||
}
|
||||
void CMetar::setAirportIcaoCode(const CAirportIcaoCode &icao) { m_airport = icao; }
|
||||
|
||||
void CMetar::setDayTime(int reportDay, const physical_quantities::CTime &reportTime)
|
||||
{
|
||||
@@ -48,10 +33,7 @@ namespace swift::misc::weather
|
||||
m_reportTime = reportTime;
|
||||
}
|
||||
|
||||
void CMetar::setAutomated(bool isAutomated)
|
||||
{
|
||||
m_isAutomated = isAutomated;
|
||||
}
|
||||
void CMetar::setAutomated(bool isAutomated) { m_isAutomated = isAutomated; }
|
||||
|
||||
void CMetar::setCavok()
|
||||
{
|
||||
@@ -60,50 +42,26 @@ namespace swift::misc::weather
|
||||
m_cloudLayers.clear();
|
||||
}
|
||||
|
||||
void CMetar::setWindLayer(const CWindLayer &windLayer)
|
||||
{
|
||||
m_windLayer = windLayer;
|
||||
}
|
||||
void CMetar::setWindLayer(const CWindLayer &windLayer) { m_windLayer = windLayer; }
|
||||
|
||||
void CMetar::setVisibility(const physical_quantities::CLength &visibility)
|
||||
{
|
||||
m_visibility = visibility;
|
||||
}
|
||||
void CMetar::setVisibility(const physical_quantities::CLength &visibility) { m_visibility = visibility; }
|
||||
|
||||
physical_quantities::CLength CMetar::getVisibility() const
|
||||
{
|
||||
return m_visibility;
|
||||
}
|
||||
physical_quantities::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::addCloudLayer(const CCloudLayer &cloudLayer) { m_cloudLayers.push_back(cloudLayer); }
|
||||
|
||||
void CMetar::setTemperature(const physical_quantities::CTemperature &temperature)
|
||||
{
|
||||
m_temperature = temperature;
|
||||
}
|
||||
void CMetar::setTemperature(const physical_quantities::CTemperature &temperature) { m_temperature = temperature; }
|
||||
|
||||
physical_quantities::CTemperature CMetar::getTemperature() const
|
||||
{
|
||||
return m_temperature;
|
||||
}
|
||||
physical_quantities::CTemperature CMetar::getTemperature() const { return m_temperature; }
|
||||
|
||||
void CMetar::setDewPoint(const physical_quantities::CTemperature &dewPoint)
|
||||
{
|
||||
m_dewPoint = dewPoint;
|
||||
}
|
||||
void CMetar::setDewPoint(const physical_quantities::CTemperature &dewPoint) { m_dewPoint = dewPoint; }
|
||||
|
||||
void CMetar::setAltimeter(const physical_quantities::CPressure &altimeter)
|
||||
{
|
||||
m_altimeter = altimeter;
|
||||
}
|
||||
void CMetar::setAltimeter(const physical_quantities::CPressure &altimeter) { m_altimeter = altimeter; }
|
||||
|
||||
QString CMetar::getMetarText() const
|
||||
{
|
||||
@@ -122,7 +80,13 @@ namespace swift::misc::weather
|
||||
}
|
||||
|
||||
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());
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -65,16 +65,12 @@ namespace swift::misc::weather
|
||||
// Loop stop condition:
|
||||
// - Invalid data
|
||||
// - One match found and token not repeatable
|
||||
do
|
||||
{
|
||||
do {
|
||||
QRegularExpressionMatch match = re.match(metarString);
|
||||
if (match.hasMatch())
|
||||
{
|
||||
// If invalid data, we return straight away
|
||||
if (!validateAndSet(match, metar))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!validateAndSet(match, metar)) { return false; }
|
||||
|
||||
// Remove the captured part
|
||||
metarString.replace(re, QString());
|
||||
@@ -91,7 +87,8 @@ namespace swift::misc::weather
|
||||
|
||||
if (!isValid)
|
||||
{
|
||||
CLogMessage(static_cast<CMetarDecoder *>(nullptr)).debug() << "Failed to match" << getDecoderType() << "in remaining METAR:" << metarString;
|
||||
CLogMessage(static_cast<CMetarDecoder *>(nullptr)).debug()
|
||||
<< "Failed to match" << getDecoderType() << "in remaining METAR:" << metarString;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
@@ -124,10 +121,8 @@ namespace swift::misc::weather
|
||||
private:
|
||||
const QHash<QString, CMetar::ReportType> &getReportTypeHash() const
|
||||
{
|
||||
static const QHash<QString, CMetar::ReportType> hash = {
|
||||
{ "METAR", CMetar::METAR },
|
||||
{ "SPECI", CMetar::SPECI }
|
||||
};
|
||||
static const QHash<QString, CMetar::ReportType> hash = { { "METAR", CMetar::METAR },
|
||||
{ "SPECI", CMetar::SPECI } };
|
||||
return hash;
|
||||
}
|
||||
};
|
||||
@@ -210,14 +205,8 @@ namespace swift::misc::weather
|
||||
metar.setAutomated(true);
|
||||
return true;
|
||||
}
|
||||
else if (match.captured(1) == "NIL")
|
||||
{ /* todo */
|
||||
return true;
|
||||
}
|
||||
else if (match.captured(1).size() == 3)
|
||||
{ /* todo */
|
||||
return true;
|
||||
}
|
||||
else if (match.captured(1) == "NIL") { return true; }
|
||||
else if (match.captured(1).size() == 3) { return true; }
|
||||
else { return false; }
|
||||
}
|
||||
|
||||
@@ -232,12 +221,10 @@ namespace swift::misc::weather
|
||||
protected:
|
||||
const QHash<QString, CSpeedUnit> &getWindUnitHash() const
|
||||
{
|
||||
static const QHash<QString, CSpeedUnit> hash = {
|
||||
{ "KT", CSpeedUnit::kts() },
|
||||
{ "MPS", CSpeedUnit::m_s() },
|
||||
{ "KPH", CSpeedUnit::km_h() },
|
||||
{ "KMH", CSpeedUnit::km_h() }
|
||||
};
|
||||
static const QHash<QString, CSpeedUnit> hash = { { "KT", CSpeedUnit::kts() },
|
||||
{ "MPS", CSpeedUnit::m_s() },
|
||||
{ "KPH", CSpeedUnit::km_h() },
|
||||
{ "KMH", CSpeedUnit::km_h() } };
|
||||
return hash;
|
||||
}
|
||||
|
||||
@@ -254,10 +241,7 @@ namespace swift::misc::weather
|
||||
if (directionAsString == "///") return true;
|
||||
int direction = 0;
|
||||
bool directionVariable = false;
|
||||
if (directionAsString == "VRB")
|
||||
{
|
||||
directionVariable = true;
|
||||
}
|
||||
if (directionAsString == "VRB") { directionVariable = true; }
|
||||
else
|
||||
{
|
||||
direction = directionAsString.toInt(&ok);
|
||||
@@ -278,7 +262,9 @@ namespace swift::misc::weather
|
||||
QString unitAsString = match.captured("unit");
|
||||
if (!getWindUnitHash().contains(unitAsString)) return false;
|
||||
|
||||
CWindLayer windLayer(CAltitude(0, CAltitude::AboveGround, CLengthUnit::ft()), CAngle(direction, CAngleUnit::deg()), CSpeed(speed, getWindUnitHash().value(unitAsString)),
|
||||
CWindLayer windLayer(CAltitude(0, CAltitude::AboveGround, CLengthUnit::ft()),
|
||||
CAngle(direction, CAngleUnit::deg()),
|
||||
CSpeed(speed, getWindUnitHash().value(unitAsString)),
|
||||
CSpeed(gustSpeed, getWindUnitHash().value(unitAsString)));
|
||||
windLayer.setDirectionVariable(directionVariable);
|
||||
metar.setWindLayer(windLayer);
|
||||
@@ -359,14 +345,8 @@ namespace swift::misc::weather
|
||||
const QHash<QString, QString> &getCardinalDirections() const
|
||||
{
|
||||
static const QHash<QString, QString> hash = {
|
||||
{ "N", "north" },
|
||||
{ "NE", "north-east" },
|
||||
{ "E", "east" },
|
||||
{ "SE", "south-east" },
|
||||
{ "S", "south" },
|
||||
{ "SW", "south-west" },
|
||||
{ "W", "west" },
|
||||
{ "NW", "north-west" },
|
||||
{ "N", "north" }, { "NE", "north-east" }, { "E", "east" }, { "SE", "south-east" },
|
||||
{ "S", "south" }, { "SW", "south-west" }, { "W", "west" }, { "NW", "north-west" },
|
||||
};
|
||||
return hash;
|
||||
}
|
||||
@@ -438,14 +418,16 @@ namespace swift::misc::weather
|
||||
// Cardinal directions N, NE etc.
|
||||
// "////" in case no info is available
|
||||
// NDV = No Directional Variation
|
||||
const QString visibility_eu = QStringLiteral("(?<visibility>\\d{4}|/{4})(NDV)?") + "(" + QStringList(getCardinalDirections().keys()).join('|') + ")?";
|
||||
const QString visibility_eu = QStringLiteral("(?<visibility>\\d{4}|/{4})(NDV)?") + "(" +
|
||||
QStringList(getCardinalDirections().keys()).join('|') + ")?";
|
||||
// US/Canada version:
|
||||
// Surface visibility reported in statute miles.
|
||||
// A space divides whole miles and fractions.
|
||||
// Group ends with SM to indicate statute miles. For example,
|
||||
// 1 1/2SM.
|
||||
// Auto only: M prefixed to value < 1/4 mile, e.g., M1/4S
|
||||
const QString visibility_us = QStringLiteral("(?<distance>\\d{0,2}) ?M?((?<numerator>\\d)/(?<denominator>\\d))?(?<unit>SM|KM)");
|
||||
const QString visibility_us =
|
||||
QStringLiteral("(?<distance>\\d{0,2}) ?M?((?<numerator>\\d)/(?<denominator>\\d))?(?<unit>SM|KM)");
|
||||
const QString regexp = "^(" + cavok + "|" + visibility_eu + "|" + visibility_us + ") ";
|
||||
return regexp;
|
||||
}
|
||||
@@ -516,25 +498,19 @@ namespace swift::misc::weather
|
||||
protected:
|
||||
const QHash<QString, CPresentWeather::Intensity> &getIntensityHash() const
|
||||
{
|
||||
static const QHash<QString, CPresentWeather::Intensity> hash = {
|
||||
{ "-", CPresentWeather::Light },
|
||||
{ "+", CPresentWeather::Heavy },
|
||||
{ "VC", CPresentWeather::InVincinity }
|
||||
};
|
||||
static const QHash<QString, CPresentWeather::Intensity> hash = { { "-", CPresentWeather::Light },
|
||||
{ "+", CPresentWeather::Heavy },
|
||||
{ "VC", CPresentWeather::InVincinity } };
|
||||
return hash;
|
||||
}
|
||||
|
||||
const QHash<QString, CPresentWeather::Descriptor> &getDescriptorHash() const
|
||||
{
|
||||
static const QHash<QString, CPresentWeather::Descriptor> hash = {
|
||||
{ "MI", CPresentWeather::Shallow },
|
||||
{ "BC", CPresentWeather::Patches },
|
||||
{ "PR", CPresentWeather::Partial },
|
||||
{ "DR", CPresentWeather::Drifting },
|
||||
{ "BL", CPresentWeather::Blowing },
|
||||
{ "SH", CPresentWeather::Showers },
|
||||
{ "TS", CPresentWeather::Thunderstorm },
|
||||
{ "FR", CPresentWeather::Freezing },
|
||||
{ "MI", CPresentWeather::Shallow }, { "BC", CPresentWeather::Patches },
|
||||
{ "PR", CPresentWeather::Partial }, { "DR", CPresentWeather::Drifting },
|
||||
{ "BL", CPresentWeather::Blowing }, { "SH", CPresentWeather::Showers },
|
||||
{ "TS", CPresentWeather::Thunderstorm }, { "FR", CPresentWeather::Freezing },
|
||||
};
|
||||
return hash;
|
||||
}
|
||||
@@ -612,13 +588,15 @@ namespace swift::misc::weather
|
||||
// Qualifier intensity. (-) light (no sign) moderate (+) heavy or VC
|
||||
const QString qualifier_intensity("(?<intensity>[-+]|VC)?");
|
||||
// Descriptor, if any
|
||||
const QString qualifier_descriptor = "(?<descriptor>" + QStringList(getDescriptorHash().keys()).join('|') + ")?";
|
||||
const QString qualifier_descriptor =
|
||||
"(?<descriptor>" + QStringList(getDescriptorHash().keys()).join('|') + ")?";
|
||||
const QString weatherPhenomenaJoined = QStringList(getWeatherPhenomenaHash().keys()).join('|');
|
||||
const QString weather_phenomina1 = "(?<wp1>" + weatherPhenomenaJoined + ")?";
|
||||
const QString weather_phenomina2 = "(?<wp2>" + weatherPhenomenaJoined + ")?";
|
||||
const QString weather_phenomina3 = "(?<wp3>" + weatherPhenomenaJoined + ")?";
|
||||
const QString weather_phenomina4 = "(?<wp4>" + weatherPhenomenaJoined + ")?";
|
||||
const QString regexp = "^(" + qualifier_intensity + qualifier_descriptor + weather_phenomina1 + weather_phenomina2 + weather_phenomina3 + weather_phenomina4 + ") ";
|
||||
const QString regexp = "^(" + qualifier_intensity + qualifier_descriptor + weather_phenomina1 +
|
||||
weather_phenomina2 + weather_phenomina3 + weather_phenomina4 + ") ";
|
||||
return regexp;
|
||||
}
|
||||
};
|
||||
@@ -631,24 +609,17 @@ namespace swift::misc::weather
|
||||
protected:
|
||||
const QStringList &getClearSkyTokens() const
|
||||
{
|
||||
static const QStringList list = {
|
||||
"SKC",
|
||||
"NSC",
|
||||
"CLR",
|
||||
"NCD"
|
||||
};
|
||||
static const QStringList list = { "SKC", "NSC", "CLR", "NCD" };
|
||||
return list;
|
||||
}
|
||||
|
||||
const QHash<QString, CCloudLayer::Coverage> &getCoverage() const
|
||||
{
|
||||
static const QHash<QString, CCloudLayer::Coverage> hash = {
|
||||
{ "///", CCloudLayer::None },
|
||||
{ "FEW", CCloudLayer::Few },
|
||||
{ "SCT", CCloudLayer::Scattered },
|
||||
{ "BKN", CCloudLayer::Broken },
|
||||
{ "OVC", CCloudLayer::Overcast }
|
||||
};
|
||||
static const QHash<QString, CCloudLayer::Coverage> hash = { { "///", CCloudLayer::None },
|
||||
{ "FEW", CCloudLayer::Few },
|
||||
{ "SCT", CCloudLayer::Scattered },
|
||||
{ "BKN", CCloudLayer::Broken },
|
||||
{ "OVC", CCloudLayer::Overcast } };
|
||||
return hash;
|
||||
}
|
||||
|
||||
@@ -681,7 +652,8 @@ namespace swift::misc::weather
|
||||
base *= 100;
|
||||
if (!ok) return false;
|
||||
|
||||
CCloudLayer cloudLayer(CAltitude(base, CAltitude::AboveGround, CLengthUnit::ft()), {}, getCoverage().value(coverageAsString));
|
||||
CCloudLayer cloudLayer(CAltitude(base, CAltitude::AboveGround, CLengthUnit::ft()), {},
|
||||
getCoverage().value(coverageAsString));
|
||||
metar.addCloudLayer(cloudLayer);
|
||||
QString cb_tcu = match.captured("cb_tcu");
|
||||
if (!cb_tcu.isEmpty()) {}
|
||||
@@ -696,7 +668,8 @@ namespace swift::misc::weather
|
||||
// Clear sky
|
||||
const QString clearSky = QString("(?<clear_sky>") + getClearSkyTokens().join('|') + QString(")");
|
||||
// Cloud coverage.
|
||||
const QString coverage = QString("(?<coverage>") + QStringList(getCoverage().keys()).join('|') + QString(")");
|
||||
const QString coverage =
|
||||
QString("(?<coverage>") + QStringList(getCoverage().keys()).join('|') + QString(")");
|
||||
// Cloud base
|
||||
const QString base = QStringLiteral("(?<base>\\d{3}|///)");
|
||||
// CB (Cumulonimbus) or TCU (Towering Cumulus) are appended to the cloud group without a space
|
||||
@@ -808,10 +781,8 @@ namespace swift::misc::weather
|
||||
protected:
|
||||
const QHash<QString, CPressureUnit> &getPressureUnits() const
|
||||
{
|
||||
static const QHash<QString, CPressureUnit> hash = {
|
||||
{ "Q", CPressureUnit::hPa() },
|
||||
{ "A", CPressureUnit::inHg() }
|
||||
};
|
||||
static const QHash<QString, CPressureUnit> hash = { { "Q", CPressureUnit::hPa() },
|
||||
{ "A", CPressureUnit::inHg() } };
|
||||
return hash;
|
||||
}
|
||||
|
||||
@@ -899,14 +870,15 @@ namespace swift::misc::weather
|
||||
const QString weather_phenomina2 = "(?<wp2>" + m_phenomina.join('|') + ")?";
|
||||
const QString weather_phenomina3 = "(?<wp3>" + m_phenomina.join('|') + ")?";
|
||||
const QString weather_phenomina4 = "(?<wp4>" + m_phenomina.join('|') + ")?";
|
||||
const QString regexp = "^RE" + qualifier_intensity + qualifier_descriptor + weather_phenomina1 + weather_phenomina2 + weather_phenomina3 + weather_phenomina4 + " ";
|
||||
const QString regexp = "^RE" + qualifier_intensity + qualifier_descriptor + weather_phenomina1 +
|
||||
weather_phenomina2 + weather_phenomina3 + weather_phenomina4 + " ";
|
||||
return regexp;
|
||||
}
|
||||
|
||||
const QStringList m_descriptor = QStringList { "MI", "BC", "PR", "DR", "BL", "SH", "TS", "FZ" };
|
||||
const QStringList m_phenomina = QStringList { "DZ", "RA", "SN", "SG", "IC", "PE", "GR", "GS",
|
||||
"BR", "FG", "FU", "VA", "IC", "DU", "SA", "HZ",
|
||||
"PY", "PO", "SQ", "FC", "SS", "DS" };
|
||||
const QStringList m_phenomina =
|
||||
QStringList { "DZ", "RA", "SN", "SG", "IC", "PE", "GR", "GS", "BR", "FG", "FU",
|
||||
"VA", "IC", "DU", "SA", "HZ", "PY", "PO", "SQ", "FC", "SS", "DS" };
|
||||
};
|
||||
|
||||
class CMetarDecoderWindShear : public IMetarDecoderPart
|
||||
@@ -948,13 +920,9 @@ namespace swift::misc::weather
|
||||
}
|
||||
};
|
||||
|
||||
CMetarDecoder::CMetarDecoder()
|
||||
{
|
||||
allocateDecoders();
|
||||
}
|
||||
CMetarDecoder::CMetarDecoder() { allocateDecoders(); }
|
||||
|
||||
CMetarDecoder::~CMetarDecoder()
|
||||
{}
|
||||
CMetarDecoder::~CMetarDecoder() {}
|
||||
|
||||
CMetar CMetarDecoder::decode(const QString &metarString) const
|
||||
{
|
||||
|
||||
@@ -9,8 +9,7 @@ SWIFT_DEFINE_SEQUENCE_MIXINS(swift::misc::weather, CMetar, CMetarList)
|
||||
|
||||
namespace swift::misc::weather
|
||||
{
|
||||
CMetarList::CMetarList(const CSequence<CMetar> &other) : CSequence<CMetar>(other)
|
||||
{}
|
||||
CMetarList::CMetarList(const CSequence<CMetar> &other) : CSequence<CMetar>(other) {}
|
||||
|
||||
CMetar CMetarList::getMetarForAirport(const aviation::CAirportIcaoCode &icao) const
|
||||
{
|
||||
|
||||
@@ -21,9 +21,7 @@ SWIFT_DECLARE_SEQUENCE_MIXINS(swift::misc::weather, CMetar, CMetarList)
|
||||
namespace swift::misc::weather
|
||||
{
|
||||
//! Sequence of Metars
|
||||
class SWIFT_MISC_EXPORT CMetarList :
|
||||
public CSequence<CMetar>,
|
||||
public swift::misc::mixin::MetaType<CMetarList>
|
||||
class SWIFT_MISC_EXPORT CMetarList : public CSequence<CMetar>, public swift::misc::mixin::MetaType<CMetarList>
|
||||
{
|
||||
public:
|
||||
SWIFT_MISC_DECLARE_USING_MIXIN_METATYPE(CMetarList)
|
||||
|
||||
@@ -17,7 +17,8 @@ namespace swift::misc::weather
|
||||
qRegisterMetaType<Descriptor>();
|
||||
}
|
||||
|
||||
CPresentWeather::CPresentWeather(Intensity intensity, Descriptor descriptor, int weatherPhenomena) : m_intensity(intensity), m_descriptor(descriptor), m_weatherPhenomena(weatherPhenomena)
|
||||
CPresentWeather::CPresentWeather(Intensity intensity, Descriptor descriptor, int weatherPhenomena)
|
||||
: m_intensity(intensity), m_descriptor(descriptor), m_weatherPhenomena(weatherPhenomena)
|
||||
{}
|
||||
|
||||
QVariant CPresentWeather::propertyByIndex(swift::misc::CPropertyIndexRef index) const
|
||||
@@ -26,14 +27,10 @@ namespace swift::misc::weather
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexIntensity:
|
||||
return QVariant::fromValue(m_intensity);
|
||||
case IndexDescriptor:
|
||||
return QVariant::fromValue(m_descriptor);
|
||||
case IndexWeatherPhenomena:
|
||||
return QVariant::fromValue(m_weatherPhenomena);
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
case IndexIntensity: return QVariant::fromValue(m_intensity);
|
||||
case IndexDescriptor: return QVariant::fromValue(m_descriptor);
|
||||
case IndexWeatherPhenomena: return QVariant::fromValue(m_weatherPhenomena);
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,18 +44,10 @@ namespace swift::misc::weather
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexIntensity:
|
||||
setIntensity(variant.value<Intensity>());
|
||||
break;
|
||||
case IndexDescriptor:
|
||||
setDescriptor(variant.value<Descriptor>());
|
||||
break;
|
||||
case IndexWeatherPhenomena:
|
||||
setWeatherPhenomena(variant.toInt());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
case IndexIntensity: setIntensity(variant.value<Intensity>()); break;
|
||||
case IndexDescriptor: setDescriptor(variant.value<Descriptor>()); break;
|
||||
case IndexWeatherPhenomena: setWeatherPhenomena(variant.toInt()); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,41 +61,34 @@ namespace swift::misc::weather
|
||||
};
|
||||
|
||||
static const QHash<Descriptor, QString> descriptorHash = {
|
||||
{ None, "" },
|
||||
{ Shallow, "shallow" },
|
||||
{ Patches, "patches" },
|
||||
{ Partial, "partial" },
|
||||
{ Drifting, "drifting" },
|
||||
{ Blowing, "blowing" },
|
||||
{ Showers, "showers" },
|
||||
{ Thunderstorm, "thunderstorm" },
|
||||
{ Freezing, "freezing" },
|
||||
{ None, "" }, { Shallow, "shallow" }, { Patches, "patches" },
|
||||
{ Partial, "partial" }, { Drifting, "drifting" }, { Blowing, "blowing" },
|
||||
{ Showers, "showers" }, { Thunderstorm, "thunderstorm" }, { Freezing, "freezing" },
|
||||
};
|
||||
|
||||
static const QHash<WeatherPhenomenon, QString> weatherPhenomenaHash = {
|
||||
{ Drizzle, "drizzle" },
|
||||
{ Rain, "rain" },
|
||||
{ Snow, "snow" },
|
||||
{ SnowGrains, "snow srains" },
|
||||
{ IceCrystals, "ice crystals" },
|
||||
{ IcePellets, "ice pellets" },
|
||||
{ Hail, "hail" },
|
||||
{ SnowPellets, "snow pellets" },
|
||||
{ Unknown, "unknown" },
|
||||
{ Mist, "mist" },
|
||||
{ Fog, "fog" },
|
||||
{ Smoke, "smoke" },
|
||||
{ VolcanicAsh, "volcanic ash" },
|
||||
{ Dust, "dust" },
|
||||
{ Sand, "sand" },
|
||||
{ Haze, "haze" },
|
||||
{ DustSandWhirls, "dustSand whirls" },
|
||||
{ Squalls, "squalls" },
|
||||
{ TornadoOrWaterspout, "tornado or waterspout" },
|
||||
{ FunnelCloud, "funnel cloud" },
|
||||
{ Sandstorm, "sandstorm" },
|
||||
{ Duststorm, "duststorm" }
|
||||
};
|
||||
static const QHash<WeatherPhenomenon, QString> weatherPhenomenaHash = { { Drizzle, "drizzle" },
|
||||
{ Rain, "rain" },
|
||||
{ Snow, "snow" },
|
||||
{ SnowGrains, "snow srains" },
|
||||
{ IceCrystals, "ice crystals" },
|
||||
{ IcePellets, "ice pellets" },
|
||||
{ Hail, "hail" },
|
||||
{ SnowPellets, "snow pellets" },
|
||||
{ Unknown, "unknown" },
|
||||
{ Mist, "mist" },
|
||||
{ Fog, "fog" },
|
||||
{ Smoke, "smoke" },
|
||||
{ VolcanicAsh, "volcanic ash" },
|
||||
{ Dust, "dust" },
|
||||
{ Sand, "sand" },
|
||||
{ Haze, "haze" },
|
||||
{ DustSandWhirls, "dustSand whirls" },
|
||||
{ Squalls, "squalls" },
|
||||
{ TornadoOrWaterspout,
|
||||
"tornado or waterspout" },
|
||||
{ FunnelCloud, "funnel cloud" },
|
||||
{ Sandstorm, "sandstorm" },
|
||||
{ Duststorm, "duststorm" } };
|
||||
|
||||
QString weatherPhenomenaAsString;
|
||||
for (const WeatherPhenomenon &wp : makeKeysRange(weatherPhenomenaHash))
|
||||
|
||||
@@ -7,7 +7,8 @@ SWIFT_DEFINE_SEQUENCE_MIXINS(swift::misc::weather, CPresentWeather, CPresentWeat
|
||||
|
||||
namespace swift::misc::weather
|
||||
{
|
||||
CPresentWeatherList::CPresentWeatherList(const CSequence<CPresentWeather> &other) : CSequence<CPresentWeather>(other)
|
||||
CPresentWeatherList::CPresentWeatherList(const CSequence<CPresentWeather> &other)
|
||||
: CSequence<CPresentWeather>(other)
|
||||
{}
|
||||
|
||||
} // namespace swift::misc::weather
|
||||
|
||||
@@ -14,7 +14,9 @@ SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::misc::weather, CWindLayer)
|
||||
namespace swift::misc::weather
|
||||
{
|
||||
|
||||
CWindLayer::CWindLayer(const CAltitude &level, const CAngle &direction, const CSpeed &speed, const CSpeed &gustSpeed) : m_level(level), m_directionMain(direction), m_speed(speed), m_gustSpeed(gustSpeed)
|
||||
CWindLayer::CWindLayer(const CAltitude &level, const CAngle &direction, const CSpeed &speed,
|
||||
const CSpeed &gustSpeed)
|
||||
: m_level(level), m_directionMain(direction), m_speed(speed), m_gustSpeed(gustSpeed)
|
||||
{}
|
||||
|
||||
QVariant CWindLayer::propertyByIndex(swift::misc::CPropertyIndexRef index) const
|
||||
@@ -23,18 +25,12 @@ namespace swift::misc::weather
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexLevel:
|
||||
return QVariant::fromValue(m_level);
|
||||
case IndexDirection:
|
||||
return QVariant::fromValue(m_directionMain);
|
||||
case IndexDirectionVariable:
|
||||
return QVariant::fromValue(m_directionVariable);
|
||||
case IndexSpeed:
|
||||
return QVariant::fromValue(m_speed);
|
||||
case IndexGustSpeed:
|
||||
return QVariant::fromValue(m_gustSpeed);
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
case IndexLevel: return QVariant::fromValue(m_level);
|
||||
case IndexDirection: return QVariant::fromValue(m_directionMain);
|
||||
case IndexDirectionVariable: return QVariant::fromValue(m_directionVariable);
|
||||
case IndexSpeed: return QVariant::fromValue(m_speed);
|
||||
case IndexGustSpeed: return QVariant::fromValue(m_gustSpeed);
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,24 +44,12 @@ namespace swift::misc::weather
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexLevel:
|
||||
setLevel(variant.value<CAltitude>());
|
||||
break;
|
||||
case IndexDirection:
|
||||
setDirection(variant.value<CAngle>());
|
||||
break;
|
||||
case IndexDirectionVariable:
|
||||
setDirectionVariable(variant.toBool());
|
||||
break;
|
||||
case IndexSpeed:
|
||||
setSpeed(variant.value<CSpeed>());
|
||||
break;
|
||||
case IndexGustSpeed:
|
||||
setGustSpeed(variant.value<CSpeed>());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
case IndexLevel: setLevel(variant.value<CAltitude>()); break;
|
||||
case IndexDirection: setDirection(variant.value<CAngle>()); break;
|
||||
case IndexDirectionVariable: setDirectionVariable(variant.toBool()); break;
|
||||
case IndexSpeed: setSpeed(variant.value<CSpeed>()); break;
|
||||
case IndexGustSpeed: setGustSpeed(variant.value<CSpeed>()); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +63,8 @@ namespace swift::misc::weather
|
||||
|
||||
if (m_directionFrom != CAngle() && m_directionTo != CAngle())
|
||||
{
|
||||
windAsString += QStringLiteral("variable between %1 and %2 ").arg(m_directionFrom.toQString(), m_directionTo.toQString());
|
||||
windAsString += QStringLiteral("variable between %1 and %2 ")
|
||||
.arg(m_directionFrom.toQString(), m_directionTo.toQString());
|
||||
}
|
||||
|
||||
windAsString += QStringLiteral("at %2").arg(m_speed.toQString());
|
||||
|
||||
@@ -62,7 +62,8 @@ namespace swift::misc::weather
|
||||
}
|
||||
|
||||
//! Set direction
|
||||
void setDirection(const physical_quantities::CAngle &main, const physical_quantities::CAngle &from, const physical_quantities::CAngle &to)
|
||||
void setDirection(const physical_quantities::CAngle &main, const physical_quantities::CAngle &from,
|
||||
const physical_quantities::CAngle &to)
|
||||
{
|
||||
m_directionMain = main;
|
||||
m_directionFrom = from;
|
||||
|
||||
@@ -12,13 +12,9 @@ SWIFT_DEFINE_SEQUENCE_MIXINS(swift::misc::weather, CWindLayer, CWindLayerList)
|
||||
|
||||
namespace swift::misc::weather
|
||||
{
|
||||
CWindLayerList::CWindLayerList(const CSequence<CWindLayer> &other) : CSequence<CWindLayer>(other)
|
||||
{}
|
||||
CWindLayerList::CWindLayerList(const CSequence<CWindLayer> &other) : CSequence<CWindLayer>(other) {}
|
||||
|
||||
bool CWindLayerList::containsLevel(const CAltitude &level) const
|
||||
{
|
||||
return contains(&CWindLayer::getLevel, level);
|
||||
}
|
||||
bool CWindLayerList::containsLevel(const CAltitude &level) const { return contains(&CWindLayer::getLevel, level); }
|
||||
|
||||
CWindLayer CWindLayerList::findByLevel(const CAltitude &level) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user