QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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  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 
112 class 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
193  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
204  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 
287 class 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 
309  enum Status
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
Qgis::GpsQualityIndicator
GpsQualityIndicator
GPS signal quality indicator.
Definition: qgis.h:833
operator==
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:425
QgsGpsInformation::FixStatus
FixStatus
GPS fix status.
Definition: qgsgpsconnection.h:120
QgsGpsConnection::Connected
@ Connected
Definition: qgsgpsconnection.h:312
qgsgpsdconnection.h
QgsSatelliteInfo::operator!=
bool operator!=(const QgsSatelliteInfo &other) const
Definition: qgsgpsconnection.h:101
qgis.h
QgsGpsConnection::currentGPSInformation
QgsGpsInformation currentGPSInformation() const
Returns the current gps information (lat, lon, etc.)
Definition: qgsgpsconnection.h:335
QgsSatelliteInfo
Encapsulates information relating to a GPS satellite.
Definition: qgsgpsconnection.h:41
QgsGpsConnection::status
Status status() const
Returns the status. Possible state are not connected, connected, data received.
Definition: qgsgpsconnection.h:332
QgsSatelliteInfo::signal
int signal
Signal strength (0-99dB), or -1 if not available.
Definition: qgsgpsconnection.h:90
QgsGpsConnection::Status
Status
Definition: qgsgpsconnection.h:309
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:186
Qgis::GpsQualityIndicator::Unknown
@ Unknown
Unknown.
QgsGpsConnection::mSource
std::unique_ptr< QIODevice > mSource
Data source (e.g. serial device, socket, file,...)
Definition: qgsgpsconnection.h:343
QgsGpsInformation::utcDateTime
QDateTime utcDateTime
The date and time at which this position was reported, in UTC time.
Definition: qgsgpsconnection.h:219
QgsGpsInformation
Encapsulates information relating to a GPS position fix.
Definition: qgsgpsconnection.h:112
QgsSatelliteInfo::elevation
double elevation
Elevation of the satellite, in degrees.
Definition: qgsgpsconnection.h:64
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:224
QgsSatelliteInfo::inUse
bool inUse
true if satellite was used in obtaining the position fix.
Definition: qgsgpsconnection.h:57
qgsgpsconnection.h
QgsGpsInformation::Fix2D
@ Fix2D
Definition: qgsgpsconnection.h:124
QgsGpsConnection::mLastGPSInformation
QgsGpsInformation mLastGPSInformation
Last state of the gps related variables (e.g. position, time, ...)
Definition: qgsgpsconnection.h:345
QgsSatelliteInfo::id
int id
Contains the satellite identifier number.
Definition: qgsgpsconnection.h:52
QgsSatelliteInfo::azimuth
double azimuth
The azimuth of the satellite to true north, in degrees.
Definition: qgsgpsconnection.h:78
QgsGpsConnection::DataReceived
@ DataReceived
Definition: qgsgpsconnection.h:313
QgsGpsInformation::NoFix
@ NoFix
Definition: qgsgpsconnection.h:123
QgsGpsConnection
Abstract base class for connection to a GPS device.
Definition: qgsgpsconnection.h:287
QgsGpsInformation::satPrn
QList< int > satPrn
IDs of satellites used in the position fix.
Definition: qgsgpsconnection.h:256
QgsGpsInformation::satellitesInView
QList< QgsSatelliteInfo > satellitesInView
Contains a list of information relating to the current satellites in view.
Definition: qgsgpsconnection.h:175
QgsSatelliteInfo::operator==
bool operator==(const QgsSatelliteInfo &other) const
Definition: qgsgpsconnection.h:92
qgsnmeaconnection.h
SIP_END
#define SIP_END
Definition: qgis_sip.h:203
QgsGpsConnection::NotConnected
@ NotConnected
Definition: qgsgpsconnection.h:311
QgsGpsInformation::status
QChar status
Status (A = active or V = void)
Definition: qgsgpsconnection.h:251
QgsGpsInformation::NoData
@ NoData
Definition: qgsgpsconnection.h:122