Add weather grid classes

refs #556
This commit is contained in:
Roland Winklmeier
2016-01-13 20:41:29 +01:00
parent 59508305ae
commit ca06933c0d
7 changed files with 273 additions and 0 deletions

View File

@@ -70,6 +70,7 @@ namespace BlackMisc
GlobalIndexCPresentWeather = 4200,
GlobalIndexCWindLayer = 4300,
GlobalIndexCTemperatureLayer = 4400,
GlobalIndexCGridPoint = 4500,
GlobalIndexICoordinateGeodetic = 5000,
GlobalIndexCCoordinateGeodetic = 5100,
GlobalIndexCClient = 6000,

View File

@@ -0,0 +1,86 @@
/* 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/gridpoint.h"
#include "blackmisc/propertyindex.h"
#include "blackmisc/blackmiscfreefunctions.h"
#include "blackmisc/variant.h"
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Geo;
namespace BlackMisc
{
namespace Weather
{
CGridPoint::CGridPoint(const Geo::CLatitude &latitude, const Geo::CLongitude longitude,
const CCloudLayerList &cloudLayers,
const CTemperatureLayerList &temperatureLayers,
const CWindLayerList &windLayers) :
m_latitude(latitude), m_longitude(longitude), m_cloudLayers(cloudLayers),
m_temperatureLayers(temperatureLayers), m_windLayers(windLayers)
{ }
CVariant CGridPoint::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
{
if (index.isMyself()) { return CVariant::from(*this); }
ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexLatitude:
return CVariant::fromValue(m_latitude);
case IndexLongitude:
return CVariant::fromValue(m_longitude);
case IndexCloudLayers:
return CVariant::fromValue(m_cloudLayers);
case IndexTemperatureLayers:
return CVariant::fromValue(m_temperatureLayers);
case IndexWindLayers:
return CVariant::fromValue(m_windLayers);
default:
return CValueObject::propertyByIndex(index);
}
}
void CGridPoint::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
{
if (index.isMyself()) { (*this) = variant.to<CGridPoint>(); return; }
ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexLatitude:
setLatitude(variant.value<CLatitude>());
break;
case IndexLongitude:
setLongitude(variant.value<CLongitude>());
break;
case IndexCloudLayers:
setCloudLayers(variant.value<CCloudLayerList>());
break;
case IndexTemperatureLayers:
setTemperatureLayers(variant.value<CTemperatureLayerList>());
break;
case IndexWindLayers:
setWindLayers(variant.value<CWindLayerList>());
break;
default:
CValueObject::setPropertyByIndex(variant, index);
break;
}
}
QString CGridPoint::convertToQString(bool /** i18n **/) const
{
qFatal("Not yet implemented!");
return {};
}
} // namespace
} // namespace

View File

