QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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 "info.h"
20#include "qgis.h"
21#include "qgis_core.h"
22#include "qgis_sip.h"
25#include "qgsdistancearea.h"
26#include "qgswkbtypes.h"
27
28#include <QDateTime>
29#include <QObject>
30#include <QPointer>
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
62
64
66
68
70
72
73#ifndef SIP_RUN
76
79#endif
80
86 QgsGpsLogger( QgsGpsConnection *connection, QObject *parent SIP_TRANSFERTHIS = nullptr );
87
88 ~QgsGpsLogger() override;
89
96
103
107 void setEllipsoid( const QString &ellipsoid );
108
115 virtual void setTransformContext( const QgsCoordinateTransformContext &context );
116
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
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
313
314};
315
316
317#endif // QGSGPSLOGGER_H
GpsInformationComponent
GPS information component.
Definition qgis.h:1956
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:277
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.
Abstract base class for connections to a GPS device.
Encapsulates information relating to a GPS position fix.
static const QgsSettingsEntryBool * settingsGpsStoreAttributeInMValues
Settings entry for whether storing GPS attributes as geometry M values should be enabled.
virtual void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context to be used when transforming GPS coordinates.
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.
double lastElevation() const
Returns the last recorded elevation the device.
static const QgsSettingsEntryInteger * settingsTimeStampFormat
QgsGpsLogger(QgsGpsConnection *connection, QObject *parent=nullptr)
Constructor for QgsGpsLogger with the specified parent object.
QgsCoordinateReferenceSystem mWgs84CRS
WGS84 coordinate reference system.
static const QgsSettingsEntryInteger * settingsLeapSecondsCorrection
int mBlockGpsStateChanged
Used to pause logging of incoming GPS messages.
static const QgsSettingsEntryBool * settingsApplyLeapSeconds
QgsGeometry currentGeometry(Qgis::WkbType type, QString &error) const
Returns the current logged GPS positions as a geometry of the specified type.
const QgsDistanceArea & distanceArea() const
Returns the distance area calculator which should be used for calculating distances associated with t...
QVector< QgsPoint > currentTrack() const
Returns the recorded points in the current track.
bool automaticallyAddTrackVertices() const
Returns true if track vertices will be automatically added whenever the GPS position is changed.
void trackIsEmptyChanged(bool isEmpty)
Emitted whenever the current track changes from being empty to non-empty or vice versa.
friend class TestQgsGpsIntegration
QDateTime trackStartTime() const
Returns the timestamp at which the current track was started.
static const QgsSettingsEntryDouble * settingsDistanceThreshold
void updateGpsSettings()
Should be called whenever the QGIS GPS settings are changed.
void trackReset()
Emitted whenever the current track is reset.
void resetTrack()
Resets the current track, discarding all recorded points.
QDateTime lastTimestamp() const
Returns the last recorded timestamp from the device.
void setAutomaticallyAddTrackVertices(bool enabled)
Sets whether track vertices will be automatically added whenever the GPS position is changed.
void addTrackVertex()
Adds a track vertex at the current GPS location.
double lastMValue() const
Returns the last recorded value corresponding to the QgsGpsLogger::settingsGpsMValueComponent setting...
double trackDistanceFromStart() const
Returns the direct length from the first vertex in the track to the last (in meters).
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context to be used when transforming GPS coordinates.
void setConnection(QgsGpsConnection *connection)
Sets the associated GPS connection.
void distanceAreaChanged()
Emitted whenever the distance area used to calculate track distances is changed.
QgsGpsConnection * connection()
Returns the associated GPS connection.
static const QgsSettingsEntryString * settingsTimestampTimeZone
double totalTrackLength() const
Returns the total length of the current digitized track (in meters).
void setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid which will be used for calculating distances in the log.
static const QgsSettingsEntryInteger * settingsAcquisitionInterval
QVariant componentValue(Qgis::GpsInformationComponent component) const
Returns the value of the corresponding GPS information component.
void trackVertexAdded(const QgsPoint &vertex)
Emitted whenever a new vertex is added to the track.
QgsPointXY lastPosition() const
Returns the last recorded position of the device.
Represents 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:134
#define SIP_OUT
Definition qgis_sip.h:58