QGIS API Documentation 3.41.0-Master (64d82d4c163)
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' || status == 'D'
54 || bestFix == Qgis::GpsFixStatus::Fix2D
55 || bestFix == Qgis::GpsFixStatus::Fix3D
56 || ( qualityIndicator != Qgis::GpsQualityIndicator::Invalid ) ) // good - D=Differential for UM98x
57 {
58 valid = true;
59 }
60
61 valid &= longitude >= -180.0 && longitude <= 180.0 && latitude >= -90.0 && latitude <= 90.0;
62 return valid;
63}
64
66{
68
69 // 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
70 if ( status == 'V' || fixType == NMEA_FIX_BAD || qualityIndicator == Qgis::GpsQualityIndicator::Invalid ) // some sources say that 'V' indicates position fix, but is below acceptable quality
71 {
73 }
74 else if ( fixType == NMEA_FIX_2D ) // 2D indication (from GGA)
75 {
77 }
78 else if ( status == 'A' || fixType == NMEA_FIX_3D || qualityIndicator != Qgis::GpsQualityIndicator::Invalid ) // good
79 {
81 }
82 return fixStatus;
83}
84
86{
87 switch ( qualityIndicator )
88 {
90 return QCoreApplication::translate( "QgsGpsInformation", "Simulation mode" );
91
93 return QCoreApplication::translate( "QgsGpsInformation", "Manual input mode" );
94
96 return QCoreApplication::translate( "QgsGpsInformation", "Estimated" );
97
99 return QCoreApplication::translate( "QgsGpsInformation", "Float RTK" );
100
102 return QCoreApplication::translate( "QgsGpsInformation", "Fixed RTK" );
103
105 return QCoreApplication::translate( "QgsGpsInformation", "PPS" );
106
108 return QCoreApplication::translate( "QgsGpsInformation", "DGPS" );
109
111 return QCoreApplication::translate( "QgsGpsInformation", "Autonomous" );
112
114 return QCoreApplication::translate( "QgsGpsInformation", "Invalid" );
115
117 return QCoreApplication::translate( "QgsGpsInformation", "Unknown (%1)" ).arg( QString::number( quality ) );
118 }
120}
121
123{
124 if ( !isValid() )
125 return QVariant();
126
127 switch ( component )
128 {
130 return QgsPointXY( longitude, latitude );
131
133 return std::isnan( elevation ) ? QVariant() : elevation;
134
136 return std::isnan( elevation_diff ) ? QVariant() : elevation_diff;
137
139 return std::isnan( elevation ) || std::isnan( elevation_diff ) ? QVariant() : elevation + elevation_diff;
140
142 return speed;
144 return std::isnan( direction ) ? QVariant() : direction;
145
147 return pdop;
149 return hdop;
151 return vdop;
153 return hacc;
155 return vacc;
157 return hvacc;
159 return satellitesUsed;
160
162 return utcDateTime;
163
170 return QVariant(); // not available
171 }
173}
174
GnssConstellation
GNSS constellation.
Definition qgis.h:1834
@ 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:1819
@ NoFix
GPS is not fixed.
@ NoData
No fix data available.
GpsInformationComponent
GPS information component.
Definition qgis.h:1886
@ 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:6779