QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
Signals | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
QgsGpsLogger Class Reference

Base class for objects which log incoming GPS data. More...

#include <qgsgpslogger.h>

Inheritance diagram for QgsGpsLogger:
Inheritance graph
[legend]

Signals

void distanceAreaChanged ()
 Emitted whenever the distance area used to calculate track distances is changed.
 
void stateChanged (const QgsGpsInformation &info)
 Emitted whenever the associated GPS device state is changed.
 
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 trackVertexAdded (const QgsPoint &vertex)
 Emitted whenever a new vertex is added to the track.
 

Public Member Functions

 QgsGpsLogger (QgsGpsConnection *connection, QObject *parent=nullptr)
 Constructor for QgsGpsLogger with the specified parent object.
 
 ~QgsGpsLogger () override
 
bool automaticallyAddTrackVertices () const
 Returns true if track vertices will be automatically added whenever the GPS position is changed.
 
QVariant componentValue (Qgis::GpsInformationComponent component) const
 Returns the value of the corresponding GPS information component.
 
QgsGpsConnectionconnection ()
 Returns the associated GPS connection.
 
QgsGeometry currentGeometry (Qgis::WkbType type, QString &error) const
 Returns the current logged GPS positions as a geometry of the specified type.
 
QVector< QgsPointcurrentTrack () const
 Returns the recorded points in the current track.
 
const QgsDistanceAreadistanceArea () const
 Returns the distance area calculator which should be used for calculating distances associated with the GPS log.
 
double lastElevation () const
 Returns the last recorded elevation the device.
 
double lastMValue () const
 Returns the last recorded value corresponding to the QgsGpsLogger::settingsGpsMValueComponent setting.
 
QgsPointXY lastPosition () const
 Returns the last recorded position of the device.
 
QDateTime lastTimestamp () const
 Returns the last recorded timestamp from the device.
 
void resetTrack ()
 Resets the current track, discarding all recorded points.
 
void setAutomaticallyAddTrackVertices (bool enabled)
 Sets whether track vertices will be automatically added whenever the GPS position is changed.
 
void setConnection (QgsGpsConnection *connection)
 Sets the associated GPS connection.
 
void setEllipsoid (const QString &ellipsoid)
 Sets the ellipsoid which will be used for calculating distances in the log.
 
virtual void setTransformContext (const QgsCoordinateTransformContext &context)
 Sets the coordinate transform context to be used when transforming GPS coordinates.
 
double totalTrackLength () const
 Returns the total length of the current digitized track (in meters).
 
double trackDistanceFromStart () const
 Returns the direct length from the first vertex in the track to the last (in meters).
 
QDateTime trackStartTime () const
 Returns the timestamp at which the current track was started.
 
QgsCoordinateTransformContext transformContext () const
 Returns the coordinate transform context to be used when transforming GPS coordinates.
 
void updateGpsSettings ()
 Should be called whenever the QGIS GPS settings are changed.
 

Static Public Attributes

static const QgsSettingsEntryIntegersettingsAcquisitionInterval = new QgsSettingsEntryInteger( QStringLiteral( "acquisitionInterval" ), QgsSettingsTree::sTreeGps, 0 )
 
static const QgsSettingsEntryBoolsettingsApplyLeapSeconds = new QgsSettingsEntryBool( QStringLiteral( "applyLeapSeconds" ), QgsSettingsTree::sTreeGps, true )
 
static const QgsSettingsEntryDoublesettingsDistanceThreshold = new QgsSettingsEntryDouble( QStringLiteral( "distanceThreshold" ), QgsSettingsTree::sTreeGps, 0 )
 
static const QgsSettingsEntryEnumFlag< Qgis::GpsInformationComponent > * settingsGpsMValueComponent = new QgsSettingsEntryEnumFlag<Qgis::GpsInformationComponent>( QStringLiteral( "m-value-attribute" ), QgsSettingsTree::sTreeGps, Qgis::GpsInformationComponent::Timestamp, QStringLiteral( "Which GPS attribute should be stored in geometry m values" ) )
 Settings entry dictating which GPS attribute should be stored in geometry M values.
 
