QGIS API Documentation 4.1.0-Master (60fea48833c)
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 "qgis.h"
22#include "qgis_core.h"
23#include "qgsgpsinformation.h"
24#include "qgspoint.h"
25
26#include <QDateTime>
27#include <QObject>
28#include <QString>
29
30class QIODevice;
31
36template<class T> class QgsSettingsEntryEnumFlag;
37
38
39#ifdef SIP_RUN
40// clang-format off
41% ModuleHeaderCode
42#include "qgsgpsconnection.h"
43% End
44// clang-format on
45#endif
46
51 class CORE_EXPORT QgsGpsConnection : public QObject
52{
53 //SIP_TYPEHEADER_INCLUDE( "qgsgpsdconnection.h" );
54 //SIP_TYPEHEADER_INCLUDE( "qgsnmeaconnection.h" );
55
56
57#ifdef SIP_RUN
59 if ( sipCpp->inherits( "QgsGpsdConnection" ) )
60 sipType = sipType_QgsGpsdConnection;
61 else if ( sipCpp->inherits( "QgsNmeaConnection" ) )
62 sipType = sipType_QgsNmeaConnection;
63 else
64 sipType = NULL;
66#endif
67
68 // clang-format off
69 Q_OBJECT
70
71 public:
72
73 enum Status
74 {
75 // clang-format on
80 };
81
82#ifndef SIP_RUN
85
88
91
94
97
100
103
106
109
112
115
118
121#endif
122
127 QgsGpsConnection( QIODevice *dev SIP_TRANSFER );
128 ~QgsGpsConnection() override;
130 bool connect();
132 bool close();
133
135 void setSource( QIODevice *source SIP_TRANSFER );
136
138 Status status() const { return mStatus; }
139
142
148 QgsPoint lastValidLocation() const { return mLastLocation; }
149
150 signals:
151
155 void stateChanged( const QgsGpsInformation &info );
156
157 // TODO QGIS 5.0 -- move to QgsNmeaConnection, it makes no sense in the base class
158
162 void nmeaSentenceReceived( const QString &substring );
163
170
178 void positionChanged( const QgsPoint &point );
179
180 protected:
182 std::unique_ptr< QIODevice > mSource;
187
188 private slots:
189
190 void onStateChanged( const QgsGpsInformation &info );
191
192 private:
194 void cleanupSource();
195 void clearLastGPSInformation();
196
197 protected slots:
199 virtual void parseData() = 0; // cppcheck-suppress pureVirtualCall
200
201 private:
204
206 QgsPoint mLastLocation;
207};
208
209#endif // QGSGPSCONNECTION_H
GpsFixStatus
GPS fix status.
Definition qgis.h:1968
@ NoData
No fix data available.
Definition qgis.h:1969
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.
void setSource(QIODevice *source)
Sets the GPS source. The class takes ownership of the device class.
static const QgsSettingsEntryEnumFlag< Qgis::GpsConnectionType > * settingsGpsConnectionType
Settings entry GPS connection type.
bool connect()
Opens connection to device.
bool close()
Closes connection to device.
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.
QgsGpsConnection(QIODevice *dev)
Constructor.
static const QgsSettingsEntryString * settingsGpsdDeviceName
Settings entry GPSD device name.
QgsGpsInformation currentGPSInformation() const
Returns the current gps information (lat, lon, etc.).
Status mStatus
Connection status.
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:53
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:198
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_END
Definition qgis_sip.h:215