mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +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();
|
||||
CLogHandler::instance()->install(true);
|
||||
CLogHandler::instance()->enableConsoleOutput(false); // default disable
|
||||
BlackMisc::registerMetadata();
|
||||
|
||||
CLineReader lineReader(&a);
|
||||
CWeatherDataPrinter printer(&a);
|
||||
|
||||
@@ -26,16 +26,17 @@
|
||||
#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);
|
||||
QRegularExpression re("^(-?\\d+).([0,5])\\s(-?\\d+).([0,5])$");
|
||||
|
||||
forever
|
||||
{
|
||||
QString line = file.readLine().trimmed();
|
||||
QString line = file.readLine().simplified();
|
||||
|
||||
if (line == "x")
|
||||
{
|
||||
@@ -43,19 +44,14 @@ void CLineReader::run()
|
||||
continue;
|
||||
}
|
||||
|
||||
QRegularExpressionMatch match = re.match(line);
|
||||
if (match.hasMatch())
|
||||
const QStringList parts = line.split(' ');
|
||||
if (parts.size() == 2)
|
||||
{
|
||||
double latitudeValue = match.captured(1).toDouble();
|
||||
if (latitudeValue > 0) { latitudeValue += match.captured(2).toDouble() / 10; }
|
||||
else { { latitudeValue -= match.captured(2).toDouble() / 10; } }
|
||||
double longitudeValue = match.captured(3).toDouble();
|
||||
if (longitudeValue > 0) { longitudeValue += match.captured(4).toDouble() / 10; }
|
||||
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} };
|
||||
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
|
||||
|
||||
@@ -48,6 +48,7 @@ CWeatherDataPrinter::CWeatherDataPrinter(QObject *parent) : QObject(parent)
|
||||
void CWeatherDataPrinter::fetchAndPrintWeatherData(const CCoordinateGeodetic &position)
|
||||
{
|
||||
QTextStream qtout(stdout);
|
||||
qtout << "Position:" << position.toQString(true) << endl;
|
||||
qtout << "Fetching weather data. This may take a while..." << endl;
|
||||
|
||||
CWeatherGrid weatherGrid { { "", position } };
|
||||
|
||||
Reference in New Issue
Block a user