@@ -0,0 +1,113 @@
/* 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_GRIDPOINT_H
#define BLACKMISC_WEATHER_GRIDPOINT_H
#include "blackmisc/blackmiscexport.h"
#include "blackmisc/valueobject.h"
#include "blackmisc/propertyindex.h"
#include "blackmisc/blackmiscfreefunctions.h"
#include "blackmisc/geo/latitude.h"
#include "blackmisc/geo/longitude.h"
#include "blackmisc/weather/cloudlayerlist.h"
#include "blackmisc/weather/temperaturelayerlist.h"
#include "blackmisc/weather/windlayerlist.h"
namespace BlackMisc
{
namespace Weather
{
/*!
* Value object for a cloud layer
*/
class BLACKMISC_EXPORT CGridPoint : public CValueObject<CGridPoint>
{
public:
//! Properties by index
enum ColumnIndex
{
IndexLatitude = BlackMisc::CPropertyIndex::GlobalIndexCGridPoint,
IndexLongitude,
IndexCloudLayers,
IndexTemperatureLayers,
IndexWindLayers
};
//! Default constructor.
CGridPoint() = default;
//! Constructor
CGridPoint(const Geo::CLatitude &latitude, const Geo::CLongitude longitude,
const CCloudLayerList &cloudLayers,
const CTemperatureLayerList &temperatureLayers,
const CWindLayerList &windLayers);
//! Set latitude
void setLatitude(const Geo::CLatitude &latitude) { m_latitude = latitude; }
//! Get latitude
Geo::CLatitude getLatitude() const { return m_latitude; }
//! Set longitude
void setLongitude(const Geo::CLongitude &longitude) { m_longitude = longitude; }
//! Get longitude
Geo::CLongitude getLongitude() const { return m_longitude; }
//! Set cloud layers
void setCloudLayers(const CCloudLayerList &cloudLayers) { m_cloudLayers = cloudLayers; }
//! Get cloud layers
CCloudLayerList getCloudLayers() const { return m_cloudLayers; }
//! Set temperature layers
void setTemperatureLayers(const CTemperatureLayerList &temperatureLayers) { m_temperatureLayers = temperatureLayers; }
//! Get temperature layers
CTemperatureLayerList getTemperatureLayers() const { return m_temperatureLayers; }
//! Set wind layers
void setWindLayers(const CWindLayerList &windLayers) { m_windLayers = windLayers; }
//! Get wind layers
CWindLayerList getWindLayers() const { return m_windLayers; }
//! \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(CGridPoint)
Geo::CLatitude m_latitude;
Geo::CLongitude m_longitude;
CCloudLayerList m_cloudLayers;
CTemperatureLayerList m_temperatureLayers;
CWindLayerList m_windLayers;
};
} // namespace
} // namespace
Q_DECLARE_METATYPE(BlackMisc::Weather::CGridPoint)
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Weather::CGridPoint, (
attr(o.m_latitude),
attr(o.m_longitude),
attr(o.m_cloudLayers),
attr(o.m_temperatureLayers),
attr(o.m_windLayers)
))
#endif // guard

View File

@@ -18,12 +18,14 @@ namespace BlackMisc
{
CCloudLayer::registerMetadata();
CCloudLayerList::registerMetadata();
CGridPoint::registerMetadata();
CMetar::registerMetadata();
CMetarSet::registerMetadata();
CPresentWeather::registerMetadata();
CPresentWeatherList::registerMetadata();
CTemperatureLayer::registerMetadata();
CTemperatureLayerList::registerMetadata();
CWeatherGrid::registerMetadata();
CWindLayer::registerMetadata();
CWindLayerList::registerMetadata();
}

View File

@@ -19,12 +19,14 @@
#include "blackmisc/weather/cloudlayer.h"
#include "blackmisc/weather/cloudlayerlist.h"
#include "blackmisc/weather/gridpoint.h"
#include "blackmisc/weather/metar.h"
#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/weathergrid.h"
#include "blackmisc/weather/windlayer.h"
#include "blackmisc/weather/windlayerlist.h"

View File

@@ -0,0 +1,23 @@
/* 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 "weathergrid.h"
using namespace BlackMisc::Aviation;
namespace BlackMisc
{
namespace Weather
{
CWeatherGrid::CWeatherGrid(const CSequence<CGridPoint> &other) :
CSequence<CGridPoint>(other)
{ }
} // namespace
} // namespace

View File

@@ -0,0 +1,46 @@
/* 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_WEATHERGRID_H
#define BLACKMISC_WEATHER_WEATHERGRID_H
#include "gridpoint.h"
#include "blackmisc/blackmiscexport.h"
#include "blackmisc/sequence.h"
namespace BlackMisc
{
namespace Weather
{
/*!
* Value object a list of weather grid points
*/
class BLACKMISC_EXPORT CWeatherGrid :
public CSequence<CGridPoint>,
public BlackMisc::Mixin::MetaType<CWeatherGrid>
{
public:
BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CWeatherGrid)
//! Default constructor.
CWeatherGrid() = default;
//! Construct from a base class object.
CWeatherGrid(const CSequence<CGridPoint> &other);
};
} //namespace
} // namespace
Q_DECLARE_METATYPE(BlackMisc::Weather::CWeatherGrid)
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Weather::CGridPoint>)
#endif //guard