QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
20#include "info.h"
21#include "qgspointxy.h"
22
23#include <QCoreApplication>
24
26{
29 for ( auto it = mConstellationFixStatus.begin(); it != mConstellationFixStatus.end(); ++it )
30 {
31 if ( it.value() == Qgis::GpsFixStatus::Fix3D
32 || ( it.value() == Qgis::GpsFixStatus::Fix2D && bestStatus != Qgis::GpsFixStatus::Fix3D )
33 || ( it.value() == Qgis::GpsFixStatus::NoFix && bestStatus == Qgis::GpsFixStatus::NoData )
34 )
35 {
36 bestStatus = it.value();
37 constellation = it.key();
38 }
39 }
40 return bestStatus;
41}
42
44{
45 bool valid = false;
47 const Qgis::GpsFixStatus bestFix = bestFixStatus( constellation );
48 if ( status == 'V'
49 || bestFix == Qgis::GpsFixStatus::NoFix
50 || qualityIndicator == Qgis::GpsQualityIndicator::Invalid ) // some sources say that 'V' indicates position fix, but is below acceptable quality
51 {
52 valid = false;
53 }
54 else if ( status == 'A' || status == 'D'
55 || bestFix == Qgis::GpsFixStatus::Fix2D
56 || bestFix == Qgis::GpsFixStatus::Fix3D
57 || ( qualityIndicator != Qgis::GpsQualityIndicator::Invalid ) ) // good - D=Differential for UM98x
58 {
59 valid = true;
60 }
61
62 valid &= longitude >= -180.0 && longitude <= 180.0 && latitude >= -90.0 && latitude <= 90.0;
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:1904
@ Unknown
Unknown/other system.
Definition qgis.h:1905
@ RTK
Real-time-kynematic.
Definition qgis.h:1928
@ DGPS
Differential GPS.
Definition qgis.h:1926
@ Estimated
Estimated.
Definition qgis.h:1930
@ Simulation
Simulation mode.
Definition qgis.h:1932
@ FloatRTK
Float real-time-kynematic.
Definition qgis.h:1929
@ Manual
Manual input mode.
Definition qgis.h:1931
GpsFixStatus
GPS fix status.
Definition qgis.h:1889
@ NoFix
GPS is not fixed.
Definition qgis.h:1891
@ NoData
No fix data available.
Definition qgis.h:1890
@ Fix2D
2D fix
Definition qgis.h:1892
@ Fix3D
3D fix
Definition qgis.h:1893
GpsInformationComponent
GPS information component.
Definition qgis.h:1956
@ TrackStartTime
Timestamp at start of current track (available from QgsGpsLogger class only).
Definition qgis.h:1971
@ GroundSpeed
Ground speed.
Definition qgis.h:1959
@ TrackTimeSinceLastPoint
Time since last recorded location (available from QgsGpsLogger class only).
Definition qgis.h:1974
@ Pdop
Dilution of precision.
Definition qgis.h:1963
@ TrackEndTime
Timestamp at end (current point) of current track (available from QgsGpsLogger class only).
Definition qgis.h:1972
@ Altitude
Altitude/elevation above or below the mean sea level.
Definition qgis.h:1958
@ TrackDistanceFromStart
Direct distance from first vertex in current GPS track to last vertex (available from QgsGpsLogger cl...
Definition qgis.h:1962
@ TotalTrackLength
Total distance of current GPS track (available from QgsGpsLogger class only).
Definition qgis.h:1961
@ Hdop
Horizontal dilution of precision.
Definition qgis.h:1964
@ EllipsoidAltitude
Altitude/elevation above or below the WGS-84 Earth ellipsoid.
Definition qgis.h:1976
@ Bearing
Bearing measured in degrees clockwise from true north to the direction of travel.
Definition qgis.h:1960
@ Vdop
Vertical dilution of precision.
Definition qgis.h:1965
@ GeoidalSeparation
Geoidal separation, the difference between the WGS-84 Earth ellipsoid and mean-sea-level (geoid),...
Definition qgis.h:1975
@ VerticalAccuracy
Vertical accuracy in meters.
Definition qgis.h:1967
@ Location
2D location (latitude/longitude), as a QgsPointXY value
Definition qgis.h:1957
@ TrackDistanceSinceLastPoint
Distance since last recorded location (available from QgsGpsLogger class only).
Definition qgis.h:1973
@ HorizontalAccuracy
Horizontal accuracy in meters.
Definition qgis.h:1966
@ SatellitesUsed
Count of satellites used in obtaining the fix.
Definition qgis.h:1969
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.
Represents a 2D point.
Definition qgspointxy.h:60
#define BUILTIN_UNREACHABLE
Definition qgis.h:7208