Cloud layers have a base and a top

refs #579
This commit is contained in:
Roland Winklmeier
2016-03-01 23:48:13 +01:00
parent fe9c8ca3de
commit 48fdfbea3e
9 changed files with 46 additions and 41 deletions

View File

@@ -77,7 +77,7 @@ void CWeatherDataPrinter::ps_printWeatherData()
for (int i = 0; i < cloudLayers.size(); i++) for (int i = 0; i < cloudLayers.size(); i++)
{ {
const CCloudLayer &cloudLayer = cloudLayers[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 << " Base: " << cloudLayer.getBase().toQString() << endl;
qtout << " Coverage: " << cloudLayer.getCoveragePercent() << " %" << endl; qtout << " Coverage: " << cloudLayer.getCoveragePercent() << " %" << endl;
} }

View File

@@ -23,18 +23,18 @@ namespace BlackMisc
{ {
CCloudLayer::CCloudLayer(BlackMisc::Aviation::CAltitude base, CCloudLayer::CCloudLayer(BlackMisc::Aviation::CAltitude base,
BlackMisc::Aviation::CAltitude ceiling, BlackMisc::Aviation::CAltitude top,
Coverage coverage) : 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, CCloudLayer::CCloudLayer(BlackMisc::Aviation::CAltitude base,
BlackMisc::Aviation::CAltitude ceiling, BlackMisc::Aviation::CAltitude top,
int precipitationRate, int precipitationRate,
Precipitation precipitation, Precipitation precipitation,
Clouds clouds, Clouds clouds,
Coverage coverage) : 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) m_precipitation(precipitation), m_clouds(clouds), m_coverage(coverage)
{ } { }
@@ -44,8 +44,10 @@ namespace BlackMisc
ColumnIndex i = index.frontCasted<ColumnIndex>(); ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexCeiling: case IndexBase:
return CVariant::fromValue(m_ceiling); return CVariant::fromValue(m_base);
case IndexTop:
return CVariant::fromValue(m_top);
case IndexCoverage: case IndexCoverage:
return CVariant::fromValue(m_coverage); return CVariant::fromValue(m_coverage);
default: default:
@@ -59,8 +61,11 @@ namespace BlackMisc
ColumnIndex i = index.frontCasted<ColumnIndex>(); ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexCeiling: case IndexBase:
setCeiling(variant.value<CAltitude>()); setBase(variant.value<CAltitude>());
break;
case IndexTop:
setTop(variant.value<CAltitude>());
break; break;
case IndexCoverage: case IndexCoverage:
setCoverage(variant.value<Coverage>()); setCoverage(variant.value<Coverage>());
@@ -82,7 +87,7 @@ namespace BlackMisc
{ Overcast, "overcast" } { 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 } // namespace

View File

@@ -59,8 +59,8 @@ namespace BlackMisc
//! Properties by index //! Properties by index
enum ColumnIndex enum ColumnIndex
{ {
IndexCloudLayer = BlackMisc::CPropertyIndex::GlobalIndexCCloudLayer, IndexBase = BlackMisc::CPropertyIndex::GlobalIndexCCloudLayer,
IndexCeiling, IndexTop,
IndexCoverage IndexCoverage
}; };
@@ -69,12 +69,12 @@ namespace BlackMisc
//! Constructor //! Constructor
CCloudLayer(BlackMisc::Aviation::CAltitude base, CCloudLayer(BlackMisc::Aviation::CAltitude base,
BlackMisc::Aviation::CAltitude ceiling, BlackMisc::Aviation::CAltitude top,
Coverage coverage); Coverage coverage);
//! Constructor //! Constructor
CCloudLayer(BlackMisc::Aviation::CAltitude base, CCloudLayer(BlackMisc::Aviation::CAltitude base,
BlackMisc::Aviation::CAltitude ceiling, BlackMisc::Aviation::CAltitude top,
int precipitationRate, int precipitationRate,
Precipitation precipitation, Precipitation precipitation,
Clouds clouds, Clouds clouds,
@@ -86,11 +86,11 @@ namespace BlackMisc
//! Get base //! Get base
BlackMisc::Aviation::CAltitude getBase() const { return m_base; } BlackMisc::Aviation::CAltitude getBase() const { return m_base; }
//! Set ceiling //! Set layer top
void setCeiling(BlackMisc::Aviation::CAltitude ceiling) { m_ceiling = ceiling; } void setTop(BlackMisc::Aviation::CAltitude top) { m_top = top; }
//! Get ceiling //! Get layer top
BlackMisc::Aviation::CAltitude getCeiling() const { return m_ceiling; } BlackMisc::Aviation::CAltitude getTop() const { return m_top; }
//! Set precipitation rate //! Set precipitation rate
void setPrecipitationRate(int rate) { m_precipitationRate = rate; } void setPrecipitationRate(int rate) { m_precipitationRate = rate; }
@@ -134,7 +134,7 @@ namespace BlackMisc
private: private:
BLACK_ENABLE_TUPLE_CONVERSION(CCloudLayer) BLACK_ENABLE_TUPLE_CONVERSION(CCloudLayer)
BlackMisc::Aviation::CAltitude m_base; BlackMisc::Aviation::CAltitude m_base;
BlackMisc::Aviation::CAltitude m_ceiling; BlackMisc::Aviation::CAltitude m_top;
int m_precipitationRate = 0; int m_precipitationRate = 0;
Precipitation m_precipitation = NoPrecipitation; Precipitation m_precipitation = NoPrecipitation;
Clouds m_clouds = NoClouds; Clouds m_clouds = NoClouds;
@@ -148,7 +148,7 @@ Q_DECLARE_METATYPE(BlackMisc::Weather::CCloudLayer)
Q_DECLARE_METATYPE(BlackMisc::Weather::CCloudLayer::Coverage) Q_DECLARE_METATYPE(BlackMisc::Weather::CCloudLayer::Coverage)
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Weather::CCloudLayer, ( BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Weather::CCloudLayer, (
attr(o.m_base), attr(o.m_base),
attr(o.m_ceiling), attr(o.m_top),
attr(o.m_precipitationRate), attr(o.m_precipitationRate),
attr(o.m_precipitation), attr(o.m_precipitation),
attr(o.m_clouds), attr(o.m_clouds),

View File

@@ -19,14 +19,14 @@ namespace BlackMisc
CSequence<CCloudLayer>(other) 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 } // namespace

View File

@@ -39,11 +39,11 @@ namespace BlackMisc
//! Construct from a base class object. //! Construct from a base class object.
CCloudLayerList(const CSequence<CCloudLayer> &other); CCloudLayerList(const CSequence<CCloudLayer> &other);
//! Contains cloud layer with ceiling? //! Contains cloud layer with base?
bool containsCeiling(const BlackMisc::Aviation::CAltitude &ceiling) const; bool containsBase(const BlackMisc::Aviation::CAltitude &base) const;
//! Find cloud layer by ceiling //! Find cloud layer by base
CCloudLayer findByCeiling(const BlackMisc::Aviation::CAltitude &ceiling) const; CCloudLayer findByBase(const BlackMisc::Aviation::CAltitude &base) const;
}; };
} //namespace } //namespace

View File

@@ -560,12 +560,12 @@ namespace BlackMisc
static const QString clearSky = QString("(?<clear_sky>") + getClearSkyTokens().join('|') + QString(")"); static const QString clearSky = QString("(?<clear_sky>") + getClearSkyTokens().join('|') + QString(")");
// Cloud coverage. // Cloud coverage.
static const QString coverage = QString("(?<coverage>") + QStringList(getCoverage().keys()).join('|') + QString(")"); static const QString coverage = QString("(?<coverage>") + QStringList(getCoverage().keys()).join('|') + QString(")");
// Cloud ceiling // Cloud base
static const QString ceiling = QStringLiteral("(?<ceiling>\\d{3}|///)"); static const QString base = QStringLiteral("(?<base>\\d{3}|///)");
// CB (Cumulonimbus) or TCU (Towering Cumulus) are appended to the cloud group without a space // CB (Cumulonimbus) or TCU (Towering Cumulus) are appended to the cloud group without a space
static const QString extra = QStringLiteral("(?<cb_tcu>CB|TCU|///)?"); static const QString extra = QStringLiteral("(?<cb_tcu>CB|TCU|///)?");
// Add space at the end // 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; return regexp;
} }
@@ -579,18 +579,18 @@ namespace BlackMisc
} }
QString coverageAsString = match.captured("coverage"); QString coverageAsString = match.captured("coverage");
QString ceilingAsString = match.captured("ceiling"); QString baseAsString = match.captured("base");
Q_ASSERT(!coverageAsString.isEmpty() && !ceilingAsString.isEmpty()); Q_ASSERT(!coverageAsString.isEmpty() && !baseAsString.isEmpty());
Q_ASSERT(getCoverage().contains(coverageAsString)); Q_ASSERT(getCoverage().contains(coverageAsString));
if (ceilingAsString == "///") return true; if (baseAsString == "///") return true;
bool ok = false; bool ok = false;
int ceiling = ceilingAsString.toInt(&ok); int base = baseAsString.toInt(&ok);
// Factor 100 // Factor 100
ceiling *= 100; base *= 100;
if (!ok) return false; 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); metar.addCloudLayer(cloudLayer);
QString cb_tcu = match.captured("cb_tcu"); QString cb_tcu = match.captured("cb_tcu");
if (!cb_tcu.isEmpty()) { } if (!cb_tcu.isEmpty()) { }

