mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
@@ -77,7 +77,7 @@ void CWeatherDataPrinter::ps_printWeatherData()
|
||||
for (int i = 0; i < cloudLayers.size(); i++)
|
||||
{
|
||||
const CCloudLayer &cloudLayer = cloudLayers[i];
|
||||
qtout << " Ceiling: " << cloudLayer.getCeiling().toQString() << endl;
|
||||
qtout << " Top: " << cloudLayer.getTop().toQString() << endl;
|
||||
qtout << " Base: " << cloudLayer.getBase().toQString() << endl;
|
||||
qtout << " Coverage: " << cloudLayer.getCoveragePercent() << " %" << endl;
|
||||
}
|
||||
|
||||
@@ -23,18 +23,18 @@ namespace BlackMisc
|
||||
{
|
||||
|
||||
CCloudLayer::CCloudLayer(BlackMisc::Aviation::CAltitude base,
|
||||
BlackMisc::Aviation::CAltitude ceiling,
|
||||
BlackMisc::Aviation::CAltitude top,
|
||||
Coverage coverage) :
|
||||
m_ceiling(ceiling), m_base(base), m_coverage(coverage)
|
||||
m_base(base), m_top(top), m_coverage(coverage)
|
||||
{ }
|
||||
|
||||
CCloudLayer::CCloudLayer(BlackMisc::Aviation::CAltitude base,
|
||||
BlackMisc::Aviation::CAltitude ceiling,
|
||||
BlackMisc::Aviation::CAltitude top,
|
||||
int precipitationRate,
|
||||
Precipitation precipitation,
|
||||
Clouds clouds,
|
||||
Coverage coverage) :
|
||||
m_ceiling(ceiling), m_base(base), m_precipitationRate(precipitationRate),
|
||||
m_base(base), m_top(top), m_precipitationRate(precipitationRate),
|
||||
m_precipitation(precipitation), m_clouds(clouds), m_coverage(coverage)
|
||||
{ }
|
||||
|
||||
@@ -44,8 +44,10 @@ namespace BlackMisc
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCeiling:
|
||||
return CVariant::fromValue(m_ceiling);
|
||||
case IndexBase:
|
||||
return CVariant::fromValue(m_base);
|
||||
case IndexTop:
|
||||
return CVariant::fromValue(m_top);
|
||||
case IndexCoverage:
|
||||
return CVariant::fromValue(m_coverage);
|
||||
default:
|
||||
@@ -59,8 +61,11 @@ namespace BlackMisc
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCeiling:
|
||||
setCeiling(variant.value<CAltitude>());
|
||||
case IndexBase:
|
||||
setBase(variant.value<CAltitude>());
|
||||
break;
|
||||
case IndexTop:
|
||||
setTop(variant.value<CAltitude>());
|
||||
break;
|
||||
case IndexCoverage:
|
||||
setCoverage(variant.value<Coverage>());
|
||||
@@ -82,7 +87,7 @@ namespace BlackMisc
|
||||
{ Overcast, "overcast" }
|
||||
};
|
||||
|
||||
return QString("%1 in %2").arg(hash.value(m_coverage)).arg(m_ceiling.toQString());
|
||||
return QString("%1 from %2 to %3").arg(hash.value(m_coverage), m_base.toQString(), m_top.toQString());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -59,8 +59,8 @@ namespace BlackMisc
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexCloudLayer = BlackMisc::CPropertyIndex::GlobalIndexCCloudLayer,
|
||||
IndexCeiling,
|
||||
IndexBase = BlackMisc::CPropertyIndex::GlobalIndexCCloudLayer,
|
||||
IndexTop,
|
||||
IndexCoverage
|
||||
};
|
||||
|
||||
@@ -69,12 +69,12 @@ namespace BlackMisc
|
||||
|
||||
//! Constructor
|
||||
CCloudLayer(BlackMisc::Aviation::CAltitude base,
|
||||
BlackMisc::Aviation::CAltitude ceiling,
|
||||
BlackMisc::Aviation::CAltitude top,
|
||||
Coverage coverage);
|
||||
|
||||
//! Constructor
|
||||
CCloudLayer(BlackMisc::Aviation::CAltitude base,
|
||||
BlackMisc::Aviation::CAltitude ceiling,
|
||||
BlackMisc::Aviation::CAltitude top,
|
||||
int precipitationRate,
|
||||
Precipitation precipitation,
|
||||
Clouds clouds,
|
||||
@@ -86,11 +86,11 @@ namespace BlackMisc
|
||||
//! Get base
|
||||
BlackMisc::Aviation::CAltitude getBase() const { return m_base; }
|
||||
|
||||
//! Set ceiling
|
||||
void setCeiling(BlackMisc::Aviation::CAltitude ceiling) { m_ceiling = ceiling; }
|
||||
//! Set layer top
|
||||
void setTop(BlackMisc::Aviation::CAltitude top) { m_top = top; }
|
||||
|
||||
//! Get ceiling
|
||||
BlackMisc::Aviation::CAltitude getCeiling() const { return m_ceiling; }
|
||||
//! Get layer top
|
||||
BlackMisc::Aviation::CAltitude getTop() const { return m_top; }
|
||||
|
||||
//! Set precipitation rate
|
||||
void setPrecipitationRate(int rate) { m_precipitationRate = rate; }
|
||||
@@ -134,7 +134,7 @@ namespace BlackMisc
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CCloudLayer)
|
||||
BlackMisc::Aviation::CAltitude m_base;
|
||||
BlackMisc::Aviation::CAltitude m_ceiling;
|
||||
BlackMisc::Aviation::CAltitude m_top;
|
||||
int m_precipitationRate = 0;
|
||||
Precipitation m_precipitation = NoPrecipitation;
|
||||
Clouds m_clouds = NoClouds;
|
||||
@@ -148,7 +148,7 @@ Q_DECLARE_METATYPE(BlackMisc::Weather::CCloudLayer)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Weather::CCloudLayer::Coverage)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Weather::CCloudLayer, (
|
||||
attr(o.m_base),
|
||||
attr(o.m_ceiling),
|
||||
attr(o.m_top),
|
||||
attr(o.m_precipitationRate),
|
||||
attr(o.m_precipitation),
|
||||
attr(o.m_clouds),
|
||||
|
||||
@@ -19,14 +19,14 @@ namespace BlackMisc
|
||||
CSequence<CCloudLayer>(other)
|
||||
{ }
|
||||
|
||||
bool CCloudLayerList::containsCeiling(const CAltitude &ceiling) const
|
||||
bool CCloudLayerList::containsBase(const CAltitude &base) const
|
||||
{
|
||||
return contains(&CCloudLayer::getCeiling, ceiling);
|
||||
return contains(&CCloudLayer::getBase, base);
|
||||
}
|
||||
|
||||
CCloudLayer CCloudLayerList::findByCeiling(const CAltitude &ceiling) const
|
||||
CCloudLayer CCloudLayerList::findByBase(const CAltitude &base) const
|
||||
{
|
||||
return findFirstByOrDefault(&CCloudLayer::getCeiling, ceiling);
|
||||
return findFirstByOrDefault(&CCloudLayer::getBase, base);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -39,11 +39,11 @@ namespace BlackMisc
|
||||
//! Construct from a base class object.
|
||||
CCloudLayerList(const CSequence<CCloudLayer> &other);
|
||||
|
||||
//! Contains cloud layer with ceiling?
|
||||
bool containsCeiling(const BlackMisc::Aviation::CAltitude &ceiling) const;
|
||||
//! Contains cloud layer with base?
|
||||
bool containsBase(const BlackMisc::Aviation::CAltitude &base) const;
|
||||
|
||||
//! Find cloud layer by ceiling
|
||||
CCloudLayer findByCeiling(const BlackMisc::Aviation::CAltitude &ceiling) const;
|
||||
//! Find cloud layer by base
|
||||
CCloudLayer findByBase(const BlackMisc::Aviation::CAltitude &base) const;
|
||||
};
|
||||
|
||||
} //namespace
|
||||
|
||||
@@ -560,12 +560,12 @@ namespace BlackMisc
|
||||
static const QString clearSky = QString("(?<clear_sky>") + getClearSkyTokens().join('|') + QString(")");
|
||||
// Cloud coverage.
|
||||
static const QString coverage = QString("(?<coverage>") + QStringList(getCoverage().keys()).join('|') + QString(")");
|
||||
// Cloud ceiling
|
||||
static const QString ceiling = QStringLiteral("(?<ceiling>\\d{3}|///)");
|
||||
// Cloud base
|
||||
static const QString base = QStringLiteral("(?<base>\\d{3}|///)");
|
||||
// CB (Cumulonimbus) or TCU (Towering Cumulus) are appended to the cloud group without a space
|
||||
static const QString extra = QStringLiteral("(?<cb_tcu>CB|TCU|///)?");
|
||||
// Add space at the end
|
||||
static const QString regexp = QString("^(") + clearSky + '|' + coverage + ceiling + extra + QString(") ");
|
||||
static const QString regexp = QString("^(") + clearSky + '|' + coverage + base + extra + QString(") ");
|
||||
return regexp;
|
||||
}
|
||||
|
||||
@@ -579,18 +579,18 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
QString coverageAsString = match.captured("coverage");
|
||||
QString ceilingAsString = match.captured("ceiling");
|
||||
Q_ASSERT(!coverageAsString.isEmpty() && !ceilingAsString.isEmpty());
|
||||
QString baseAsString = match.captured("base");
|
||||
Q_ASSERT(!coverageAsString.isEmpty() && !baseAsString.isEmpty());
|
||||
Q_ASSERT(getCoverage().contains(coverageAsString));
|
||||
if (ceilingAsString == "///") return true;
|
||||
if (baseAsString == "///") return true;
|
||||
|
||||
bool ok = false;
|
||||
int ceiling = ceilingAsString.toInt(&ok);
|
||||
int base = baseAsString.toInt(&ok);
|
||||
// Factor 100
|
||||
ceiling *= 100;
|
||||
base *= 100;
|
||||
if (!ok) return false;
|
||||
|
||||
CCloudLayer cloudLayer(CAltitude(ceiling, 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()) { }
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
NewVis vis;
|
||||
vis.LowerAlt = visibilityLayer.getBase().value(CLengthUnit::m());
|
||||
vis.UpperAlt = visibilityLayer.getCeiling().value(CLengthUnit::m());
|
||||
vis.UpperAlt = visibilityLayer.getTop().value(CLengthUnit::m());
|
||||
vis.Range = visibilityLayer.getVisibility().value(CLengthUnit::mi()) * 100;
|
||||
nw.Vis = vis;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ namespace BlackSimPlugin
|
||||
default: cloud.Type = 0;
|
||||
}
|
||||
|
||||
cloud.UpperAlt = cloudLayer.getCeiling().value(CLengthUnit::m());
|
||||
cloud.UpperAlt = cloudLayer.getBase().value(CLengthUnit::m());
|
||||
nw.Cloud[nw.nCloudsCtr++] = cloud;
|
||||
}
|
||||
|
||||
|
||||
@@ -544,7 +544,7 @@ namespace BlackSimPlugin
|
||||
for (const auto &cloudLayer : cloudLayers)
|
||||
{
|
||||
int base = cloudLayer.getBase().value(CLengthUnit::m());
|
||||
int top = cloudLayer.getCeiling().value(CLengthUnit::m());
|
||||
int top = cloudLayer.getTop().value(CLengthUnit::m());
|
||||
|
||||
int coverage = 0;
|
||||
switch(cloudLayer.getCoverage())
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace BlackWxPlugin
|
||||
{
|
||||
CCloudLayer cloudLayer;
|
||||
cloudLayer.setBase(CAltitude(cloudLayerIt.value().bottomLevel, CAltitude::MeanSeaLevel, CLengthUnit::ft()));
|
||||
cloudLayer.setCeiling(CAltitude(cloudLayerIt.value().topLevel, CAltitude::MeanSeaLevel, CLengthUnit::ft()));
|
||||
cloudLayer.setTop(CAltitude(cloudLayerIt.value().topLevel, CAltitude::MeanSeaLevel, CLengthUnit::ft()));
|
||||
cloudLayer.setCoveragePercent(cloudLayerIt.value().totalCoverage);
|
||||
cloudLayers.insert(cloudLayer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user