QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsgpslogger.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsgpslogger.h
3 -------------------
4 begin : November 2022
5 copyright : (C) 2022 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSGPSLOGGER_H
17#define QGSGPSLOGGER_H
18
19#include "qgis_core.h"
20#include "qgis.h"
21#include "qgis_sip.h"
23#include "qgsdistancearea.h"
25#include "qgswkbtypes.h"
26
27#include <QObject>
28#include <QPointer>
29#include <QDateTime>
30#include "info.h"
31
36template<class T> class QgsSettingsEntryEnumFlag;
37
38
41
42class QTimer;
43
44
55class CORE_EXPORT QgsGpsLogger : public QObject
56{
57 Q_OBJECT
58
59 public:
60
61 static const QgsSettingsEntryBool *settingsApplyLeapSeconds SIP_SKIP;
62
63 static const QgsSettingsEntryString *settingsTimestampTimeZone SIP_SKIP;
64
65 static const QgsSettingsEntryInteger *settingsTimeStampFormat SIP_SKIP;
66
67 static const QgsSettingsEntryInteger *settingsLeapSecondsCorrection SIP_SKIP;
68
69 static const QgsSettingsEntryInteger *settingsAcquisitionInterval SIP_SKIP;
70
71 static const QgsSettingsEntryDouble *settingsDistanceThreshold SIP_SKIP;
72
73#ifndef SIP_RUN
76
79#endif
80
86 QgsGpsLogger( QgsGpsConnection *connection, QObject *parent SIP_TRANSFERTHIS = nullptr );
87
88 ~QgsGpsLogger() override;
89
95 QgsGpsConnection *connection();
96
102 void setConnection( QgsGpsConnection *connection );
103
107 void setEllipsoid( const QString &ellipsoid );
108
115 virtual void setTransformContext( const QgsCoordinateTransformContext &context );
116
123 QgsCoordinateTransformContext transformContext() const;
124
129 const QgsDistanceArea &distanceArea() const;
130
136 QVector<QgsPoint> currentTrack() const;
137
148 QgsGeometry currentGeometry( Qgis::WkbType type, QString &error SIP_OUT ) const;
149
155 QgsPointXY lastPosition() const;
156
163 QDateTime lastTimestamp() const;
164
171 QDateTime trackStartTime() const;
172
176 double lastElevation() const;
177
181 double lastMValue() const;
182
186 void resetTrack();
187
194 bool automaticallyAddTrackVertices() const;
195
202 void setAutomaticallyAddTrackVertices( bool enabled );
203
207 void updateGpsSettings();
208
214 double totalTrackLength() const;
215
221 double trackDistanceFromStart() const;
222
226 QVariant componentValue( Qgis::GpsInformationComponent component ) const;
227
228 signals:
229
233 void trackIsEmptyChanged( bool isEmpty );
234
239
245 void trackVertexAdded( const QgsPoint &vertex );
246
250 void stateChanged( const QgsGpsInformation &info );
251
256
257 protected:
258
261
263 mutable int mBlockGpsStateChanged = 0;
264
268 void addTrackVertex();
269
270 private slots:
271
272 void switchAcquisition();
273 void gpsStateChanged( const QgsGpsInformation &info );
274
275 private:
276
277 QPointer< QgsGpsConnection > mConnection;
278
279 QgsDistanceArea mDistanceCalculator;
280
281 QgsCoordinateTransformContext mTransformContext;
282
283 QgsPointXY mLastGpsPositionWgs84;
284 double mLastElevation = 0.0;
285
286 nmeaPOS mLastNmeaPosition;
287 QDateTime mLastTime;
288
289 QDateTime mPreviousTrackPointTime;
290 QgsPointXY mPreviousTrackPoint;
291
292 QDateTime mTrackStartTime;
293
294 QVector<QgsPoint> mCaptureListWgs84;
295
296 std::unique_ptr<QTimer> mAcquisitionTimer;
297 bool mAcquisitionEnabled = true;
298 int mAcquisitionInterval = 0;
299 double mDistanceThreshold = 0;
300
301 bool mApplyLeapSettings = false;
302 int mLeapSeconds = 0;
303 Qt::TimeSpec mTimeStampSpec = Qt::TimeSpec::LocalTime;
304 QString mTimeZone;
305 int mOffsetFromUtc = 0;
306
307 bool mAutomaticallyAddTrackVertices = true;
308 bool mStoreAttributeInMValues = false;
310 double mLastMValue = std::numeric_limits<double>::quiet_NaN();
311
312 friend class TestQgsGpsIntegration;
313
314};
315
316
317#endif // QGSGPSLOGGER_H
GpsInformationComponent
GPS information component.
Definition: qgis.h:1529
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition: qgis.h:182
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:162
Abstract base class for connection to a GPS device.
Encapsulates information relating to a GPS position fix.
Base class for objects which log incoming GPS data.
Definition: qgsgpslogger.h:56
static const QgsSettingsEntryBool * settingsGpsStoreAttributeInMValues
Settings entry for whether storing GPS attributes as geometry M values should be enabled.
Definition: qgsgpslogger.h:75
void stateChanged(const QgsGpsInformation &info)
Emitted whenever the associated GPS device state is changed.
static const QgsSettingsEntryEnumFlag< Qgis::GpsInformationComponent > * settingsGpsMValueComponent
Settings entry dictating which GPS attribute should be stored in geometry M values.
Definition: qgsgpslogger.h:78
QgsCoordinateReferenceSystem mWgs84CRS
WGS84 coordinate reference system.
Definition: qgsgpslogger.h:260
void trackIsEmptyChanged(bool isEmpty)
Emitted whenever the current track changes from being empty to non-empty or vice versa.
void trackReset()
Emitted whenever the current track is reset.
void distanceAreaChanged()
Emitted whenever the distance area used to calculate track distances is changed.
void trackVertexAdded(const QgsPoint &vertex)
Emitted whenever a new vertex is added to the track.
A class to represent a 2D point.
Definition: qgspointxy.h:60
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_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_OUT
Definition: qgis_sip.h:58