QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
134  double speed = 0;
135 
136 #ifndef SIP_RUN
137 
141  double direction = std::numeric_limits< double >::quiet_NaN();
142 #else
143 
147  double direction;
148 #endif
149 
153  QList<QgsSatelliteInfo> satellitesInView;
154 
158  double pdop = 0;
159 
163  double hdop = 0;
164 
168  double vdop = 0;
169 
170 #ifndef SIP_RUN
171  double hacc = std::numeric_limits< double >::quiet_NaN();
174  double vacc = std::numeric_limits< double >::quiet_NaN();
175 #else
176  double hacc;
179  double vacc;
180 #endif
181 
185  QDateTime utcDateTime;
186 
190  QChar fixMode;
191 
195  int fixType = 0;
196 
200  int quality = -1;
201 
205  int satellitesUsed = 0;
206 
210  QChar status;
211 
215  QList<int> satPrn;
216 
220  bool satInfoComplete = false;
221 
226  bool isValid() const;
227 
232  FixStatus fixStatus() const;
233 };
234 
239 class CORE_EXPORT QgsGpsConnection : public QObject
240 {
241 #ifdef SIP_RUN
242 #include <qgsgpsdconnection.h>
243 #include <qgsnmeaconnection.h>
244 #endif
245 
246 
247 #ifdef SIP_RUN
249  if ( sipCpp->inherits( "QgsGpsdConnection" ) )
250  sipType = sipType_QgsGpsdConnection;
251  else if ( sipCpp->inherits( "QgsNmeaConnection" ) )
252  sipType = sipType_QgsNmeaConnection;
253  else
254  sipType = NULL;
255  SIP_END
256 #endif
257 
258  Q_OBJECT
259  public:
260 
261  enum Status
262  {
266  GPSDataReceived
267  };
268 
273  QgsGpsConnection( QIODevice *dev SIP_TRANSFER );
274  ~QgsGpsConnection() override;
276  bool connect();
278  bool close();
279 
281  void setSource( QIODevice *source SIP_TRANSFER );
282 
284  Status status() const { return mStatus; }
285 
287  QgsGpsInformation currentGPSInformation() const { return mLastGPSInformation; }
288 
289  signals:
290  void stateChanged( const QgsGpsInformation &info );
291  void nmeaSentenceReceived( const QString &substring ); // added to capture 'raw' data
292 
293  protected:
295  std::unique_ptr< QIODevice > mSource;
299  Status mStatus = NotConnected;
300 
301  private:
303  void cleanupSource();
304  void clearLastGPSInformation();
305 
306  protected slots:
308  virtual void parseData() = 0;
309 };
310 
311 #endif // QGSGPSCONNECTION_H
QgsGpsInformation::FixStatus
FixStatus
GPS fix status.
Definition: qgsgpsconnection.h:106
QgsGpsConnection::Connected
@ Connected
Definition: qgsgpsconnection.h:264
qgsgpsdconnection.h
qgis.h
QgsGpsConnection::currentGPSInformation
QgsGpsInformation currentGPSInformation() const
Returns the current gps information (lat, lon, etc.)
Definition: qgsgpsconnection.h:287
QgsSatelliteInfo
Definition: qgsgpsconnection.h:41
QgsGpsConnection::status
Status status() const
Returns the status. Possible state are not connected, connected, data received.
Definition: qgsgpsconnection.h:284
QgsGpsConnection::Status
Status
Definition: qgsgpsconnection.h:261
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:172
QgsGpsConnection::mSource
std::unique_ptr< QIODevice > mSource
Data source (e.g. serial device, socket, file,...)
Definition: qgsgpsconnection.h:295
QgsGpsInformation::utcDateTime
QDateTime utcDateTime
The date and time at which this position was reported, in UTC time.
Definition: qgsgpsconnection.h:185
QgsGpsInformation
Definition: qgsgpsconnection.h:98
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsGpsInformation::fixMode
QChar fixMode
Fix mode (where M = Manual, forced to operate in 2D or 3D or A = Automatic, 3D/2D)
Definition: qgsgpsconnection.h:190
qgsgpsconnection.h
QgsGpsInformation::Fix2D
@ Fix2D
Definition: qgsgpsconnection.h:110
QgsGpsConnection::mLastGPSInformation
QgsGpsInformation mLastGPSInformation
Last state of the gps related variables (e.g. position, time, ...)
Definition: qgsgpsconnection.h:297
QgsGpsConnection::DataReceived
@ DataReceived
Definition: qgsgpsconnection.h:265
QgsGpsInformation::NoFix
@ NoFix
Definition: qgsgpsconnection.h:109
QgsGpsConnection
Definition: qgsgpsconnection.h:239
QgsGpsInformation::satPrn
QList< int > satPrn
IDs of satellites used in the position fix.
Definition: qgsgpsconnection.h:215
QgsGpsInformation::satellitesInView
QList< QgsSatelliteInfo > satellitesInView
Contains a list of information relating to the current satellites in view.
Definition: qgsgpsconnection.h:153
qgsnmeaconnection.h
SIP_END
#define SIP_END
Definition: qgis_sip.h:189
QgsGpsConnection::NotConnected
@ NotConnected
Definition: qgsgpsconnection.h:263
QgsGpsInformation::status
QChar status
Status (A = active or V = void)
Definition: qgsgpsconnection.h:210
QgsGpsInformation::NoData
@ NoData
Definition: qgsgpsconnection.h:108