mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
refactor: Remove weather support
This commit is contained in:
@@ -8,4 +8,3 @@ add_subdirectory(blackmiscquantities)
|
||||
add_subdirectory(blackmiscsim)
|
||||
add_subdirectory(fsd)
|
||||
add_subdirectory(hotkey)
|
||||
add_subdirectory(weatherdata)
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
# SPDX-FileCopyrightText: Copyright (C) swift Project Community / Contributors
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
add_executable(samples_weatherdata
|
||||
main.cpp
|
||||
reader.cpp
|
||||
reader.h
|
||||
sampleweatherdata.h
|
||||
weatherdataprinter.cpp
|
||||
weatherdataprinter.h
|
||||
)
|
||||
target_link_libraries(samples_weatherdata core misc Qt::Core)
|
||||
@@ -1,45 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
//! \file
|
||||
//! \ingroup sampleweatherdata
|
||||
|
||||
#include "blackcore/application.h"
|
||||
#include "blackmisc/directoryutils.h"
|
||||
#include "blackmisc/loghandler.h"
|
||||
#include "blackmisc/registermetadata.h"
|
||||
#include "reader.h"
|
||||
#include "weatherdataprinter.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <QCoreApplication>
|
||||
#include <QObject>
|
||||
#include <QTextStream>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackCore;
|
||||
|
||||
//! main
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication qa(argc, argv);
|
||||
CApplication a(CApplicationInfo::Sample);
|
||||
BlackMisc::registerMetadata();
|
||||
CLogHandler::instance()->install(true);
|
||||
CLogHandler::instance()->enableConsoleOutput(false); // default disable
|
||||
|
||||
CLineReader lineReader(&a);
|
||||
CWeatherDataPrinter printer(&a);
|
||||
QObject::connect(&lineReader, &CLineReader::weatherDataRequest, &printer, &CWeatherDataPrinter::fetchAndPrintWeatherData);
|
||||
QObject::connect(&lineReader, &CLineReader::wantsToQuit, &lineReader, &CLineReader::terminate);
|
||||
QObject::connect(&lineReader, &CLineReader::finished, &a, &QCoreApplication::quit);
|
||||
|
||||
QTextStream qtout(stdout);
|
||||
qtout << "Usage: <lat> <lon>" << Qt::endl;
|
||||
qtout << "Example: 48.5 11.5" << Qt::endl;
|
||||
qtout << "Type x to quit" << Qt::endl;
|
||||
|
||||
lineReader.start();
|
||||
return a.exec();
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
//! \file
|
||||
//! \ingroup sampleweatherdata
|
||||
|
||||
#include "reader.h"
|
||||
#include "blackmisc/geo/latitude.h"
|
||||
#include "blackmisc/geo/longitude.h"
|
||||
#include "blackmisc/pq/units.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <QByteArray>
|
||||
#include <QFile>
|
||||
#include <QFlags>
|
||||
#include <QIODevice>
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionMatch>
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
#include <QtGlobal>
|
||||
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
void CLineReader::run()
|
||||
{
|
||||
QFile file;
|
||||
file.open(stdin, QIODevice::ReadOnly | QIODevice::Text);
|
||||
|
||||
forever
|
||||
{
|
||||
QString line = file.readLine().simplified();
|
||||
|
||||
if (line == "x")
|
||||
{
|
||||
emit wantsToQuit();
|
||||
continue;
|
||||
}
|
||||
|
||||
const QStringList parts = line.split(' ');
|
||||
if (parts.size() == 2)
|
||||
{
|
||||
const CLatitude latitude(CAngle::parsedFromString(parts.front(), CPqString::SeparatorBestGuess, CAngleUnit::deg()));
|
||||
const CLongitude longitude(CAngle::parsedFromString(parts.back(), CPqString::SeparatorBestGuess, CAngleUnit::deg()));
|
||||
const CAltitude alt(600, CLengthUnit::m());
|
||||
|
||||
const CCoordinateGeodetic position { latitude, longitude, alt };
|
||||
emit weatherDataRequest(position);
|
||||
}
|
||||
else
|
||||
{
|
||||
QTextStream qtout(stdout);
|
||||
qtout << "Invalid command." << Qt::endl;
|
||||
qtout << "Usage: <lat> <lon>" << Qt::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
#ifndef BLACKSAMPLE_WEATHERDATA_LINEREADER_H
|
||||
#define BLACKSAMPLE_WEATHERDATA_LINEREADER_H
|
||||
|
||||
//! \file
|
||||
//! \ingroup sampleweatherdata
|
||||
|
||||
#include "blackmisc/geo/coordinategeodetic.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
|
||||
/*!
|
||||
* Class reading line input and triggering commands
|
||||
*/
|
||||
class CLineReader : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CLineReader(QObject *parent = nullptr) : QThread(parent) {}
|
||||
|
||||
protected:
|
||||
//! \copydoc QThread::run
|
||||
virtual void run() override;
|
||||
|
||||
signals:
|
||||
//! User is asking for weather data
|
||||
void weatherDataRequest(const BlackMisc::Geo::CCoordinateGeodetic &position);
|
||||
|
||||
//! User is asking to quit
|
||||
void wantsToQuit();
|
||||
};
|
||||
|
||||
#endif // guard
|
||||
@@ -1,23 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2014 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
#ifndef BLACKSAMPLE_WEATHERDATA_H
|
||||
#define BLACKSAMPLE_WEATHERDATA_H
|
||||
|
||||
//! \file
|
||||
//! \ingroup sampleweatherdata
|
||||
|
||||
// just a dummy header, documentation will go here
|
||||
|
||||
/*!
|
||||
* \defgroup sampleweatherdata Sample Weather Data
|
||||
* \ingroup samples
|
||||
* \brief Sample demonstrating how to download and use weather data
|
||||
* through the IWeatherData plugins.
|
||||
*
|
||||
* After startup it will accept input by latitude and longitude
|
||||
* and print the current weather status received from all installed
|
||||
* and loaded weather plugins.
|
||||
*/
|
||||
|
||||
#endif
|
||||
@@ -1,58 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
//! \file
|
||||
//! \ingroup sampleweatherdata
|
||||
|
||||
#include "weatherdataprinter.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include <QTextStream>
|
||||
|
||||
#include "weatherdataprinter.h"
|
||||
#include "blackmisc/aviation/altitude.h"
|
||||
#include "blackmisc/geo/latitude.h"
|
||||
#include "blackmisc/geo/longitude.h"
|
||||
#include "blackmisc/pq/angle.h"
|
||||
#include "blackmisc/pq/physicalquantity.h"
|
||||
#include "blackmisc/pq/pressure.h"
|
||||
#include "blackmisc/pq/speed.h"
|
||||
#include "blackmisc/pq/temperature.h"
|
||||
#include "blackmisc/range.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include "blackmisc/weather/cloudlayer.h"
|
||||
#include "blackmisc/weather/cloudlayerlist.h"
|
||||
#include "blackmisc/weather/gridpoint.h"
|
||||
#include "blackmisc/weather/temperaturelayer.h"
|
||||
#include "blackmisc/weather/temperaturelayerlist.h"
|
||||
#include "blackmisc/weather/windlayer.h"
|
||||
#include "blackmisc/weather/windlayerlist.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <QTextStream>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Weather;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackCore;
|
||||
|
||||
CWeatherDataPrinter::CWeatherDataPrinter(QObject *parent) : QObject(parent)
|
||||
{}
|
||||
|
||||
void CWeatherDataPrinter::fetchAndPrintWeatherData(const CCoordinateGeodetic &position)
|
||||
{
|
||||
QTextStream qtout(stdout);
|
||||
qtout << "Position:" << position.toQString(true) << Qt::endl;
|
||||
qtout << "Fetching weather data. This may take a while..." << Qt::endl;
|
||||
|
||||
const CWeatherGrid weatherGrid { { "", position } };
|
||||
m_weatherManger.requestWeatherGrid(weatherGrid, { this, &CWeatherDataPrinter::printWeatherData });
|
||||
}
|
||||
|
||||
void CWeatherDataPrinter::printWeatherData(const CWeatherGrid &weatherGrid)
|
||||
{
|
||||
QTextStream qtout(stdout);
|
||||
qtout << "... finished." << Qt::endl;
|
||||
qtout << weatherGrid.getDescription();
|
||||
qtout << Qt::endl;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
#ifndef BLACKSAMPLE_WEATERDATA_WEATHERDATAPRINTER_H
|
||||
#define BLACKSAMPLE_WEATERDATA_WEATHERDATAPRINTER_H
|
||||
|
||||
//! \file
|
||||
//! \ingroup sampleweatherdata
|
||||
|
||||
#include "blackcore/weathermanager.h"
|
||||
#include "blackmisc/geo/coordinategeodetic.h"
|
||||
#include "blackmisc/weather/weathergrid.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
/*!
|
||||
* CWeatherDataPrinter fetches and prints weather data
|
||||
*/
|
||||
class CWeatherDataPrinter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CWeatherDataPrinter(QObject *parent = nullptr);
|
||||
|
||||
//! Fetch new weather data for given position and print it once received
|
||||
void fetchAndPrintWeatherData(const BlackMisc::Geo::CCoordinateGeodetic &position);
|
||||
|
||||
private:
|
||||
//! Print weather data to stdout
|
||||
void printWeatherData(const BlackMisc::Weather::CWeatherGrid &weatherGrid);
|
||||
|
||||
BlackCore::CWeatherManager m_weatherManger { this };
|
||||
};
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user