diff --git a/samples/weatherdata/weatherdataprinter.cpp b/samples/weatherdata/weatherdataprinter.cpp index 46ee24e75..9d995610f 100644 --- a/samples/weatherdata/weatherdataprinter.cpp +++ b/samples/weatherdata/weatherdataprinter.cpp @@ -54,49 +54,10 @@ void CWeatherDataPrinter::fetchAndPrintWeatherData(const CCoordinateGeodetic &po m_weatherManger.requestWeatherGrid(weatherGrid, { this, &CWeatherDataPrinter::printWeatherData }); } -void CWeatherDataPrinter::printWeatherData(const BlackMisc::Weather::CWeatherGrid &weatherGrid) +void CWeatherDataPrinter::printWeatherData(const CWeatherGrid &weatherGrid) { QTextStream qtout(stdout); qtout << "... finished." << endl; - for (const CGridPoint &gridPoint : weatherGrid) - { - qtout << "Latitude:" << gridPoint.getPosition().latitude().toQString() << endl; - qtout << "Longitude:" << gridPoint.getPosition().longitude().toQString() << endl; - qtout << " MSL Pressure: " << gridPoint.getPressureAtMsl().toQString() << endl; - - CTemperatureLayerList temperatureLayers = gridPoint.getTemperatureLayers(); - temperatureLayers.sort([](const CTemperatureLayer & a, const CTemperatureLayer & b) { return a.getLevel() < b.getLevel(); }); - qtout << " Temperature Layers: " << endl; - for (const auto &temperatureLayer : as_const(temperatureLayers)) - { - qtout << " Level: " << temperatureLayer.getLevel().toQString() << endl; - qtout << " Temperature: " << temperatureLayer.getTemperature().toQString() << endl; - qtout << " Relative Humidity: " << temperatureLayer.getRelativeHumidity() << " %" << endl; - } - qtout << endl; - - CWindLayerList windLayers = gridPoint.getWindLayers(); - windLayers.sort([](const CWindLayer & a, const CWindLayer & b) { return a.getLevel() < b.getLevel(); }); - qtout << " Wind Layers: " << endl; - for (const auto &windLayer : as_const(windLayers)) - { - qtout << " Level: " << windLayer.getLevel().toQString() << endl; - qtout << " Wind: " << windLayer.getDirection().toQString() << " at " << windLayer.getSpeed().toQString() << endl; - } - qtout << endl; - - qtout << " Cloud Layers: " << endl; - CCloudLayerList cloudLayers = gridPoint.getCloudLayers(); - cloudLayers.sort([](const CCloudLayer & a, const CCloudLayer & b) { return a.getBase() < b.getBase(); }); - for (int i = 0; i < cloudLayers.size(); i++) - { - const CCloudLayer &cloudLayer = cloudLayers[i]; - qtout << " Top: " << cloudLayer.getTop().toQString() << endl; - qtout << " Coverage: " << cloudLayer.getCoveragePercent() << " %" << endl; - qtout << " Precipitation type: " << cloudLayer.getPrecipitation() << endl; - qtout << " Precipitation rate: " << cloudLayer.getPrecipitationRate() << endl; - qtout << " Base: " << cloudLayer.getBase().toQString() << endl; - } - qtout << endl << endl; - } + qtout << weatherGrid.getDescription(); + qtout << endl; } diff --git a/src/blackmisc/weather/weathergrid.cpp b/src/blackmisc/weather/weathergrid.cpp index a91d5e3b5..4fe5916be 100644 --- a/src/blackmisc/weather/weathergrid.cpp +++ b/src/blackmisc/weather/weathergrid.cpp @@ -61,8 +61,52 @@ namespace BlackMisc QString CWeatherGrid::getDescription(const QString sep) const { - Q_UNUSED(sep) - return QStringLiteral("Weather grid with %1 entries").arg(this->size()); + QString s; + QTextStream qtout(&s); + for (const CGridPoint &gridPoint : *this) + { + qtout << "Latitude: " << gridPoint.getPosition().latitude().toQString() << sep; + qtout << "Longitude: " << gridPoint.getPosition().longitude().toQString() << sep; + qtout << " MSL Pressure: " << gridPoint.getPressureAtMsl().toQString() << sep; + + CTemperatureLayerList temperatureLayers = gridPoint.getTemperatureLayers(); + temperatureLayers.sort([](const CTemperatureLayer & a, const CTemperatureLayer & b) { return a.getLevel() < b.getLevel(); }); + qtout << " Temperature Layers: " << sep; + for (const auto &temperatureLayer : as_const(temperatureLayers)) + { + qtout << " Level: " << temperatureLayer.getLevel().toQString() << sep; + qtout << " Temperature: " << temperatureLayer.getTemperature().toQString() << sep; + qtout << " Relative Humidity: " << temperatureLayer.getRelativeHumidity() << " %" << sep; + } + qtout << sep; + + CWindLayerList windLayers = gridPoint.getWindLayers(); + windLayers.sort([](const CWindLayer & a, const CWindLayer & b) { return a.getLevel() < b.getLevel(); }); + qtout << " Wind Layers: " << sep; + for (const auto &windLayer : as_const(windLayers)) + { + qtout << " Level: " << windLayer.getLevel().toQString() << sep; + qtout << " Wind: " << windLayer.getDirection().toQString() << " at " << windLayer.getSpeed().toQString() << sep; + } + qtout << sep; + + qtout << " Cloud Layers: " << sep; + CCloudLayerList cloudLayers = gridPoint.getCloudLayers(); + cloudLayers.sort([](const CCloudLayer & a, const CCloudLayer & b) { return a.getBase() < b.getBase(); }); + for (int i = 0; i < cloudLayers.size(); i++) + { + const CCloudLayer &cloudLayer = cloudLayers[i]; + qtout << " Top: " << cloudLayer.getTop().toQString() << sep; + qtout << " Coverage: " << cloudLayer.getCoveragePercent() << " %" << sep; + qtout << " Precipitation type: " << cloudLayer.getPrecipitation() << sep; + qtout << " Precipitation rate: " << cloudLayer.getPrecipitationRate() << sep; + qtout << " Base: " << cloudLayer.getBase().toQString() << sep; + } + qtout << sep << sep; + } + + qtout.flush(); + return s; } const QVector &CWeatherGrid::getAllScenarios() diff --git a/src/plugins/simulator/emulated/simulatoremulated.cpp b/src/plugins/simulator/emulated/simulatoremulated.cpp index a86be3249..7ef0bf0a2 100644 --- a/src/plugins/simulator/emulated/simulatoremulated.cpp +++ b/src/plugins/simulator/emulated/simulatoremulated.cpp @@ -125,8 +125,6 @@ namespace BlackSimPlugin const QString wg = QStringLiteral("Weather grid with %1 entries").arg(weatherGrid.size()); if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, wg); m_monitorWidget->receivedWeather(weatherGrid); - - // remark see CWeatherDataPrinter } bool CSimulatorEmulated::changeRemoteAircraftModel(const CSimulatedAircraft &aircraft)