static const QgsSettingsEntryBoolsettingsGpsStoreAttributeInMValues = new QgsSettingsEntryBool( QStringLiteral( "store-attribute-in-m-values" ), QgsSettingsTree::sTreeGps, false, QStringLiteral( "Whether GPS attributes should be stored in geometry m values" ) )
 Settings entry for whether storing GPS attributes as geometry M values should be enabled.
 
static const QgsSettingsEntryIntegersettingsLeapSecondsCorrection = new QgsSettingsEntryInteger( QStringLiteral( "leapSecondsCorrection" ), QgsSettingsTree::sTreeGps, 18 )
 
static const QgsSettingsEntryIntegersettingsTimeStampFormat = new QgsSettingsEntryInteger( QStringLiteral( "timeStampFormat" ), QgsSettingsTree::sTreeGps, Qt::LocalTime )
 
static const QgsSettingsEntryStringsettingsTimestampTimeZone = new QgsSettingsEntryString( QStringLiteral( "timestampTimeZone" ), QgsSettingsTree::sTreeGps, QString() )
 

Protected Member Functions

void addTrackVertex ()
 Adds a track vertex at the current GPS location.
 

Protected Attributes

int mBlockGpsStateChanged = 0
 Used to pause logging of incoming GPS messages.
 
QgsCoordinateReferenceSystem mWgs84CRS
 WGS84 coordinate reference system.
 

Friends

class TestQgsGpsIntegration
 

Detailed Description

Base class for objects which log incoming GPS data.

This class handles generic logic regarding logging GPS data, such as creation of tracks from incoming GPS location points.

Since
QGIS 3.30

Definition at line 55 of file qgsgpslogger.h.

Constructor & Destructor Documentation

◆ QgsGpsLogger()

QgsGpsLogger::QgsGpsLogger ( QgsGpsConnection connection,
QObject *  parent = nullptr 
)

Constructor for QgsGpsLogger with the specified parent object.

The logger will automatically record GPS information from the specified connection.

Definition at line 41 of file qgsgpslogger.cpp.

◆ ~QgsGpsLogger()

QgsGpsLogger::~QgsGpsLogger ( )
override

Definition at line 59 of file qgsgpslogger.cpp.

Member Function Documentation

◆ addTrackVertex()

void QgsGpsLogger::addTrackVertex ( )
protected

Adds a track vertex at the current GPS location.

Definition at line 430 of file qgsgpslogger.cpp.

◆ automaticallyAddTrackVertices()

bool QgsGpsLogger::automaticallyAddTrackVertices ( ) const

Returns true if track vertices will be automatically added whenever the GPS position is changed.

See also
setAutomaticallyAddTrackVertices()

Definition at line 451 of file qgsgpslogger.cpp.

◆ componentValue()

QVariant QgsGpsLogger::componentValue ( Qgis::GpsInformationComponent  component) const

Returns the value of the corresponding GPS information component.

Definition at line 281 of file qgsgpslogger.cpp.

◆ connection()

QgsGpsConnection * QgsGpsLogger::connection ( )

Returns the associated GPS connection.

See also
setConnection()

Definition at line 64 of file qgsgpslogger.cpp.

◆ currentGeometry()

QgsGeometry QgsGpsLogger::currentGeometry ( Qgis::WkbType  type,
QString &  error 
) const

Returns the current logged GPS positions as a geometry of the specified type.

The returned geometries will always be in the WGS84 (EPSG:4326) coordinate reference system.

Parameters
typedesired geometry type
errorWill be set to a user-friendly error if the logged positions could not be converted to an appropriate geometry
Returns
logged GPS positions as a geometry.

Definition at line 112 of file qgsgpslogger.cpp.

◆ currentTrack()

QVector< QgsPoint > QgsGpsLogger::currentTrack ( ) const

Returns the recorded points in the current track.

These points will always be in WGS84 coordinate reference system.

Definition at line 107 of file qgsgpslogger.cpp.

◆ distanceArea()

const QgsDistanceArea & QgsGpsLogger::distanceArea ( ) const

Returns the distance area calculator which should be used for calculating distances associated with the GPS log.

