QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
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 
28 class QIODevice;
29 
30 #ifdef SIP_RUN
31 % ModuleHeaderCode
32 #include "qgsgpsconnection.h"
33 % End
34 #endif
35 
41 class 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 
98 class CORE_EXPORT QgsGpsInformation
99 {
100  public:
101 
107  {
111  Fix3D
112  };
113 
118  double latitude = 0;
119 
124  double longitude = 0;
125 
129  double elevation = 0;
130 
137  double elevation_diff = 0;
138 
142  double speed = 0;
143 
144 #ifndef SIP_RUN
145 
149  double direction = std::numeric_limits< double >::quiet_NaN();
150 #else
151 
155  double direction;
156 #endif
157 
161  QList<QgsSatelliteInfo> satellitesInView;
162 
166  double pdop = 0;
167 
171  double hdop = 0;
172 
176  double vdop = 0;
177 
178 #ifndef SIP_RUN
180  double hacc = std::numeric_limits< double >::quiet_NaN();
182  double vacc = std::numeric_limits< double >::quiet_NaN();
183 
188  double hvacc = std::numeric_limits< double >::quiet_NaN();
189 #else
191  double hacc;
193  double vacc;
194 
199  double hvacc;
200 #endif
201 
205  QDateTime utcDateTime;
206 
210  QChar fixMode;
211 
215  int fixType = 0;
216 
220  int quality = -1;
221 
225  int satellitesUsed = 0;
226 
230  QChar status;
231 
235  QList<int> satPrn;
236 
240  bool satInfoComplete = false;
241 
246  bool isValid() const;
247 
252  FixStatus fixStatus() const;
253 
259  QString qualityDescription() const;
260 };
261 
266 class CORE_EXPORT QgsGpsConnection : public QObject
267 {
268 #ifdef SIP_RUN
269 #include <qgsgpsdconnection.h>
270 #include <qgsnmeaconnection.h>
271 #endif
272 
273 
274 #ifdef SIP_RUN
276  if ( sipCpp->inherits( "QgsGpsdConnection" ) )
277  sipType = sipType_QgsGpsdConnection;
278  else if ( sipCpp->inherits( "QgsNmeaConnection" ) )
279  sipType = sipType_QgsNmeaConnection;
280  else
281  sipType = NULL;
282  SIP_END
283 #endif
284 
285  Q_OBJECT
286  public:
287 
288  enum Status
289  {
293  GPSDataReceived
294  };
295 
300  QgsGpsConnection( QIODevice *dev SIP_TRANSFER );
301  ~QgsGpsConnection() override;
303  bool connect();
305  bool close();
306 
308  void setSource( QIODevice *source SIP_TRANSFER );
309 
311  Status status() const { return mStatus; }
312 
314  QgsGpsInformation currentGPSInformation() const { return mLastGPSInformation; }
315 
316  signals:
317  void stateChanged( const QgsGpsInformation &info );
318  void nmeaSentenceReceived( const QString &substring ); // added to capture 'raw' data
319 
320  protected:
322  std::unique_ptr< QIODevice > mSource;
326  Status mStatus = NotConnected;
327 
328  private:
330  void cleanupSource();
331  void clearLastGPSInformation();
332 
333  protected slots:
335  virtual void parseData() = 0;
336 };
337 
338 #endif // QGSGPSCONNECTION_H
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.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:177
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_END
Definition: qgis_sip.h:194