QGIS API Documentation 3.39.0-Master (3783037d301)
Loading...
Searching...
No Matches
qgsgpsinformation.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsgpsinformation.cpp
3 --------------------
4 begin : November 30th, 2009
5 copyright : (C) 2009 by Marco Hugentobler
6 email : marco at hugis dot net
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "qgsgpsinformation.h"
19#include "info.h"
20#include "qgspointxy.h"
21
22#include <QCoreApplication>
23
25{
28 for ( auto it = mConstellationFixStatus.begin(); it != mConstellationFixStatus.end(); ++it )
29 {
30 if ( it.value() == Qgis::GpsFixStatus::Fix3D
31 || ( it.value() == Qgis::GpsFixStatus::Fix2D && bestStatus != Qgis::GpsFixStatus::Fix3D )
32 || ( it.value() == Qgis::GpsFixStatus::NoFix && bestStatus == Qgis::GpsFixStatus::NoData )
33 )
34 {
35 bestStatus = it.value();
36 constellation = it.key();
37 }
38 }
39 return bestStatus;
40}
41
43{
44 bool valid = false;
46 const Qgis::GpsFixStatus bestFix = bestFixStatus( constellation );
47 if ( status == 'V'
48 || bestFix == Qgis::GpsFixStatus::NoFix
49 || qualityIndicator == Qgis::GpsQualityIndicator::Invalid ) // some sources say that 'V' indicates position fix, but is below acceptable quality
50 {
51 valid = false;
52 }
53 else if ( status == 'A'
54 || bestFix == Qgis::GpsFixStatus::Fix2D
55 || bestFix == Qgis::GpsFixStatus::Fix3D
57 {
58 valid = true;
59 }
60
61 valid &= longitude >= -180.0 && longitude <= 180.0 && latitude >= -90.0 && latitude <= 90.0;
62
63 return valid;
64}
65
67{
69
70 // no fix if any of the three report bad; default values are invalid values and won't be changed if the corresponding NMEA msg is not received
71 if ( status == 'V' || fixType == NMEA_FIX_BAD || qualityIndicator == Qgis::GpsQualityIndicator::Invalid ) // some sources say that 'V' indicates position fix, but is below acceptable quality
72 {
74 }
75 else if ( fixType == NMEA_FIX_2D ) // 2D indication (from GGA)
76 {
78 }
79 else if ( status == 'A' || fixType == NMEA_FIX_3D || qualityIndicator != Qgis::GpsQualityIndicator::Invalid ) // good
80 {
82 }
83 return fixStatus;
84}
85
87{
88 switch ( qualityIndicator )
89 {
91 return QCoreApplication::translate( "QgsGpsInformation", "Simulation mode" );
92
94 return QCoreApplication::translate( "QgsGpsInformation", "Manual input mode" );
95
97 return QCoreApplication::translate( "QgsGpsInformation", "Estimated" );
98
100 return QCoreApplication::translate( "QgsGpsInformation", "Float RTK" );
101
103 return QCoreApplication::translate( "QgsGpsInformation", "Fixed RTK" );
104
106 return QCoreApplication::translate( "QgsGpsInformation", "PPS" );
107
109 return QCoreApplication::translate( "QgsGpsInformation", "DGPS" );
110
112 return QCoreApplication::translate( "QgsGpsInformation", "Autonomous" );
113
115 return QCoreApplication::translate( "QgsGpsInformation", "Invalid" );
116
118 return QCoreApplication::translate( "QgsGpsInformation", "Unknown (%1)" ).arg( QString::number( quality ) );
119 }
121}
122
124{
125 if ( !isValid() )
126 return QVariant();
127
128 switch ( component )
129 {
131 return QgsPointXY( longitude, latitude );
132
134 return std::isnan( elevation ) ? QVariant() : elevation;
135
137 return std::isnan( elevation_diff ) ? QVariant() : elevation_diff;
138
140 return std::isnan( elevation ) || std::isnan( elevation_diff ) ? QVariant() : elevation + elevation_diff;
141
143 return speed;
145 return std::isnan( direction ) ? QVariant() : direction;
146
148 return pdop;
150 return hdop;
152 return vdop;
154 return hacc;
156 return vacc;
158 return hvacc;
160 return satellitesUsed;
161
163 return utcDateTime;
164
171 return QVariant(); // not available
172 }
174}
175
GnssConstellation
GNSS constellation.
Definition qgis.h:1751
@ Unknown
Unknown/other system.
@ RTK
Real-time-kynematic.
@ DGPS
Differential GPS.
@ Simulation
Simulation mode.
@ FloatRTK
Float real-time-kynematic.
@ Manual
Manual input mode.
GpsFixStatus
GPS fix status.
Definition qgis.h:1736
@ NoFix
GPS is not fixed.
@ NoData
No fix data available.
GpsInformationComponent
GPS information component.
Definition qgis.h:1803
@ TrackStartTime
Timestamp at start of current track (available from QgsGpsLogger class only)
@ TrackTimeSinceLastPoint
Time since last recorded location (available from QgsGpsLogger class only)
@ Pdop
Dilution of precision.
@ TrackEndTime
Timestamp at end (current point) of current track (available from QgsGpsLogger class only)
@ Altitude
Altitude/elevation above or below the mean sea level.
@ TrackDistanceFromStart
Direct distance from first vertex in current GPS track to last vertex (available from QgsGpsLogger cl...
@ TotalTrackLength
Total distance of current GPS track (available from QgsGpsLogger class only)
@ Hdop
Horizontal dilution of precision.
@ EllipsoidAltitude
Altitude/elevation above or below the WGS-84 Earth ellipsoid.
@ Bearing
Bearing measured in degrees clockwise from true north to the direction of travel.
@ Vdop
Vertical dilution of precision.
@ GeoidalSeparation
Geoidal separation, the difference between the WGS-84 Earth ellipsoid and mean-sea-level (geoid),...
@ VerticalAccuracy
Vertical accuracy in meters.
@ Location
2D location (latitude/longitude), as a QgsPointXY value
@ TrackDistanceSinceLastPoint
Distance since last recorded location (available from QgsGpsLogger class only)
@ HorizontalAccuracy
Horizontal accuracy in meters.
@ SatellitesUsed
Count of satellites used in obtaining the fix.
double vdop
Vertical dilution of precision.
double direction
The bearing measured in degrees clockwise from true north to the direction of travel.
bool isValid() const
Returns whether the connection information is valid.
int fixType
Contains the fix type, where 1 = no fix, 2 = 2d fix, 3 = 3d fix.
QChar status
Status (A = active or V = void)
double speed
Ground speed, in km/h.
Q_DECL_DEPRECATED Qgis::GpsFixStatus fixStatus() const
Returns the fix status.
double vacc
Vertical accuracy in meters.
QString qualityDescription() const
Returns a descriptive string for the signal quality.
Qgis::GpsQualityIndicator qualityIndicator
Returns the signal quality indicator.
double latitude
Latitude in decimal degrees, using the WGS84 datum.
double longitude
Longitude in decimal degrees, using the WGS84 datum.
QDateTime utcDateTime
The date and time at which this position was reported, in UTC time.
double elevation
Altitude (in meters) above or below the mean sea level.
QVariant componentValue(Qgis::GpsInformationComponent component) const
Returns the value of the corresponding GPS information component.
double pdop
Dilution of precision.
int satellitesUsed
Count of satellites used in obtaining the fix.
Qgis::GpsFixStatus bestFixStatus(Qgis::GnssConstellation &constellation) const
Returns the best fix status and corresponding constellation.
double elevation_diff
Geoidal separation (in meters).
double hdop
Horizontal dilution of precision.
int quality
GPS quality indicator (0 = Invalid; 1 = Fix; 2 = Differential, 3 = Sensitive, etc....
double hacc
Horizontal accuracy in meters.
A class to represent a 2D point.
Definition qgspointxy.h:60
#define BUILTIN_UNREACHABLE
Definition qgis.h:6558