QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
239  QString qualityDescription() const;
240 };
241 
246 class CORE_EXPORT QgsGpsConnection : public QObject
247 {
248 #ifdef SIP_RUN
249 #include <qgsgpsdconnection.h>
250 #include <qgsnmeaconnection.h>
251 #endif
252 
253 
254 #ifdef SIP_RUN
256  if ( sipCpp->inherits( "QgsGpsdConnection" ) )
257  sipType = sipType_QgsGpsdConnection;
258  else if ( sipCpp->inherits( "QgsNmeaConnection" ) )
259  sipType = sipType_QgsNmeaConnection;
260  else
261  sipType = NULL;
262  SIP_END
263 #endif
264 
265  Q_OBJECT
266  public:
267 
268  enum Status
269  {
273  GPSDataReceived
274  };
275 
280  QgsGpsConnection( QIODevice *dev SIP_TRANSFER );
281  ~QgsGpsConnection() override;
283  bool connect();
285  bool close();
286 
288  void setSource( QIODevice *source SIP_TRANSFER );
289 
291  Status status() const { return mStatus; }
292 
294  QgsGpsInformation currentGPSInformation() const { return mLastGPSInformation; }
295 
296  signals:
297  void stateChanged( const QgsGpsInformation &info );
298  void nmeaSentenceReceived( const QString &substring ); // added to capture 'raw' data
299 
300  protected:
302  std::unique_ptr< QIODevice > mSource;
306  Status mStatus = NotConnected;
307 
308  private:
310  void cleanupSource();
311  void clearLastGPSInformation();
312 
313  protected slots:
315  virtual void parseData() = 0;
316 };
317 
318 #endif // QGSGPSCONNECTION_H
QgsGpsConnection::stateChanged
void stateChanged(const QgsGpsInformation &info)
QgsGpsInformation::FixStatus
FixStatus
GPS fix status.
Definition: qgsgpsconnection.h:107
QgsGpsConnection::Connected
@ Connected
Definition: qgsgpsconnection.h:271
qgsgpsdconnection.h
qgis.h
QgsGpsConnection::nmeaSentenceReceived
void nmeaSentenceReceived(const QString &substring)
QgsGpsConnection::currentGPSInformation
QgsGpsInformation currentGPSInformation() const
Returns the current gps information (lat, lon, etc.)
Definition: qgsgpsconnection.h:294
QgsSatelliteInfo
Encapsulates information relating to a GPS satellite.
Definition: qgsgpsconnection.h:42
QgsGpsConnection::status
Status status() const
Returns the status. Possible state are not connected, connected, data received.
Definition: qgsgpsconnection.h:291
QgsGpsConnection::Status
Status
Definition: qgsgpsconnection.h:269
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:177
QgsGpsConnection::mSource
std::unique_ptr< QIODevice > mSource
Data source (e.g. serial device, socket, file,...)
Definition: qgsgpsconnection.h:302
QgsGpsInformation::utcDateTime
QDateTime utcDateTime
The date and time at which this position was reported, in UTC time.
Definition: qgsgpsconnection.h:185
QgsGpsInformation
Encapsulates information relating to a GPS position fix.
Definition: qgsgpsconnection.h:99
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:304
QgsGpsConnection::parseData
virtual void parseData()=0
Parse available data source content.
QgsGpsConnection::DataReceived
@ DataReceived
Definition: qgsgpsconnection.h:272
QgsGpsInformation::NoFix
@ NoFix
Definition: qgsgpsconnection.h:109
QgsGpsConnection
Abstract base class for connection to a GPS device.
Definition: qgsgpsconnection.h:247
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:194
QgsGpsConnection::NotConnected
@ NotConnected
Definition: qgsgpsconnection.h:270
QgsGpsInformation::status
QChar status
Status (A = active or V = void)
Definition: qgsgpsconnection.h:210
QgsGpsInformation::NoData
@ NoData
Definition: qgsgpsconnection.h:108