QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 
221  int quality = -1;
222 
228 
232  int satellitesUsed = 0;
233 
237  QChar status;
238 
242  QList<int> satPrn;
243 
247  bool satInfoComplete = false;
248 
253  bool isValid() const;
254 
259  FixStatus fixStatus() const;
260 
266  QString qualityDescription() const;
267 };
268 
273 class CORE_EXPORT QgsGpsConnection : public QObject
274 {
275 #ifdef SIP_RUN
276 #include <qgsgpsdconnection.h>
277 #include <qgsnmeaconnection.h>
278 #endif
279 
280 
281 #ifdef SIP_RUN
283  if ( sipCpp->inherits( "QgsGpsdConnection" ) )
284  sipType = sipType_QgsGpsdConnection;
285  else if ( sipCpp->inherits( "QgsNmeaConnection" ) )
286  sipType = sipType_QgsNmeaConnection;
287  else
288  sipType = NULL;
289  SIP_END
290 #endif
291 
292  Q_OBJECT
293  public:
294 
295  enum Status
296  {
300  GPSDataReceived
301  };
302 
307  QgsGpsConnection( QIODevice *dev SIP_TRANSFER );
308  ~QgsGpsConnection() override;
310  bool connect();
312  bool close();
313 
315  void setSource( QIODevice *source SIP_TRANSFER );
316 
318  Status status() const { return mStatus; }
319 
321  QgsGpsInformation currentGPSInformation() const { return mLastGPSInformation; }
322 
323  signals:
324  void stateChanged( const QgsGpsInformation &info );
325  void nmeaSentenceReceived( const QString &substring ); // added to capture 'raw' data
326 
327  protected:
329  std::unique_ptr< QIODevice > mSource;
333  Status mStatus = NotConnected;
334 
335  private:
337  void cleanupSource();
338  void clearLastGPSInformation();
339 
340  protected slots:
342  virtual void parseData() = 0;
343 };
344 
345 #endif // QGSGPSCONNECTION_H
GpsQualityIndicator
GPS signal quality indicator.
Definition: qgis.h:615
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