Class: QgsGpsLogger

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.

Added in version 3.30.

Class Hierarchy

Inheritance diagram of qgis.core.QgsGpsLogger

Base classes

QObject

Subclasses

QgsVectorLayerGpsLogger

Handles logging of incoming GPS data to a vector layer.

Methods

addTrackVertex

Adds a track vertex at the current GPS location.

automaticallyAddTrackVertices

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

componentValue

Returns the value of the corresponding GPS information component.

connection

Returns the associated GPS connection.

currentGeometry

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

currentTrack

Returns the recorded points in the current track.

distanceArea

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

lastElevation

Returns the last recorded elevation the device.

lastMValue

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

lastPosition

Returns the last recorded position of the device.

lastTimestamp

Returns the last recorded timestamp from the device.

resetTrack

Resets the current track, discarding all recorded points.

setAutomaticallyAddTrackVertices

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

setConnection

Sets the associated GPS connection.

setEllipsoid

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

totalTrackLength

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

trackDistanceFromStart

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

trackStartTime

Returns the timestamp at which the current track was started.

transformContext

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

updateGpsSettings

Should be called whenever the QGIS GPS settings are changed.

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsGpsLogger. See the FAQ for more details.

setTransformContext

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

Signals

distanceAreaChanged

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

stateChanged

Emitted whenever the associated GPS device state is changed.

trackIsEmptyChanged

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

trackReset

Emitted whenever the current track is reset.

trackVertexAdded

Emitted whenever a new vertex is added to the track.

class qgis.core.QgsGpsLogger[source]

Bases: QObject

__init__(connection: QgsGpsConnection | None, parent: QObject | None = None)

Constructor for QgsGpsLogger with the specified parent object.

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

Parameters:
addTrackVertex(self)[source]

Adds a track vertex at the current GPS location.

automaticallyAddTrackVertices(self) bool[source]

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

Return type:

bool

componentValue(self, component: Qgis.GpsInformationComponent) Any[source]

Returns the value of the corresponding GPS information component.

Parameters:

component (Qgis.GpsInformationComponent)

Return type:

Any

connection(self) QgsGpsConnection | None[source]

Returns the associated GPS connection.

See also

setConnection()

Return type:

Optional[QgsGpsConnection]

currentGeometry(self, type: Qgis.WkbType)[source]

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:

type (Qgis.WkbType) -> (QgsGeometry) – desired geometry type

Returns:

  • logged GPS positions as a geometry.

  • error: Will be set to a user-friendly error if the logged positions could not be converted to an appropriate geometry

currentTrack(self) List[QgsPoint]

Returns the recorded points in the current track.

These points will always be in WGS84 coordinate reference system.

Return type:

List[QgsPoint]

distanceArea(self) QgsDistanceArea

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

Return type:

QgsDistanceArea

signal distanceAreaChanged[source]

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

lastElevation(self) float[source]

Returns the last recorded elevation the device.

Return type:

float

lastMValue(self) float[source]

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

Return type:

float

lastPosition(self) QgsPointXY[source]

Returns the last recorded position of the device.

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

Return type:

QgsPointXY

lastTimestamp(self) QDateTime[source]

Returns the last recorded timestamp from the device.

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

Return type:

QDateTime

resetTrack(self)[source]

Resets the current track, discarding all recorded points.

setAutomaticallyAddTrackVertices(self, enabled: bool)[source]

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

Parameters:

enabled (bool)

setConnection(self, connection: QgsGpsConnection | None)[source]

Sets the associated GPS connection.

See also

connection()

Parameters:

connection (Optional[QgsGpsConnection])

setEllipsoid(self, ellipsoid: str | None)[source]

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

Parameters:

ellipsoid (Optional[str])

virtual setTransformContext(self, context: QgsCoordinateTransformContext)[source]

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

Parameters:

context (QgsCoordinateTransformContext)

signal stateChanged(info: QgsGpsInformation)[source]

Emitted whenever the associated GPS device state is changed.

Parameters:

info (QgsGpsInformation)

totalTrackLength(self) float[source]

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

The returned length is calculated using ellipsoidal calculations.

Return type:

float

trackDistanceFromStart(self) float[source]

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

The returned length is calculated using ellipsoidal calculations.

Return type:

float

signal trackIsEmptyChanged(isEmpty: bool)[source]

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

Parameters:

isEmpty (bool)

signal trackReset[source]

Emitted whenever the current track is reset.

trackStartTime(self) QDateTime[source]

Returns the timestamp at which the current track was started.

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

Return type:

QDateTime

signal trackVertexAdded(vertex: QgsPoint)[source]

Emitted whenever a new vertex is added to the track.

The vertex point will be in WGS84 coordinate reference system.

Parameters:

vertex (QgsPoint)

transformContext(self) QgsCoordinateTransformContext[source]

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

Return type:

QgsCoordinateTransformContext

updateGpsSettings(self)[source]

Should be called whenever the QGIS GPS settings are changed.