QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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:
61
63
65
67
69
71
72#ifndef SIP_RUN
75
78#endif
79
85 QgsGpsLogger( QgsGpsConnection *connection, QObject *parent SIP_TRANSFERTHIS = nullptr );
86
87 ~QgsGpsLogger() override;
88
95
102
106 void setEllipsoid( const QString &ellipsoid );
107
114 virtual void setTransformContext( const QgsCoordinateTransformContext &context );
115
123
128 const QgsDistanceArea &distanceArea() const;
129
135 QVector<QgsPoint> currentTrack() const;
136
147 QgsGeometry currentGeometry( Qgis::WkbType type, QString &error SIP_OUT ) const;
148
154 QgsPointXY lastPosition() const;
155
162 QDateTime lastTimestamp() const;
163
170 QDateTime trackStartTime() const;
171
175 double lastElevation() const;
176
180 double lastMValue() const;
181
185 void resetTrack();
186
194
201 void setAutomaticallyAddTrackVertices( bool enabled );
202
206 void updateGpsSettings();
207
213 double totalTrackLength() const;
214
220 double trackDistanceFromStart() const;
221
225 QVariant componentValue( Qgis::GpsInformationComponent component ) const;
226
227 signals:
228
232 void trackIsEmptyChanged( bool isEmpty );
233
238
244 void trackVertexAdded( const QgsPoint &vertex );
245
249 void stateChanged( const QgsGpsInformation &info );
250
255
256 protected:
259
261 mutable int mBlockGpsStateChanged = 0;
262
266 void addTrackVertex();
267
268 private slots:
269
270 void switchAcquisition();
271 void gpsStateChanged( const QgsGpsInformation &info );
272
273 private:
274 QPointer< QgsGpsConnection > mConnection;
275
276 QgsDistanceArea mDistanceCalculator;
277
278 QgsCoordinateTransformContext mTransformContext;
279
280 QgsPointXY mLastGpsPositionWgs84;
281 double mLastElevation = 0.0;
282
283 nmeaPOS mLastNmeaPosition;
284 QDateTime mLastTime;
285
286 QDateTime mPreviousTrackPointTime;
287 QgsPointXY mPreviousTrackPoint;
288
289 QDateTime mTrackStartTime;
290
291 QVector<QgsPoint> mCaptureListWgs84;
292
293 std::unique_ptr<QTimer> mAcquisitionTimer;
294 bool mAcquisitionEnabled = true;
295 int mAcquisitionInterval = 0;
296 double mDistanceThreshold = 0;
297
298 bool mApplyLeapSettings = false;
299 int mLeapSeconds = 0;
300 Qt::TimeSpec mTimeStampSpec = Qt::TimeSpec::LocalTime;
301 QString mTimeZone;
302 int mOffsetFromUtc = 0;
303
304 bool mAutomaticallyAddTrackVertices = true;
305 bool mStoreAttributeInMValues = false;
307 double mLastMValue = std::numeric_limits<double>::quiet_NaN();
308
310};
311
312
313#endif // QGSGPSLOGGER_H
GpsInformationComponent
GPS information component.
Definition qgis.h:2035
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:294
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:62
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_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_OUT
Definition qgis_sip.h:57