Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qlocationutils.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 Jolla Ltd.
2// Copyright (C) 2016 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4// Qt-Security score:critical reason:data-parser
5
9
10#include <QTime>
11#include <QList>
12#include <QByteArray>
13#include <QDateTime>
14#include <QDebug>
15#include <QTimeZone>
16
17#include <math.h>
18
19QT_BEGIN_NAMESPACE
20
21// converts e.g. 15306.0235 from NMEA sentence to 153.100392
22static double qlocationutils_nmeaDegreesToDecimal(double nmeaDegrees)
23{
24 double deg;
25 double min = 100.0 * modf(nmeaDegrees / 100.0, &deg);
26 return deg + (min / 60.0);
27}
28
29static void qlocationutils_readGga(QByteArrayView bv, QGeoPositionInfo *info, double uere,
30 bool *hasFix,
31 QGeoCoordinate::AltitudeType preferredAltitudeType)
32{
33 const QList<QByteArray> parts = QByteArray::fromRawData(bv.data(), bv.size()).split(',');
34 QGeoCoordinate coord;
35
36 if (hasFix && parts.size() > 6 && !parts[6].isEmpty())
37 *hasFix = parts[6].toInt() > 0;
38
39 if (parts.size() > 1 && !parts[1].isEmpty()) {
40 QTime time;
41 if (QLocationUtils::getNmeaTime(parts[1], &time))
42 info->setTimestamp(QDateTime(QDate(), time, QTimeZone::UTC));
43 }
44
45 if (parts.size() > 5 && parts[3].size() == 1 && parts[5].size() == 1) {
46 double lat;
47 double lng;
48 if (QLocationUtils::getNmeaLatLong(parts[2], parts[3][0], parts[4], parts[5][0], &lat, &lng)) {
49 coord.setLatitude(lat);
50 coord.setLongitude(lng);
51 }
52 }
53
54 if (parts.size() > 8 && !parts[8].isEmpty()) {
55 bool hasHdop = false;
56 double hdop = parts[8].toDouble(&hasHdop);
57 if (hasHdop)
58 info->setAttribute(QGeoPositionInfo::HorizontalAccuracy, 2 * hdop * uere);
59 }
60
61 if (parts.size() > 9 && !parts[9].isEmpty()) {
62 bool hasAlt = false;
63 double alt = parts[9].toDouble(&hasAlt);
64 if (hasAlt) {
65 // Field 9 contains the altitude above MSL (geoid). Field 11
66 // contains the geoid separation, which is the height of the geoid
67 // above the WGS84 ellipsoid, so the ellipsoidal height is their sum.
68 auto altType = QGeoCoordinate::AltitudeType::MSL;
69 if (preferredAltitudeType == QGeoCoordinate::AltitudeType::WGS84
70 && parts.size() > 11 && !parts[11].isEmpty()) {
71 bool hasSeparation = false;
72 const double separation = parts[11].toDouble(&hasSeparation);
73 if (hasSeparation) {
74 alt += separation;
75 altType = QGeoCoordinate::AltitudeType::WGS84;
76 }
77 }
78 coord.setAltitude(alt);
79 // Report type only if preferred is specified
80 if (preferredAltitudeType != QGeoCoordinate::AltitudeType::Unknown)
81 coord.setAltitudeType(altType);
82 }
83 }
84
85 if (coord.type() != QGeoCoordinate::InvalidCoordinate)
86 info->setCoordinate(coord);
87}
88
89static void qlocationutils_readGsa(QByteArrayView bv, QGeoPositionInfo *info, double uere,
90 bool *hasFix)
91{
92 const QList<QByteArray> parts = QByteArray::fromRawData(bv.data(), bv.size()).split(',');
93
94 // The GSA sentence is different from GGA:
95 // 1 - no fix;
96 // 2 - 2D fix;
97 // 3 - 3D fix.
98 if (hasFix && parts.size() > 2 && !parts[2].isEmpty())
99 *hasFix = parts[2].toInt() > 1;
100
101 if (parts.size() > 16 && !parts[16].isEmpty()) {
102 bool hasHdop = false;
103 double hdop = parts[16].toDouble(&hasHdop);
104 if (hasHdop)
105 info->setAttribute(QGeoPositionInfo::HorizontalAccuracy, 2 * hdop * uere);
106 }
107
108 if (parts.size() > 17 && !parts[17].isEmpty()) {
109 bool hasVdop = false;
110 double vdop = parts[17].toDouble(&hasVdop);
111 if (hasVdop)
112 info->setAttribute(QGeoPositionInfo::VerticalAccuracy, 2 * vdop * uere);
113 }
114}
115
116static void qlocationutils_readGsa(QByteArrayView bv, QList<int> &pnrsInUse)
117{
118 const QList<QByteArray> parts = QByteArray::fromRawData(bv.data(), bv.size()).split(',');
119 pnrsInUse.clear();
120 if (parts.size() <= 2)
121 return;
122 bool ok;
123 for (qsizetype i = 3; i < qMin(15, parts.size()); ++i) {
124 const QByteArray &pnrString = parts.at(i);
125 if (pnrString.isEmpty())
126 continue;
127 int pnr = pnrString.toInt(&ok);
128 if (ok)
129 pnrsInUse.append(pnr);
130 }
131}
132
133static void qlocationutils_readGll(QByteArrayView bv, QGeoPositionInfo *info, bool *hasFix)
134{
135 const QList<QByteArray> parts = QByteArray::fromRawData(bv.data(), bv.size()).split(',');
136 QGeoCoordinate coord;
137
138 if (hasFix && parts.size() > 6 && !parts[6].isEmpty())
139 *hasFix = (parts[6][0] == 'A');
140
141 if (parts.size() > 5 && !parts[5].isEmpty()) {
142 QTime time;
143 if (QLocationUtils::getNmeaTime(parts[5], &time))
144 info->setTimestamp(QDateTime(QDate(), time, QTimeZone::UTC));
145 }
146
147 if (parts.size() > 4 && parts[2].size() == 1 && parts[4].size() == 1) {
148 double lat;
149 double lng;
150 if (QLocationUtils::getNmeaLatLong(parts[1], parts[2][0], parts[3], parts[4][0], &lat, &lng)) {
151 coord.setLatitude(lat);
152 coord.setLongitude(lng);
153 }
154 }
155
156 if (coord.type() != QGeoCoordinate::InvalidCoordinate)
157 info->setCoordinate(coord);
158}
159
160static void qlocationutils_readRmc(QByteArrayView bv, QGeoPositionInfo *info, bool *hasFix)
161{
162 const QList<QByteArray> parts = QByteArray::fromRawData(bv.data(), bv.size()).split(',');
163 QGeoCoordinate coord;
164 QDate date;
165 QTime time;
166
167 if (hasFix && parts.size() > 2 && !parts[2].isEmpty())
168 *hasFix = (parts[2][0] == 'A');
169
170 if (parts.size() > 9 && parts[9].size() == 6) {
171 date = QDate::fromString(QString::fromLatin1(parts[9]), QStringLiteral("ddMMyy"));
172 if (date.isValid())
173 date = date.addYears(100); // otherwise starts from 1900
174 }
175
176 if (parts.size() > 1 && !parts[1].isEmpty())
177 QLocationUtils::getNmeaTime(parts[1], &time);
178
179 if (parts.size() > 6 && parts[4].size() == 1 && parts[6].size() == 1) {
180 double lat;
181 double lng;
182 if (QLocationUtils::getNmeaLatLong(parts[3], parts[4][0], parts[5], parts[6][0], &lat, &lng)) {
183 coord.setLatitude(lat);
184 coord.setLongitude(lng);
185 }
186 }
187
188 bool parsed = false;
189 double value = 0.0;
190 if (parts.size() > 7 && !parts[7].isEmpty()) {
191 value = parts[7].toDouble(&parsed);
192 if (parsed)
193 info->setAttribute(QGeoPositionInfo::GroundSpeed, qreal(value * 1.852 / 3.6)); // knots -> m/s
194 }
195 if (parts.size() > 8 && !parts[8].isEmpty()) {
196 value = parts[8].toDouble(&parsed);
197 if (parsed)
198 info->setAttribute(QGeoPositionInfo::Direction, qreal(value));
199 }
200 if (parts.size() > 11 && parts[11].size() == 1
201 && (parts[11][0] == 'E' || parts[11][0] == 'W')) {
202 value = parts[10].toDouble(&parsed);
203 if (parsed) {
204 if (parts[11][0] == 'W')
205 value *= -1;
206 info->setAttribute(QGeoPositionInfo::MagneticVariation, qreal(value));
207 }
208 }
209
210 if (coord.type() != QGeoCoordinate::InvalidCoordinate)
211 info->setCoordinate(coord);
212
213 info->setTimestamp(QDateTime(date, time, QTimeZone::UTC));
214}
215
216static void qlocationutils_readVtg(QByteArrayView bv, QGeoPositionInfo *info, bool *hasFix)
217{
218 if (hasFix)
219 *hasFix = false;
220
221 const QList<QByteArray> parts = QByteArray::fromRawData(bv.data(), bv.size()).split(',');
222
223 bool parsed = false;
224 double value = 0.0;
225 if (parts.size() > 1 && !parts[1].isEmpty()) {
226 value = parts[1].toDouble(&parsed);
227 if (parsed)
228 info->setAttribute(QGeoPositionInfo::Direction, qreal(value));
229 }
230 if (parts.size() > 7 && !parts[7].isEmpty()) {
231 value = parts[7].toDouble(&parsed);
232 if (parsed)
233 info->setAttribute(QGeoPositionInfo::GroundSpeed, qreal(value / 3.6)); // km/h -> m/s
234 }
235}
236
237static void qlocationutils_readZda(QByteArrayView bv, QGeoPositionInfo *info, bool *hasFix)
238{
239 if (hasFix)
240 *hasFix = false;
241
242 const QList<QByteArray> parts = QByteArray::fromRawData(bv.data(), bv.size()).split(',');
243 QDate date;
244 QTime time;
245
246 if (parts.size() > 1 && !parts[1].isEmpty())
247 QLocationUtils::getNmeaTime(parts[1], &time);
248
249 if (parts.size() > 4 && !parts[2].isEmpty() && !parts[3].isEmpty()
250 && parts[4].size() == 4) { // must be full 4-digit year
251 int day = parts[2].toInt();
252 int month = parts[3].toInt();
253 int year = parts[4].toInt();
254 if (day > 0 && month > 0 && year > 0)
255 date.setDate(year, month, day);
256 }
257
258 info->setTimestamp(QDateTime(date, time, QTimeZone::UTC));
259}
260
261QLocationUtils::NmeaSentence QLocationUtils::getNmeaSentenceType(QByteArrayView bv)
262{
263 if (bv.size() < 6 || bv[0] != '$' || !hasValidNmeaChecksum(bv))
264 return NmeaSentenceInvalid;
265
266 QByteArrayView key = bv.sliced(3);
267
268 if (key.startsWith("GGA"))
269 return NmeaSentenceGGA;
270
271 if (key.startsWith("GSA"))
272 return NmeaSentenceGSA;
273
274 if (key.startsWith("GSV"))
275 return NmeaSentenceGSV;
276
277 if (key.startsWith("GLL"))
278 return NmeaSentenceGLL;
279
280 if (key.startsWith("RMC"))
281 return NmeaSentenceRMC;
282
283 if (key.startsWith("VTG"))
284 return NmeaSentenceVTG;
285
286 if (key.startsWith("ZDA"))
287 return NmeaSentenceZDA;
288
289 return NmeaSentenceInvalid;
290}
291
292QGeoSatelliteInfo::SatelliteSystem QLocationUtils::getSatelliteSystem(QByteArrayView bv)
293{
294 if (bv.size() < 6 || bv[0] != '$' || !hasValidNmeaChecksum(bv))
295 return QGeoSatelliteInfo::Undefined;
296
297 QByteArrayView key = bv.sliced(1);
298
299 // GPS: GP
300 if (key.startsWith("GP"))
301 return QGeoSatelliteInfo::GPS;
302
303 // GLONASS: GL
304 if (key.startsWith("GL"))
305 return QGeoSatelliteInfo::GLONASS;
306
307 // GALILEO: GA
308 if (key.startsWith("GA"))
309 return QGeoSatelliteInfo::GALILEO;
310
311 // BeiDou: BD or GB
312 if (key.startsWith("BD") || key.startsWith("GB"))
313 return QGeoSatelliteInfo::BEIDOU;
314
315 // QZSS: GQ, PQ, QZ
316 if (key.startsWith("GQ") || key.startsWith("PQ") || key.startsWith("QZ"))
317 return QGeoSatelliteInfo::QZSS;
318
319 // IRNSS: GI
320 if (key.startsWith("GI"))
321 return QGeoSatelliteInfo::IRNSS;
322
323 // SBAS: no talker id, should use satellite id range
324
325 // Multiple: GN
326 if (key.startsWith("GN"))
327 return QGeoSatelliteInfo::Multiple;
328
329 return QGeoSatelliteInfo::Undefined;
330}
331
332QGeoSatelliteInfo::SatelliteSystem QLocationUtils::getSatelliteSystemBySatelliteId(int satId)
333{
334 if (satId >= 1 && satId <= 32)
335 return QGeoSatelliteInfo::GPS;
336
337 if (satId >= 33 && satId <= 64)
338 return QGeoSatelliteInfo::SBAS;
339
340 if (satId >= 65 && satId <= 96) // including future extensions
341 return QGeoSatelliteInfo::GLONASS;
342
343 if (satId >= 193 && satId <= 200) // including future extensions
344 return QGeoSatelliteInfo::QZSS;
345
346 if ((satId >= 201 && satId <= 235) || (satId >= 401 && satId <= 437))
347 return QGeoSatelliteInfo::BEIDOU;
348
349 if (satId >= 301 && satId <= 336)
350 return QGeoSatelliteInfo::GALILEO;
351
352 return QGeoSatelliteInfo::Undefined;
353}
354
355bool QLocationUtils::getPosInfoFromNmea(QByteArrayView bv, QGeoPositionInfo *info, double uere,
356 QGeoCoordinate::AltitudeType preferredAltitudeType,
357 bool *hasFix)
358{
359 if (!info)
360 return false;
361
362 if (hasFix)
363 *hasFix = false;
364
365 NmeaSentence nmeaType = getNmeaSentenceType(bv);
366 if (nmeaType == NmeaSentenceInvalid)
367 return false;
368
369 // Adjust size so that * and following characters are not parsed by the following functions.
370 qsizetype idx = bv.indexOf('*');
371 QByteArrayView key = idx < 0 ? bv : bv.first(idx);
372
373 switch (nmeaType) {
374 case NmeaSentenceGGA:
375 qlocationutils_readGga(key, info, uere, hasFix, preferredAltitudeType);
376 return true;
377 case NmeaSentenceGSA:
378 qlocationutils_readGsa(key, info, uere, hasFix);
379 return true;
380 case NmeaSentenceGLL:
381 qlocationutils_readGll(key, info, hasFix);
382 return true;
383 case NmeaSentenceRMC:
384 qlocationutils_readRmc(key, info, hasFix);
385 return true;
386 case NmeaSentenceVTG:
387 qlocationutils_readVtg(key, info, hasFix);
388 return true;
389 case NmeaSentenceZDA:
390 qlocationutils_readZda(key, info, hasFix);
391 return true;
392 default:
393 return false;
394 }
395}
396
397QNmeaSatelliteInfoSource::SatelliteInfoParseStatus
398QLocationUtils::getSatInfoFromNmea(QByteArrayView bv, QList<QGeoSatelliteInfo> &infos, QGeoSatelliteInfo::SatelliteSystem &system)
399{
400 if (bv.isEmpty())
401 return QNmeaSatelliteInfoSource::NotParsed;
402
403 NmeaSentence nmeaType = getNmeaSentenceType(bv);
404 if (nmeaType != NmeaSentenceGSV)
405 return QNmeaSatelliteInfoSource::NotParsed;
406
407 // Standard forbids using $GN talker id for GSV messages, so the system
408 // type here will be uniquely identified.
409 system = getSatelliteSystem(bv);
410
411 // Adjust size so that * and following characters are not parsed by the
412 // following code.
413 qsizetype idx = bv.indexOf('*');
414
415 const QList<QByteArray> parts = QByteArray::fromRawData(bv.data(),
416 idx < 0 ? bv.size() : idx).split(',');
417
418 if (parts.size() <= 3) {
419 infos.clear();
420 return QNmeaSatelliteInfoSource::FullyParsed; // Malformed sentence.
421 }
422
423 // The hard max limit for the number of sentences in one message is used
424 // to prevent malicious messages. The protocol does not seem to define any
425 // maximum, but this value provides an upper limit that is more than enough
426 // in practice.
427 static constexpr quint32 MaxTotalSentences = 250;
428 bool ok;
429 const quint32 totalSentences = parts.at(1).toUInt(&ok);
430 if (!ok || totalSentences > MaxTotalSentences) {
431 infos.clear();
432 return QNmeaSatelliteInfoSource::FullyParsed; // Malformed sentence.
433 }
434
435 const quint32 sentence = parts.at(2).toUInt(&ok);
436 if (!ok || sentence > totalSentences) {
437 infos.clear();
438 return QNmeaSatelliteInfoSource::FullyParsed; // Malformed sentence.
439 }
440
441 const quint32 totalSats = parts.at(3).toUInt(&ok);
442 if (!ok) {
443 infos.clear();
444 return QNmeaSatelliteInfoSource::FullyParsed; // Malformed sentence.
445 }
446
447 if (sentence == 1)
448 infos.clear();
449 else if (infos.isEmpty()) // sentences out of order or DDoS spotted earlier
450 return QNmeaSatelliteInfoSource::FullyParsed; // Malformed sentence.
451
452 static constexpr qsizetype MaxTotalSatellites = 1000;
453 const auto currentSatsSize = infos.size();
454 if (currentSatsSize > qint64(totalSats) || currentSatsSize > MaxTotalSatellites) {
455 // Maybe DDoS: otherwise, probably something is wrong; reject, either way.
456 infos.clear();
457 return QNmeaSatelliteInfoSource::FullyParsed; // Malformed sentence.
458 }
459
460 const qint64 numSatInSentence = qMin(sentence * 4, totalSats) - (sentence - 1) * 4;
461 if (parts.size() < (4 + numSatInSentence * 4)) {
462 infos.clear();
463 return QNmeaSatelliteInfoSource::FullyParsed; // Malformed sentence.
464 }
465
466 int field = 4;
467 for (qint64 i = 0; i < numSatInSentence; ++i) {
468 QGeoSatelliteInfo info;
469 info.setSatelliteSystem(system);
470 int prn = parts.at(field++).toInt(&ok);
471 // Quote from: https://gpsd.gitlab.io/gpsd/NMEA.html#_satellite_ids
472 // GLONASS satellite numbers come in two flavors. If a sentence has a GL
473 // talker ID, expect the skyviews to be GLONASS-only and in the range
474 // 1-32; you must add 64 to get a globally-unique NMEA ID. If the
475 // sentence has a GN talker ID, the device emits a multi-constellation
476 // skyview with GLONASS IDs already in the 65-96 range.
477 //
478 // However I don't observe such behavior with my device. So implementing
479 // a safe scenario.
480 if (ok && (system == QGeoSatelliteInfo::GLONASS)) {
481 if (prn <= 64)
482 prn += 64;
483 }
484
485 // If the system is unknown, try to determine it based on prn.
486 // Note that the new value can vary among the satellites, so *do not*
487 // update the out-variable 'system'.
488 if (ok && system == QGeoSatelliteInfo::Undefined)
489 info.setSatelliteSystem(getSatelliteSystemBySatelliteId(prn));
490
491 info.setSatelliteIdentifier((ok) ? prn : 0);
492 const int elevation = parts.at(field++).toInt(&ok);
493 info.setAttribute(QGeoSatelliteInfo::Elevation, (ok) ? elevation : 0);
494 const int azimuth = parts.at(field++).toInt(&ok);
495 info.setAttribute(QGeoSatelliteInfo::Azimuth, (ok) ? azimuth : 0);
496 const int snr = parts.at(field++).toInt(&ok);
497 info.setSignalStrength((ok) ? snr : -1);
498 infos.append(info);
499 }
500
501 if (sentence == totalSentences)
502 return QNmeaSatelliteInfoSource::FullyParsed;
503
504 return QNmeaSatelliteInfoSource::PartiallyParsed;
505}
506
507QGeoSatelliteInfo::SatelliteSystem QLocationUtils::getSatInUseFromNmea(QByteArrayView bv,
508 QList<int> &pnrsInUse)
509{
510 if (bv.isEmpty())
511 return QGeoSatelliteInfo::Undefined;
512
513 NmeaSentence nmeaType = getNmeaSentenceType(bv);
514 if (nmeaType != NmeaSentenceGSA)
515 return QGeoSatelliteInfo::Undefined;
516
517 auto systemType = getSatelliteSystem(bv);
518 if (systemType == QGeoSatelliteInfo::Undefined)
519 return systemType;
520
521 // The documentation states that we do not modify pnrsInUse if we could not
522 // parse the data
523 pnrsInUse.clear();
524
525 // Adjust size so that * and following characters are not parsed by the following functions.
526 qsizetype idx = bv.indexOf('*');
527 QByteArrayView key = idx < 0 ? bv : bv.first(idx);
528
529 qlocationutils_readGsa(key, pnrsInUse);
530
531 // Quote from: https://gpsd.gitlab.io/gpsd/NMEA.html#_satellite_ids
532 // GLONASS satellite numbers come in two flavors. If a sentence has a GL
533 // talker ID, expect the skyviews to be GLONASS-only and in the range 1-32;
534 // you must add 64 to get a globally-unique NMEA ID. If the sentence has a
535 // GN talker ID, the device emits a multi-constellation skyview with
536 // GLONASS IDs already in the 65-96 range.
537 //
538 // However I don't observe such behavior with my device. So implementing a
539 // safe scenario.
540 if (systemType == QGeoSatelliteInfo::GLONASS) {
541 std::for_each(pnrsInUse.begin(), pnrsInUse.end(), [](int &id) {
542 if (id <= 64)
543 id += 64;
544 });
545 }
546
547 if ((systemType == QGeoSatelliteInfo::Multiple) && !pnrsInUse.isEmpty()) {
548 // Standard claims that in case of multiple system types we will receive
549 // several GSA messages, each containing data from only one satellite
550 // system, so we can pick the first id to determine the system type.
551 auto tempSystemType = getSatelliteSystemBySatelliteId(pnrsInUse.front());
552 if (tempSystemType != QGeoSatelliteInfo::Undefined)
553 systemType = tempSystemType;
554 }
555
556 return systemType;
557}
558
559bool QLocationUtils::hasValidNmeaChecksum(QByteArrayView bv)
560{
561 qsizetype asteriskIndex = bv.indexOf('*');
562
563 constexpr qsizetype CSUM_LEN = 2;
564 if (asteriskIndex < 0 || asteriskIndex >= bv.size() - CSUM_LEN)
565 return false;
566
567 // XOR byte value of all characters between '$' and '*'
568 int result = 0;
569 for (qsizetype i = 1; i < asteriskIndex; ++i)
570 result ^= bv[i];
571 /*
572 char calc[CSUM_LEN + 1];
573 ::snprintf(calc, CSUM_LEN + 1, "%02x", result);
574 return ::strncmp(calc, &data[asteriskIndex+1], 2) == 0;
575 */
576
577 QByteArrayView checkSumBytes = bv.sliced(asteriskIndex + 1, 2);
578 bool ok = false;
579 int checksum = checkSumBytes.toInt(&ok,16);
580 return ok && checksum == result;
581}
582
583bool QLocationUtils::getNmeaTime(const QByteArray &bytes, QTime *time)
584{
585 QTime tempTime = QTime::fromString(QString::fromLatin1(bytes),
586 QStringView(bytes.size() > 6 && bytes[6] == '.'
587 ? u"hhmmss.z"
588 : u"hhmmss"));
589
590 if (tempTime.isValid()) {
591 *time = tempTime;
592 return true;
593 }
594 return false;
595}
596
597bool QLocationUtils::getNmeaLatLong(const QByteArray &latString, char latDirection, const QByteArray &lngString, char lngDirection, double *lat, double *lng)
598{
599 if ((latDirection != 'N' && latDirection != 'S')
600 || (lngDirection != 'E' && lngDirection != 'W')) {
601 return false;
602 }
603
604 bool hasLat = false;
605 bool hasLong = false;
606 double tempLat = latString.toDouble(&hasLat);
607 double tempLng = lngString.toDouble(&hasLong);
608 if (hasLat && hasLong) {
609 tempLat = qlocationutils_nmeaDegreesToDecimal(tempLat);
610 if (latDirection == 'S')
611 tempLat *= -1;
612 tempLng = qlocationutils_nmeaDegreesToDecimal(tempLng);
613 if (lngDirection == 'W')
614 tempLng *= -1;
615
616 if (isValidLat(tempLat) && isValidLong(tempLng)) {
617 *lat = tempLat;
618 *lng = tempLng;
619 return true;
620 }
621 }
622 return false;
623}
624
625QT_END_NAMESPACE
static void qlocationutils_readZda(QByteArrayView bv, QGeoPositionInfo *info, bool *hasFix)
static void qlocationutils_readVtg(QByteArrayView bv, QGeoPositionInfo *info, bool *hasFix)
static void qlocationutils_readRmc(QByteArrayView bv, QGeoPositionInfo *info, bool *hasFix)
static void qlocationutils_readGga(QByteArrayView bv, QGeoPositionInfo *info, double uere, bool *hasFix, QGeoCoordinate::AltitudeType preferredAltitudeType)
static void qlocationutils_readGll(QByteArrayView bv, QGeoPositionInfo *info, bool *hasFix)
static void qlocationutils_readGsa(QByteArrayView bv, QList< int > &pnrsInUse)
static void qlocationutils_readGsa(QByteArrayView bv, QGeoPositionInfo *info, double uere, bool *hasFix)