mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
Add CTemperatureLayer, CTemperatureLayerList and CWindLayerList classes
refs #556
This commit is contained in:
@@ -69,6 +69,7 @@ namespace BlackMisc
|
||||
GlobalIndexCCloudLayer = 4100,
|
||||
GlobalIndexCPresentWeather = 4200,
|
||||
GlobalIndexCWindLayer = 4300,
|
||||
GlobalIndexCTemperatureLayer = 4400,
|
||||
GlobalIndexICoordinateGeodetic = 5000,
|
||||
GlobalIndexCCoordinateGeodetic = 5100,
|
||||
GlobalIndexCClient = 6000,
|
||||
|
||||
@@ -22,7 +22,10 @@ namespace BlackMisc
|
||||
CMetarSet::registerMetadata();
|
||||
CPresentWeather::registerMetadata();
|
||||
CPresentWeatherList::registerMetadata();
|
||||
CTemperatureLayer::registerMetadata();
|
||||
CTemperatureLayerList::registerMetadata();
|
||||
CWindLayer::registerMetadata();
|
||||
CWindLayerList::registerMetadata();
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
74
src/blackmisc/weather/temperaturelayer.cpp
Normal file
74
src/blackmisc/weather/temperaturelayer.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackmisc/weather/temperaturelayer.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <tuple>
|
||||
#include <QRegularExpression>
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Weather
|
||||
{
|
||||
|
||||
CTemperatureLayer::CTemperatureLayer(const CAltitude &level, const CTemperature &value, double relativeHumidity) :
|
||||
m_level(level), m_temperature(value), m_relativeHumidity(relativeHumidity)
|
||||
{ }
|
||||
|
||||
CVariant CTemperatureLayer::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexLevel:
|
||||
return CVariant::fromValue(m_level);
|
||||
case IndexTemperature:
|
||||
return CVariant::fromValue(m_temperature);
|
||||
case IndexRelativeHumidity:
|
||||
return CVariant::fromValue(m_relativeHumidity);
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CTemperatureLayer::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CTemperatureLayer>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexLevel:
|
||||
setLevel(variant.value<CAltitude>());
|
||||
break;
|
||||
case IndexTemperature:
|
||||
setTemperature(variant.value<CTemperature>());
|
||||
break;
|
||||
case IndexRelativeHumidity:
|
||||
setRelativeHumidity(variant.value<double>());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(variant, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QString CTemperatureLayer::convertToQString(bool /** i18n **/) const
|
||||
{
|
||||
return QString("%1 %2 at %3").arg(m_temperature.toQString(), QString::number(m_relativeHumidity), m_level.toQString());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
90
src/blackmisc/weather/temperaturelayer.h
Normal file
90
src/blackmisc/weather/temperaturelayer.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_WEATHER_TEMPERATURELAYER_H
|
||||
#define BLACKMISC_WEATHER_TEMPERATURELAYER_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/aviation/altitude.h"
|
||||
#include "blackmisc/pq/temperature.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Weather
|
||||
{
|
||||
/*!
|
||||
* Value object for a temperature layer
|
||||
*/
|
||||
class BLACKMISC_EXPORT CTemperatureLayer : public CValueObject<CTemperatureLayer>
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexTemperatureLayer = BlackMisc::CPropertyIndex::GlobalIndexCTemperatureLayer,
|
||||
IndexLevel,
|
||||
IndexTemperature,
|
||||
IndexRelativeHumidity
|
||||
};
|
||||
|
||||
//! Default constructor.
|
||||
CTemperatureLayer() = default;
|
||||
|
||||
//! Constructor
|
||||
CTemperatureLayer(const BlackMisc::Aviation::CAltitude &level, const PhysicalQuantities::CTemperature &value, double relativeHumidity);
|
||||
|
||||
//! Set level
|
||||
void setLevel(const BlackMisc::Aviation::CAltitude &level) { m_level = level; }
|
||||
|
||||
//! Get level
|
||||
BlackMisc::Aviation::CAltitude getLevel() const { return m_level; }
|
||||
|
||||
//! Set temperature
|
||||
void setTemperature(const PhysicalQuantities::CTemperature &value) { m_temperature = value; }
|
||||
|
||||
//! Get temperature
|
||||
PhysicalQuantities::CTemperature getTemperature() const { return m_temperature; }
|
||||
|
||||
//! Set relative humidity
|
||||
void setRelativeHumidity(double value) { m_relativeHumidity = value; }
|
||||
|
||||
//! Get relative humidity
|
||||
double getRelativeHumidity() const { return m_relativeHumidity; }
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CTemperatureLayer)
|
||||
BlackMisc::Aviation::CAltitude m_level;
|
||||
PhysicalQuantities::CTemperature m_temperature;
|
||||
double m_relativeHumidity = 0;
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Weather::CTemperatureLayer)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Weather::CTemperatureLayer, (
|
||||
attr(o.m_level),
|
||||
attr(o.m_temperature),
|
||||
attr(o.m_relativeHumidity)
|
||||
))
|
||||
|
||||
#endif // guard
|
||||
33
src/blackmisc/weather/temperaturelayerlist.cpp
Normal file
33
src/blackmisc/weather/temperaturelayerlist.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "temperaturelayerlist.h"
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Weather
|
||||
{
|
||||
CTemperatureLayerList::CTemperatureLayerList(const CSequence<CTemperatureLayer> &other) :
|
||||
CSequence<CTemperatureLayer>(other)
|
||||
{ }
|
||||
|
||||
bool CTemperatureLayerList::containsLevel(const CAltitude &level) const
|
||||
{
|
||||
return contains(&CTemperatureLayer::getLevel, level);
|
||||
}
|
||||
|
||||
CTemperatureLayer CTemperatureLayerList::findByLevel(const CAltitude &level) const
|
||||
{
|
||||
return findFirstByOrDefault(&CTemperatureLayer::getLevel, level);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
52
src/blackmisc/weather/temperaturelayerlist.h
Normal file
52
src/blackmisc/weather/temperaturelayerlist.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_WEATHER_TEMPERATURELAYERLIST_H
|
||||
#define BLACKMISC_WEATHER_TEMPERATURELAYERLIST_H
|
||||
|
||||
#include "temperaturelayer.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Weather
|
||||
{
|
||||
/*!
|
||||
* Value object encapsulating a set of temperature layers
|
||||
*/
|
||||
class BLACKMISC_EXPORT CTemperatureLayerList :
|
||||
public CSequence<CTemperatureLayer>,
|
||||
public BlackMisc::Mixin::MetaType<CTemperatureLayerList>
|
||||
{
|
||||
public:
|
||||
BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CTemperatureLayerList)
|
||||
|
||||
//! Default constructor.
|
||||
CTemperatureLayerList() = default;
|
||||
|
||||
//! Construct from a base class object.
|
||||
CTemperatureLayerList(const CSequence<CTemperatureLayer> &other);
|
||||
|
||||
//! Contains temperature layer with level?
|
||||
bool containsLevel(const BlackMisc::Aviation::CAltitude &level) const;
|
||||
|
||||
//! Find cloud layer by level
|
||||
CTemperatureLayer findByLevel(const BlackMisc::Aviation::CAltitude &level) const;
|
||||
};
|
||||
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Weather::CTemperatureLayerList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Weather::CTemperatureLayer>)
|
||||
|
||||
#endif //guard
|
||||
@@ -23,6 +23,9 @@
|
||||
#include "blackmisc/weather/metarset.h"
|
||||
#include "blackmisc/weather/presentweather.h"
|
||||
#include "blackmisc/weather/presentweatherlist.h"
|
||||
#include "blackmisc/weather/temperaturelayer.h"
|
||||
#include "blackmisc/weather/temperaturelayerlist.h"
|
||||
#include "blackmisc/weather/windlayer.h"
|
||||
#include "blackmisc/weather/windlayerlist.h"
|
||||
|
||||
#endif // guard
|
||||
|
||||
33
src/blackmisc/weather/windlayerlist.cpp
Normal file
33
src/blackmisc/weather/windlayerlist.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "windlayerlist.h"
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Weather
|
||||
{
|
||||
CWindLayerList::CWindLayerList(const CSequence<CWindLayer> &other) :
|
||||
CSequence<CWindLayer>(other)
|
||||
{ }
|
||||
|
||||
bool CWindLayerList::containsLevel(const CAltitude &level) const
|
||||
{
|
||||
return contains(&CWindLayer::getLevel, level);
|
||||
}
|
||||
|
||||
CWindLayer CWindLayerList::findByLevel(const CAltitude &level) const
|
||||
{
|
||||
return findFirstByOrDefault(&CWindLayer::getLevel, level);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
52
src/blackmisc/weather/windlayerlist.h
Normal file
52
src/blackmisc/weather/windlayerlist.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_WEATHER_WINDLAYERLIST_H
|
||||
#define BLACKMISC_WEATHER_WINDLAYERLIST_H
|
||||
|
||||
#include "windlayer.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Weather
|
||||
{
|
||||
/*!
|
||||
* Value object encapsulating a set of wind layers
|
||||
*/
|
||||
class BLACKMISC_EXPORT CWindLayerList :
|
||||
public CSequence<CWindLayer>,
|
||||
public BlackMisc::Mixin::MetaType<CWindLayerList>
|
||||
{
|
||||
public:
|
||||
BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CWindLayerList)
|
||||
|
||||
//! Default constructor.
|
||||
CWindLayerList() = default;
|
||||
|
||||
//! Construct from a base class object.
|
||||
CWindLayerList(const CSequence<CWindLayer> &other);
|
||||
|
||||
//! Contains cloud layer with level?
|
||||
bool containsLevel(const BlackMisc::Aviation::CAltitude &level) const;
|
||||
|
||||
//! Find cloud layer by level
|
||||
CWindLayer findByLevel(const BlackMisc::Aviation::CAltitude &level) const;
|
||||
};
|
||||
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Weather::CWindLayerList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Weather::CWindLayer>)
|
||||
|
||||
#endif //guard
|
||||
Reference in New Issue
Block a user