/* 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/variant.h" #include using namespace BlackMisc::Aviation; using namespace BlackMisc::Geo; using namespace BlackMisc::PhysicalQuantities; namespace BlackMisc { namespace Weather { 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, const CPressure &surfacePressure) : m_identifier(identifier), m_position(position), m_cloudLayers(cloudLayers), m_temperatureLayers(temperatureLayers), m_visibilityLayers(visibilityLayers), m_windLayers(windLayers), m_surfacePressure(surfacePressure) { } void CGridPoint::copyWeatherDataFrom(const CGridPoint &other) { setCloudLayers(other.getCloudLayers()); setTemperatureLayers(other.getTemperatureLayers()); setVisibilityLayers(other.getVisibilityLayers()); setWindLayers(other.getWindLayers()); setSurfacePressure(other.getSurfacePressure()); } CVariant CGridPoint::propertyByIndex(const BlackMisc::CPropertyIndex &index) const { if (index.isMyself()) { return CVariant::from(*this); } ColumnIndex i = index.frontCasted(); switch (i) { case IndexIdentifier: return CVariant::fromValue(m_identifier); case IndexPosition: return CVariant::fromValue(m_position); case IndexCloudLayers: return CVariant::fromValue(m_cloudLayers); case IndexTemperatureLayers: return CVariant::fromValue(m_temperatureLayers); case IndexWindLayers: return CVariant::fromValue(m_windLayers); case IndexSurfacePressure: return CVariant::fromValue(m_surfacePressure); default: return CValueObject::propertyByIndex(index); } } void CGridPoint::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant) { if (index.isMyself()) { (*this) = variant.to(); return; } ColumnIndex i = index.frontCasted(); switch (i) { case IndexIdentifier: setIdentifier(variant.value()); break; case IndexPosition: setPosition(variant.value()); break; case IndexCloudLayers: setCloudLayers(variant.value()); break; case IndexTemperatureLayers: setTemperatureLayers(variant.value()); break; case IndexWindLayers: setWindLayers(variant.value()); break; case IndexSurfacePressure: setSurfacePressure(variant.value()); break; default: CValueObject::setPropertyByIndex(index, variant); break; } } QString CGridPoint::convertToQString(bool /** i18n **/) const { qFatal("Not yet implemented!"); return {}; } } // namespace } // namespace