Class: QgsGpsLogger

class qgis.core.QgsGpsLogger

Bases: PyQt5.QtCore.QObject

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.

New in version 3.30.

QgsGpsLogger(connection: QgsGpsConnection, parent: QObject = None) Constructor for QgsGpsLogger with the specified parent object.

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

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.

childEvent

componentValue

Returns the value of the corresponding GPS information component.

connectNotify

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.

customEvent

disconnectNotify

distanceArea

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

isSignalConnected

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.

receivers

resetTrack

Resets the current track, discarding all recorded points.

sender

senderSignalIndex

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.

setTransformContext

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

timerEvent

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.

Signals

distanceAreaChanged

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

stateChanged

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

trackIsEmptyChanged

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

trackReset

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

trackVertexAdded

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

addTrackVertex(self)

Adds a track vertex at the current GPS location.

automaticallyAddTrackVertices(self) bool

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

Return type:

bool

childEvent(self, QChildEvent)
componentValue(self, component: Qgis.GpsInformationComponent) Any

Returns the value of the corresponding GPS information component.

Parameters:

component (Qgis.GpsInformationComponent) –

Return type:

Any

connectNotify(self, QMetaMethod)
connection(self) QgsGpsConnection

Returns the associated GPS connection.

See also

setConnection()

Return type:

QgsGpsConnection

currentGeometry(self, type: Qgis.WkbType) Tuple[QgsGeometry, str]

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) – desired geometry type

Return type:

Tuple[QgsGeometry, str]

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]

customEvent(self, QEvent)
disconnectNotify(self, QMetaMethod)
distanceArea(self) QgsDistanceArea

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

Return type:

QgsDistanceArea

distanceAreaChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

isSignalConnected(self, QMetaMethod) bool
lastElevation(self) float

Returns the last recorded elevation the device.

Return type:

float

lastMValue(self) float

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

Return type:

float

lastPosition(self) QgsPointXY

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

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

receivers(self, PYQT_SIGNAL) int
resetTrack(self)

Resets the current track, discarding all recorded points.

sender(self) QObject
senderSignalIndex(self) int
setAutomaticallyAddTrackVertices(self, enabled: bool)

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

Parameters:

enabled (bool) –

setConnection(self, connection: QgsGpsConnection)

Sets the associated GPS connection.

See also

connection()

Parameters:

connection (QgsGpsConnection) –

setEllipsoid(self, ellipsoid: str)

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

Parameters:

ellipsoid (str) –

setTransformContext(self, context: QgsCoordinateTransformContext)

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

Parameters:

context (QgsCoordinateTransformContext) –

stateChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

timerEvent(self, QTimerEvent)
totalTrackLength(self) float

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

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

trackIsEmptyChanged

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

trackReset

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

trackStartTime(self) QDateTime

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

trackVertexAdded

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

transformContext(self) QgsCoordinateTransformContext

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

Return type:

QgsCoordinateTransformContext

updateGpsSettings(self)

Should be called whenever the QGIS GPS settings are changed.