QGIS API Documentation 3.27.0-Master (a46f227e17)
qgsgpsconnection.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsgpsconnection.h - description
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#ifndef QGSGPSCONNECTION_H
19#define QGSGPSCONNECTION_H
20
21#include <QDateTime>
22#include "qgis.h"
23#include <QObject>
24#include <QString>
25
26#include "qgis_core.h"
27
28class QIODevice;
29
30#ifdef SIP_RUN
31% ModuleHeaderCode
32#include "qgsgpsconnection.h"
33% End
34#endif
35
41class CORE_EXPORT QgsSatelliteInfo
42{
43 public:
44
52 int id = 0;
53
57 bool inUse = false;
58
59#ifndef SIP_RUN
60
64 double elevation = std::numeric_limits< double >::quiet_NaN();
65#else
66
70 double elevation;
71#endif
72
73#ifndef SIP_RUN
74
78 double azimuth = std::numeric_limits< double >::quiet_NaN();
79#else
80
84 double azimuth;
85#endif
86
90 int signal = -1;
91
96 QChar satType;
97
98 bool operator==( const QgsSatelliteInfo &other ) const
99 {
100 return id == other.id &&
101 inUse == other.inUse &&
102 elevation == other.elevation &&
103 azimuth == other.azimuth &&
104 signal == other.signal &&
105 satType == other.satType;
106 }
107
108 bool operator!=( const QgsSatelliteInfo &other ) const
109 {
110 return !operator==( other );
111 }
112};
113
119class CORE_EXPORT QgsGpsInformation
120{
121 public:
122
128 {
132 Fix3D
133 };
134
139 double latitude = 0;
140
145 double longitude = 0;
146
150 double elevation = 0;
151
158 double elevation_diff = 0;
159
163 double speed = 0;
164
165#ifndef SIP_RUN
166
170 double direction = std::numeric_limits< double >::quiet_NaN();
171#else
172
176 double direction;
177#endif
178
182 QList<QgsSatelliteInfo> satellitesInView;
183
187 double pdop = 0;
188
192 double hdop = 0;
193
197 double vdop = 0;
198
199#ifndef SIP_RUN
201 double hacc = std::numeric_limits< double >::quiet_NaN();
203 double vacc = std::numeric_limits< double >::quiet_NaN();
204
209 double hvacc = std::numeric_limits< double >::quiet_NaN();
210#else
212 double hacc;
214 double vacc;
215
220 double hvacc;
221#endif
222
226 QDateTime utcDateTime;
227
231 QChar fixMode;
232
236 int fixType = 0;
237
242 int quality = -1;
243
249
253 int satellitesUsed = 0;
254
258 QChar status;
259
263 QList<int> satPrn;
264
268 bool satInfoComplete = false;
269
274 bool isValid() const;
275
280 FixStatus fixStatus() const;
281
287 QString qualityDescription() const;
288};
289
294class CORE_EXPORT QgsGpsConnection : public QObject
295{
296#ifdef SIP_RUN
297#include <qgsgpsdconnection.h>
298#include <qgsnmeaconnection.h>
299#endif
300
301
302#ifdef SIP_RUN
304 if ( sipCpp->inherits( "QgsGpsdConnection" ) )
305 sipType = sipType_QgsGpsdConnection;
306 else if ( sipCpp->inherits( "QgsNmeaConnection" ) )
307 sipType = sipType_QgsNmeaConnection;
308 else
309 sipType = NULL;
310 SIP_END
311#endif
312
313 Q_OBJECT
314 public:
315
317 {
321 GPSDataReceived
322 };
323
328 QgsGpsConnection( QIODevice *dev SIP_TRANSFER );
329 ~QgsGpsConnection() override;
331 bool connect();
333 bool close();
334
336 void setSource( QIODevice *source SIP_TRANSFER );
337
339 Status status() const { return mStatus; }
340
342 QgsGpsInformation currentGPSInformation() const { return mLastGPSInformation; }
343
344 signals:
345 void stateChanged( const QgsGpsInformation &info );
346 void nmeaSentenceReceived( const QString &substring ); // added to capture 'raw' data
347
348 protected:
350 std::unique_ptr< QIODevice > mSource;
354 Status mStatus = NotConnected;
355
356 private:
358 void cleanupSource();
359 void clearLastGPSInformation();
360
361 protected slots:
363 virtual void parseData() = 0;
364};
365
366#endif // QGSGPSCONNECTION_H
GpsQualityIndicator
GPS signal quality indicator.
Definition: qgis.h:887
Abstract base class for connection to a GPS device.
Status status() const
Returns the status. Possible state are not connected, connected, data received.
QgsGpsInformation mLastGPSInformation
Last state of the gps related variables (e.g. position, time, ...)
virtual void parseData()=0
Parse available data source content.
void nmeaSentenceReceived(const QString &substring)
std::unique_ptr< QIODevice > mSource
Data source (e.g. serial device, socket, file,...)
QgsGpsInformation currentGPSInformation() const
Returns the current gps information (lat, lon, etc.)
void stateChanged(const QgsGpsInformation &info)
Encapsulates information relating to a GPS position fix.
FixStatus
GPS fix status.
QChar status
Status (A = active or V = void)
QList< QgsSatelliteInfo > satellitesInView
Contains a list of information relating to the current satellites in view.
QChar fixMode
Fix mode (where M = Manual, forced to operate in 2D or 3D or A = Automatic, 3D/2D)
QDateTime utcDateTime
The date and time at which this position was reported, in UTC time.
QList< int > satPrn
IDs of satellites used in the position fix.
Encapsulates information relating to a GPS satellite.
double elevation
Elevation of the satellite, in degrees.
bool inUse
true if satellite was used in obtaining the position fix.
bool operator!=(const QgsSatelliteInfo &other) const
int signal
Signal strength (0-99dB), or -1 if not available.
bool operator==(const QgsSatelliteInfo &other) const
int id
Contains the satellite identifier number.
double azimuth
The azimuth of the satellite to true north, in degrees.
QChar satType
satType value from NMEA message $GxGSV, where x: P = GPS; S = SBAS (GPSid> 32 then SBasid = GPSid + 8...
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:186
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_END
Definition: qgis_sip.h:203
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)