From d50811c941858de87c7b4d38e26f9271346770b4 Mon Sep 17 00:00:00 2001 From: Roland Rossgotterer Date: Mon, 11 Feb 2019 14:25:59 +0100 Subject: [PATCH] Fix sampleweatherdata to accept negative Lat/Lon values --- samples/weatherdata/reader.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/samples/weatherdata/reader.cpp b/samples/weatherdata/reader.cpp index 250628ee1..1105a754a 100644 --- a/samples/weatherdata/reader.cpp +++ b/samples/weatherdata/reader.cpp @@ -33,7 +33,7 @@ void CLineReader::run() { QFile file; file.open(stdin, QIODevice::ReadOnly | QIODevice::Text); - QRegularExpression re("^(\\d+).([0,5])\\s(\\d+).([0,5])$"); + QRegularExpression re("^(-?\\d+).([0,5])\\s(-?\\d+).([0,5])$"); forever { QString line = file.readLine().trimmed(); @@ -48,8 +48,11 @@ void CLineReader::run() if (match.hasMatch()) { double latitudeValue = match.captured(1).toDouble(); - latitudeValue += match.captured(2).toDouble() / 10; + 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());