Definition at line 102 of file qgsgpslogger.cpp.

◆ distanceAreaChanged

void QgsGpsLogger::distanceAreaChanged ( )
signal

Emitted whenever the distance area used to calculate track distances is changed.

◆ lastElevation()

double QgsGpsLogger::lastElevation ( ) const

Returns the last recorded elevation the device.

Definition at line 193 of file qgsgpslogger.cpp.

◆ lastMValue()

double QgsGpsLogger::lastMValue ( ) const

Returns the last recorded value corresponding to the QgsGpsLogger::settingsGpsMValueComponent setting.

Definition at line 198 of file qgsgpslogger.cpp.

◆ lastPosition()

QgsPointXY QgsGpsLogger::lastPosition ( ) const

Returns the last recorded position of the device.

The returned point will always be in WGS84 coordinate reference system.

Definition at line 188 of file qgsgpslogger.cpp.

◆ lastTimestamp()

QDateTime QgsGpsLogger::lastTimestamp ( ) const

Returns the last recorded timestamp from the device.

The returned time value will respect all user settings regarding GPS time zone handling.

Definition at line 461 of file qgsgpslogger.cpp.

◆ resetTrack()

void QgsGpsLogger::resetTrack ( )

Resets the current track, discarding all recorded points.

Definition at line 203 of file qgsgpslogger.cpp.

◆ setAutomaticallyAddTrackVertices()

void QgsGpsLogger::setAutomaticallyAddTrackVertices ( bool  enabled)

Sets whether track vertices will be automatically added whenever the GPS position is changed.

See also
automaticallyAddTrackVertices()

Definition at line 456 of file qgsgpslogger.cpp.

◆ setConnection()

void QgsGpsLogger::setConnection ( QgsGpsConnection connection)

Sets the associated GPS connection.

See also
connection()

Definition at line 69 of file qgsgpslogger.cpp.

◆ setEllipsoid()

void QgsGpsLogger::setEllipsoid ( const QString &  ellipsoid)

Sets the ellipsoid which will be used for calculating distances in the log.

Definition at line 84 of file qgsgpslogger.cpp.

◆ setTransformContext()

void QgsGpsLogger::setTransformContext ( const QgsCoordinateTransformContext context)
virtual

Sets the coordinate transform context to be used when transforming GPS coordinates.

See also
transformContext()

Reimplemented in QgsVectorLayerGpsLogger.

Definition at line 90 of file qgsgpslogger.cpp.

◆ stateChanged

void QgsGpsLogger::stateChanged ( const QgsGpsInformation info)
signal

Emitted whenever the associated GPS device state is changed.

◆ totalTrackLength()

double QgsGpsLogger::totalTrackLength ( ) const

Returns the total length of the current digitized track (in meters).

The returned length is calculated using ellipsoidal calculations.

Definition at line 266 of file qgsgpslogger.cpp.

◆ trackDistanceFromStart()

double QgsGpsLogger::trackDistanceFromStart ( ) const

Returns the direct length from the first vertex in the track to the last (in meters).

The returned length is calculated using ellipsoidal calculations.

Definition at line 273 of file qgsgpslogger.cpp.

◆ trackIsEmptyChanged

void QgsGpsLogger::trackIsEmptyChanged ( bool  isEmpty)
signal

Emitted whenever the current track changes from being empty to non-empty or vice versa.

◆ trackReset

void QgsGpsLogger::trackReset ( )
signal

Emitted whenever the current track is reset.

◆ trackStartTime()

QDateTime QgsGpsLogger::trackStartTime ( ) const

Returns the timestamp at which the current track was started.

The returned time value will respect all user settings regarding GPS time zone handling.

Definition at line 504 of file qgsgpslogger.cpp.

◆ trackVertexAdded

void QgsGpsLogger::trackVertexAdded ( const QgsPoint vertex)
signal

Emitted whenever a new vertex is added to the track.

The vertex point will be in WGS84 coordinate reference system.

◆ transformContext()

QgsCoordinateTransformContext QgsGpsLogger::transformContext ( ) const

Returns the coordinate transform context to be used when transforming GPS coordinates.

See also
setTransformContext()

