From 779191e66b4dfed229f05e6a781a0182a938b49e Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Mon, 28 Mar 2016 17:06:24 +0200 Subject: [PATCH] Add string based identifier to CGridPoint refs #612 --- src/blackmisc/weather/gridpoint.cpp | 21 ++++++++++++++++++--- src/blackmisc/weather/gridpoint.h | 19 +++++++++++++++++-- src/blackmisc/weather/weathergrid.cpp | 2 ++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/blackmisc/weather/gridpoint.cpp b/src/blackmisc/weather/gridpoint.cpp index d675b678a..2d97d33b4 100644 --- a/src/blackmisc/weather/gridpoint.cpp +++ b/src/blackmisc/weather/gridpoint.cpp @@ -19,13 +19,23 @@ namespace BlackMisc { namespace Weather { - CGridPoint::CGridPoint(const Geo::CCoordinateGeodetic &position, + CGridPoint::CGridPoint(const QString &identifier, + const Geo::CCoordinateGeodetic &position) : + m_identifier(identifier), + m_position(position) + { } + + CGridPoint::CGridPoint(const QString &identifier, + const Geo::CCoordinateGeodetic &position, const CCloudLayerList &cloudLayers, const CTemperatureLayerList &temperatureLayers, const CVisibilityLayerList &visibilityLayers, const CWindLayerList &windLayers) : - m_position(position), m_cloudLayers(cloudLayers), - m_temperatureLayers(temperatureLayers), m_visibilityLayers(visibilityLayers), + m_identifier(identifier), + m_position(position), + m_cloudLayers(cloudLayers), + m_temperatureLayers(temperatureLayers), + m_visibilityLayers(visibilityLayers), m_windLayers(windLayers) { } @@ -43,6 +53,8 @@ namespace BlackMisc ColumnIndex i = index.frontCasted(); switch (i) { + case IndexIdentifier: + return CVariant::fromValue(m_identifier); case IndexPosition: return CVariant::fromValue(m_position); case IndexCloudLayers: @@ -62,6 +74,9 @@ namespace BlackMisc ColumnIndex i = index.frontCasted(); switch (i) { + case IndexIdentifier: + setIdentifier(variant.value()); + break; case IndexPosition: setPosition(variant.value()); break; diff --git a/src/blackmisc/weather/gridpoint.h b/src/blackmisc/weather/gridpoint.h index 6d07dc7fa..d5e4809f1 100644 --- a/src/blackmisc/weather/gridpoint.h +++ b/src/blackmisc/weather/gridpoint.h @@ -34,7 +34,8 @@ namespace BlackMisc //! Properties by index enum ColumnIndex { - IndexPosition = BlackMisc::CPropertyIndex::GlobalIndexCGridPoint, + IndexIdentifier = BlackMisc::CPropertyIndex::GlobalIndexCGridPoint, + IndexPosition, IndexCloudLayers, IndexTemperatureLayers, IndexWindLayers @@ -44,12 +45,23 @@ namespace BlackMisc CGridPoint() = default; //! Constructor - CGridPoint(const Geo::CCoordinateGeodetic &position, + CGridPoint(const QString &identifier, + const Geo::CCoordinateGeodetic &position); + + //! Constructor + CGridPoint(const QString &identifier, + const Geo::CCoordinateGeodetic &position, const CCloudLayerList &cloudLayers, const CTemperatureLayerList &temperatureLayers, const CVisibilityLayerList &visibilityLayers, const CWindLayerList &windLayers); + //! Set identifier + void setIdentifier(const QString &identifier) { m_identifier = identifier; } + + //! Get identifier + QString getIdentifier() const { return m_identifier; } + //! Set position void setPosition(const BlackMisc::Geo::CCoordinateGeodetic &position) { m_position = position; } @@ -93,6 +105,8 @@ namespace BlackMisc QString convertToQString(bool i18n = false) const; private: + // Identifier is intentionally string based. MSFS uses ICAO but others don't. + QString m_identifier; BlackMisc::Geo::CCoordinateGeodetic m_position; CCloudLayerList m_cloudLayers; CTemperatureLayerList m_temperatureLayers; @@ -101,6 +115,7 @@ namespace BlackMisc BLACK_METACLASS( CGridPoint, + BLACK_METAMEMBER(identifier), BLACK_METAMEMBER(position), BLACK_METAMEMBER(cloudLayers), BLACK_METAMEMBER(temperatureLayers), diff --git a/src/blackmisc/weather/weathergrid.cpp b/src/blackmisc/weather/weathergrid.cpp index 49f45cadb..529376521 100644 --- a/src/blackmisc/weather/weathergrid.cpp +++ b/src/blackmisc/weather/weathergrid.cpp @@ -47,6 +47,7 @@ namespace BlackMisc static const CGridPoint gridPointGLOB = { + "GLOB", {}, CCloudLayerList { cloudLayer }, CTemperatureLayerList { temperatureLayer }, @@ -97,6 +98,7 @@ namespace BlackMisc static const CGridPoint gridPointGLOB { + "GLOB", {}, CCloudLayerList { cloudLayer1, cloudLayer2 }, CTemperatureLayerList { temperatureLayer },