QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
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#include "qgspoint.h"
28#include "qgsgpsinformation.h"
29
30class QIODevice;
31
36template<class T> class QgsSettingsEntryEnumFlag;
37
38
39#ifdef SIP_RUN
40% ModuleHeaderCode
41#include "qgsgpsconnection.h"
42% End
43#endif
44
49class CORE_EXPORT QgsGpsConnection : public QObject
50{
51 //SIP_TYPEHEADER_INCLUDE( "qgsgpsdconnection.h" );
52 //SIP_TYPEHEADER_INCLUDE( "qgsnmeaconnection.h" );
53
54
55#ifdef SIP_RUN
57 if ( sipCpp->inherits( "QgsGpsdConnection" ) )
58 sipType = sipType_QgsGpsdConnection;
59 else if ( sipCpp->inherits( "QgsNmeaConnection" ) )
60 sipType = sipType_QgsNmeaConnection;
61 else
62 sipType = NULL;
64#endif
65
66 Q_OBJECT
67 public:
68
69 enum Status
70 {
74 GPSDataReceived
75 };
76
77#ifndef SIP_RUN
80
83
86
89
92
95
98
101
104
107
110
113
116#endif
117
122 QgsGpsConnection( QIODevice *dev SIP_TRANSFER );
123 ~QgsGpsConnection() override;
125 bool connect();
127 bool close();
128
130 void setSource( QIODevice *source SIP_TRANSFER );
131
133 Status status() const { return mStatus; }
134
136 QgsGpsInformation currentGPSInformation() const { return mLastGPSInformation; }
137
143 QgsPoint lastValidLocation() const { return mLastLocation; }
144
145 signals:
146
150 void stateChanged( const QgsGpsInformation &info );
151
152 // TODO QGIS 4.0 -- move to QgsNmeaConnection, it makes no sense in the base class
153
157 void nmeaSentenceReceived( const QString &substring );
158
165
173 void positionChanged( const QgsPoint &point );
174
175 protected:
177 std::unique_ptr< QIODevice > mSource;
181 Status mStatus = NotConnected;
182
183 private slots:
184
185 void onStateChanged( const QgsGpsInformation &info );
186
187 private:
189 void cleanupSource();
190 void clearLastGPSInformation();
191
192 protected slots:
194 virtual void parseData() = 0; // cppcheck-suppress pureVirtualCall
195
196 private:
197
200
202 QgsPoint mLastLocation;
203};
204
205#endif // QGSGPSCONNECTION_H
GpsFixStatus
GPS fix status.
Definition qgis.h:1799
@ NoData
No fix data available.
Abstract base class for connection to a GPS device.
Status status() const
Returns the status. Possible state are not connected, connected, data received.
static const QgsSettingsEntryString * settingsGpsSerialDevice
Settings entry GPS serial device name.
static const QgsSettingsEntryEnumFlag< Qt::TimeSpec > * settingsGpsTimeStampSpecification
Settings entry time specification for GPS time stamps.
static const QgsSettingsEntryString * settingsGpsTimeStampTimeZone
Settings entry GPS time stamp time zone.
static const QgsSettingsEntryString * settingsGpsdHostName
Settings entry GPSD host name.
QgsGpsInformation mLastGPSInformation
Last state of the gps related variables (e.g. position, time, ...)
virtual void parseData()=0
Parse available data source content.
static const QgsSettingsEntryBool * settingGpsApplyLeapSecondsCorrection
Settings entry GPS apply leap seconds correction.
static const QgsSettingsEntryInteger * settingGpsLeapSeconds
Settings entry GPS leap seconds correction amount (in seconds)
QgsPoint lastValidLocation() const
Returns the last valid location obtained by the device.
static const QgsSettingsEntryEnumFlag< Qgis::GpsConnectionType > * settingsGpsConnectionType
Settings entry GPS connection type.
void positionChanged(const QgsPoint &point)
Emitted when the GPS position changes.
void nmeaSentenceReceived(const QString &substring)
Emitted whenever the GPS device receives a raw NMEA sentence.
std::unique_ptr< QIODevice > mSource
Data source (e.g. serial device, socket, file,...)
static const QgsSettingsEntryInteger * settingsGpsTimeStampOffsetFromUtc
Settings entry GPS time offset from UTC in seconds.
void fixStatusChanged(Qgis::GpsFixStatus status)
Emitted when the GPS device fix status is changed.
static const QgsSettingsEntryBool * settingGpsBearingFromTravelDirection
Settings entry GPS calculate bearing from travel direction.
static const QgsSettingsEntryInteger * settingGpsAcquisitionInterval
Settings entry GPS track point acquisition interval.
static const QgsSettingsEntryDouble * settingGpsDistanceThreshold
Settings entry GPS track point distance threshold.
static const QgsSettingsEntryString * settingsGpsdDeviceName
Settings entry GPSD device name.
QgsGpsInformation currentGPSInformation() const
Returns the current gps information (lat, lon, etc.)
void stateChanged(const QgsGpsInformation &info)
Emitted whenever the GPS state is changed.
static const QgsSettingsEntryInteger * settingsGpsdPortNumber
Settings entry GPSD port number.
Encapsulates information relating to a GPS position fix.
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49
A boolean settings entry.
A double settings entry.
A template class for enum and flag settings entry.
An integer settings entry.
A string settings entry.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:191
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_END
Definition qgis_sip.h:208