QGIS API Documentation 3.27.0-Master (f261cc1f8b)
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
92 bool operator==( const QgsSatelliteInfo &other ) const
93 {
94 return id == other.id &&
95 inUse == other.inUse &&
96 elevation == other.elevation &&
97 azimuth == other.azimuth &&
98 signal == other.signal;
99 }
100
101 bool operator!=( const QgsSatelliteInfo &other ) const
102 {
103 return !operator==( other );
104 }
105};
106
112class CORE_EXPORT QgsGpsInformation
113{
114 public:
115
121 {
125 Fix3D
126 };
127
132 double latitude = 0;
133
138 double longitude = 0;
139
143 double elevation = 0;
144
151 double elevation_diff = 0;
152
156 double speed = 0;
157
158#ifndef SIP_RUN
159
163 double direction = std::numeric_limits< double >::quiet_NaN();
164#else
165
169 double direction;
170#endif
171
175 QList<QgsSatelliteInfo> satellitesInView;
176
180 double pdop = 0;
181
185 double hdop = 0;
186
190 double vdop = 0;
191
192#ifndef SIP_RUN
194 double hacc = std::numeric_limits< double >::quiet_NaN();
196 double vacc = std::numeric_limits< double >::quiet_NaN();
197
202 double hvacc = std::numeric_limits< double >::quiet_NaN();
203#else
205 double hacc;
207 double vacc;
208
213 double hvacc;
214#endif
215
219 QDateTime utcDateTime;
220
224 QChar fixMode;
225
229 int fixType = 0;
230
235 int quality = -1;
236
242
246 int satellitesUsed = 0;
247
251 QChar status;
252
256 QList<int> satPrn;
257
261 bool satInfoComplete = false;
262
267 bool isValid() const;
268
273 FixStatus fixStatus() const;
274
280 QString qualityDescription() const;
281};
282
287class CORE_EXPORT QgsGpsConnection : public QObject
288{
289#ifdef SIP_RUN
290#include <qgsgpsdconnection.h>
291#include <qgsnmeaconnection.h>
292#endif
293
294
295#ifdef SIP_RUN
297 if ( sipCpp->inherits( "QgsGpsdConnection" ) )
298 sipType = sipType_QgsGpsdConnection;
299 else if ( sipCpp->inherits( "QgsNmeaConnection" ) )
300 sipType = sipType_QgsNmeaConnection;
301 else
302 sipType = NULL;
303 SIP_END
304#endif
305
306 Q_OBJECT
307 public:
308
310 {
314 GPSDataReceived
315 };
316
321 QgsGpsConnection( QIODevice *dev SIP_TRANSFER );
322 ~QgsGpsConnection() override;
324 bool connect();
326 bool close();
327
329 void setSource( QIODevice *source SIP_TRANSFER );
330
332 Status status() const { return mStatus; }
333
335 QgsGpsInformation currentGPSInformation() const { return mLastGPSInformation; }
336
337 signals:
338 void stateChanged( const QgsGpsInformation &info );
339 void nmeaSentenceReceived( const QString &substring ); // added to capture 'raw' data
340
341 protected:
343 std::unique_ptr< QIODevice > mSource;
347 Status mStatus = NotConnected;
348
349 private:
351 void cleanupSource();
352 void clearLastGPSInformation();
353
354 protected slots:
356 virtual void parseData() = 0;
357};
358
359#endif // QGSGPSCONNECTION_H
GpsQualityIndicator
GPS signal quality indicator.
Definition: qgis.h:867
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.
#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)