mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
Ref T786, fixed weather sample
* RR found that no alt value means a huge number of grid points is parsed * see https://discordapp.com/channels/539048679160676382/539925070550794240/701762348506939693
This commit is contained in:
committed by
Mat Sutcliffe
parent
0a2b25e409
commit
5ef25d4a41
@@ -33,7 +33,6 @@ int main(int argc, char *argv[])
|
|||||||
BlackMisc::registerMetadata();
|
BlackMisc::registerMetadata();
|
||||||
CLogHandler::instance()->install(true);
|
CLogHandler::instance()->install(true);
|
||||||
CLogHandler::instance()->enableConsoleOutput(false); // default disable
|
CLogHandler::instance()->enableConsoleOutput(false); // default disable
|
||||||
BlackMisc::registerMetadata();
|
|
||||||
|
|
||||||
CLineReader lineReader(&a);
|
CLineReader lineReader(&a);
|
||||||
CWeatherDataPrinter printer(&a);
|
CWeatherDataPrinter printer(&a);
|
||||||
|
|||||||
@@ -26,16 +26,17 @@
|
|||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
|
|
||||||
void CLineReader::run()
|
void CLineReader::run()
|
||||||
{
|
{
|
||||||
QFile file;
|
QFile file;
|
||||||
file.open(stdin, QIODevice::ReadOnly | QIODevice::Text);
|
file.open(stdin, QIODevice::ReadOnly | QIODevice::Text);
|
||||||
QRegularExpression re("^(-?\\d+).([0,5])\\s(-?\\d+).([0,5])$");
|
|
||||||
forever
|
forever
|
||||||
{
|
{
|
||||||
QString line = file.readLine().trimmed();
|
QString line = file.readLine().simplified();
|
||||||
|
|
||||||
if (line == "x")
|
if (line == "x")
|
||||||
{
|
{
|
||||||
@@ -43,19 +44,14 @@ void CLineReader::run()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRegularExpressionMatch match = re.match(line);
|
const QStringList parts = line.split(' ');
|
||||||
if (match.hasMatch())
|
if (parts.size() == 2)
|
||||||
{
|
{
|
||||||
double latitudeValue = match.captured(1).toDouble();
|
const CLatitude latitude(CAngle::parsedFromString(parts.front(), CPqString::SeparatorBestGuess, CAngleUnit::deg()));
|
||||||
if (latitudeValue > 0) { latitudeValue += match.captured(2).toDouble() / 10; }
|
const CLongitude longitude(CAngle::parsedFromString(parts.back(), CPqString::SeparatorBestGuess, CAngleUnit::deg()));
|
||||||
else { { latitudeValue -= match.captured(2).toDouble() / 10; } }
|
const CAltitude alt(600, CLengthUnit::m());
|
||||||
double longitudeValue = match.captured(3).toDouble();
|
|
||||||
if (longitudeValue > 0) { longitudeValue += match.captured(4).toDouble() / 10; }
|
const CCoordinateGeodetic position { latitude, longitude, alt};
|
||||||
else { longitudeValue -= match.captured(4).toDouble() / 10; }
|
|
||||||
longitudeValue += match.captured(4).toDouble() / 10;
|
|
||||||
const CLatitude latitude(latitudeValue, CAngleUnit::deg());
|
|
||||||
const CLongitude longitude(longitudeValue, CAngleUnit::deg());
|
|
||||||
const CCoordinateGeodetic position { latitude, longitude, {0} };
|
|
||||||
emit weatherDataRequest(position);
|
emit weatherDataRequest(position);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ CWeatherDataPrinter::CWeatherDataPrinter(QObject *parent) : QObject(parent)
|
|||||||
void CWeatherDataPrinter::fetchAndPrintWeatherData(const CCoordinateGeodetic &position)
|
void CWeatherDataPrinter::fetchAndPrintWeatherData(const CCoordinateGeodetic &position)
|
||||||
{
|
{
|
||||||
QTextStream qtout(stdout);
|
QTextStream qtout(stdout);
|
||||||
|
qtout << "Position:" << position.toQString(true) << endl;
|
||||||
qtout << "Fetching weather data. This may take a while..." << endl;
|
qtout << "Fetching weather data. This may take a while..." << endl;
|
||||||
|
|
||||||
CWeatherGrid weatherGrid { { "", position } };
|
CWeatherGrid weatherGrid { { "", position } };
|
||||||
|
|||||||
Reference in New Issue
Block a user