View File

@@ -128,7 +128,7 @@ namespace BlackSimPlugin
{ {
NewVis vis; NewVis vis;
vis.LowerAlt = visibilityLayer.getBase().value(CLengthUnit::m()); 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; vis.Range = visibilityLayer.getVisibility().value(CLengthUnit::mi()) * 100;
nw.Vis = vis; nw.Vis = vis;
} }
@@ -179,7 +179,7 @@ namespace BlackSimPlugin
default: cloud.Type = 0; default: cloud.Type = 0;
} }
cloud.UpperAlt = cloudLayer.getCeiling().value(CLengthUnit::m()); cloud.UpperAlt = cloudLayer.getBase().value(CLengthUnit::m());
nw.Cloud[nw.nCloudsCtr++] = cloud; nw.Cloud[nw.nCloudsCtr++] = cloud;
} }

View File

@@ -544,7 +544,7 @@ namespace BlackSimPlugin
for (const auto &cloudLayer : cloudLayers) for (const auto &cloudLayer : cloudLayers)
{ {
int base = cloudLayer.getBase().value(CLengthUnit::m()); int base = cloudLayer.getBase().value(CLengthUnit::m());
int top = cloudLayer.getCeiling().value(CLengthUnit::m()); int top = cloudLayer.getTop().value(CLengthUnit::m());
int coverage = 0; int coverage = 0;
switch(cloudLayer.getCoverage()) switch(cloudLayer.getCoverage())

View File

@@ -263,7 +263,7 @@ namespace BlackWxPlugin
{ {
CCloudLayer cloudLayer; CCloudLayer cloudLayer;
cloudLayer.setBase(CAltitude(cloudLayerIt.value().bottomLevel, CAltitude::MeanSeaLevel, CLengthUnit::ft())); 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); cloudLayer.setCoveragePercent(cloudLayerIt.value().totalCoverage);
cloudLayers.insert(cloudLayer); cloudLayers.insert(cloudLayer);
} }