Definition at line 97 of file qgsgpslogger.cpp.

◆ updateGpsSettings()

void QgsGpsLogger::updateGpsSettings ( )

Should be called whenever the QGIS GPS settings are changed.

Definition at line 218 of file qgsgpslogger.cpp.

Friends And Related Symbol Documentation

◆ TestQgsGpsIntegration

friend class TestQgsGpsIntegration
friend

Definition at line 312 of file qgsgpslogger.h.

Member Data Documentation

◆ mBlockGpsStateChanged

int QgsGpsLogger::mBlockGpsStateChanged = 0
mutableprotected

Used to pause logging of incoming GPS messages.

Definition at line 263 of file qgsgpslogger.h.

◆ mWgs84CRS

QgsCoordinateReferenceSystem QgsGpsLogger::mWgs84CRS
protected

WGS84 coordinate reference system.

Definition at line 260 of file qgsgpslogger.h.

◆ settingsAcquisitionInterval

const QgsSettingsEntryInteger * QgsGpsLogger::settingsAcquisitionInterval = new QgsSettingsEntryInteger( QStringLiteral( "acquisitionInterval" ), QgsSettingsTree::sTreeGps, 0 )
static

Definition at line 69 of file qgsgpslogger.h.

◆ settingsApplyLeapSeconds

const QgsSettingsEntryBool * QgsGpsLogger::settingsApplyLeapSeconds = new QgsSettingsEntryBool( QStringLiteral( "applyLeapSeconds" ), QgsSettingsTree::sTreeGps, true )
static

Definition at line 61 of file qgsgpslogger.h.

◆ settingsDistanceThreshold

const QgsSettingsEntryDouble * QgsGpsLogger::settingsDistanceThreshold = new QgsSettingsEntryDouble( QStringLiteral( "distanceThreshold" ), QgsSettingsTree::sTreeGps, 0 )
static

Definition at line 71 of file qgsgpslogger.h.

◆ settingsGpsMValueComponent

const QgsSettingsEntryEnumFlag< Qgis::GpsInformationComponent > * QgsGpsLogger::settingsGpsMValueComponent = new QgsSettingsEntryEnumFlag<Qgis::GpsInformationComponent>( QStringLiteral( "m-value-attribute" ), QgsSettingsTree::sTreeGps, Qgis::GpsInformationComponent::Timestamp, QStringLiteral( "Which GPS attribute should be stored in geometry m values" ) )
static

Settings entry dictating which GPS attribute should be stored in geometry M values.

Definition at line 78 of file qgsgpslogger.h.

◆ settingsGpsStoreAttributeInMValues

const QgsSettingsEntryBool * QgsGpsLogger::settingsGpsStoreAttributeInMValues = new QgsSettingsEntryBool( QStringLiteral( "store-attribute-in-m-values" ), QgsSettingsTree::sTreeGps, false, QStringLiteral( "Whether GPS attributes should be stored in geometry m values" ) )
static

Settings entry for whether storing GPS attributes as geometry M values should be enabled.

Definition at line 75 of file qgsgpslogger.h.

◆ settingsLeapSecondsCorrection

const QgsSettingsEntryInteger * QgsGpsLogger::settingsLeapSecondsCorrection = new QgsSettingsEntryInteger( QStringLiteral( "leapSecondsCorrection" ), QgsSettingsTree::sTreeGps, 18 )
static

Definition at line 67 of file qgsgpslogger.h.

◆ settingsTimeStampFormat

const QgsSettingsEntryInteger * QgsGpsLogger::settingsTimeStampFormat = new QgsSettingsEntryInteger( QStringLiteral( "timeStampFormat" ), QgsSettingsTree::sTreeGps, Qt::LocalTime )
static

Definition at line 65 of file qgsgpslogger.h.

◆ settingsTimestampTimeZone

const QgsSettingsEntryString * QgsGpsLogger::settingsTimestampTimeZone = new QgsSettingsEntryString( QStringLiteral( "timestampTimeZone" ), QgsSettingsTree::sTreeGps, QString() )
static

Definition at line 63 of file qgsgpslogger.h.


The documentation for this class was generated from the following files: