QgsQuickPositionKit class

Convenient set of tools to read GPS position and accuracy.

Also, if one can use use_simulated_location to specify simulated position. Simulated position source generates random points in circles around the selected point and radius. Real GPS position is not used in this mode.

Constructors, destructors, conversion operators

QgsQuickPositionKit(QObject* parent = nullptr) explicit
Creates new position kit.

Public functions

auto accuracy() const -> double
GPS horizontal accuracy in accuracyUnits, -1 if not available.
auto accuracyUnits() const -> QgsUnitTypes::DistanceUnit
GPS horizontal accuracy units - meters (constant)
auto direction() const -> double
GPS direction, bearing in degrees clockwise from north to direction of travel.
auto hasPosition() const -> bool
GPS position in WGS84 coords.
auto isSimulated() const -> bool
GPS position and accuracy is simulated (not real from GPS sensor).
auto mapSettings() const -> QgsQuickMapSettings*
Associated map settings.
auto position() const -> QgsPoint
GPS position in WGS84 coords.
auto positionCRS() const -> Q_INVOKABLE QgsCoordinateReferenceSystem
Coordinate reference system of position - WGS84 (constant)
auto projectedPosition() const -> QgsPoint
GPS position in map coords.
auto screenAccuracy() const -> double
Screen horizontal accuracy, 2 if not available or resolution is too small.
auto screenPosition() const -> QPointF
GPS position in device coords (pixels).
void setMapSettings(QgsQuickMapSettings* mapSettings)
Associated map settings.
void setSimulatePositionLongLatRad(const QVector<double>& simulatePositionLongLatRad)
Uses of GPS and simulated position and sets its parameters.
auto simulatePositionLongLatRad() const -> QVector<double>
Uses of GPS and simulated position and sets its parameters.
auto source() const -> QGeoPositionInfoSource*
Returns pointer to the internal QGeoPositionInfoSource object used to receive GPS location.
auto useGpsLocation() -> Q_INVOKABLE void
Use real GPS source (not simulated)
auto useSimulatedLocation(double longitude, double latitude, double radius) -> Q_INVOKABLE void
Use simulated GPS source.

Signals

auto accuracyChanged() const -> double
GPS horizontal accuracy in accuracyUnits, -1 if not available.
auto accuracyUnitsChanged() const -> Q_INVOKABLE QString
GPS horizontal accuracy units - meters (constant)
auto directionChanged() const -> double
GPS direction, bearing in degrees clockwise from north to direction of travel.
void hasPositionChanged()
hasPosition changed
void isSimulatedChanged()
GPS position and accuracy is simulated (not real from GPS sensor).
void mapSettingsChanged()
Associated map settings.
void positionChanged()
GPS position in WGS84 coords.
void projectedPositionChanged()
GPS position in map coords.
auto screenAccuracyChanged() const -> double
Screen horizontal accuracy, 2 if not available or resolution is too small.
void screenPositionChanged()
GPS position in device coords (pixels).
void simulatePositionLongLatRadChanged(QVector<double> simulatePositionLongLatRad)
Uses of GPS and simulated position and sets its parameters.
void sourceChanged()
Emitted when the internal source of GPS location data has been replaced.

Function documentation

double QgsQuickPositionKit::accuracy() const

GPS horizontal accuracy in accuracyUnits, -1 if not available.

This is a readonly property.

double QgsQuickPositionKit::direction() const

GPS direction, bearing in degrees clockwise from north to direction of travel.

-1 if not available

This is a readonly property.

bool QgsQuickPositionKit::hasPosition() const

GPS position in WGS84 coords.

This is a readonly property.

bool QgsQuickPositionKit::isSimulated() const

GPS position and accuracy is simulated (not real from GPS sensor).

Default false (use real GPS)

This is a readonly property. To change to simulated position, see QgsQuickPositionKit::simulatePositionLongLatRad

QgsQuickMapSettings* QgsQuickPositionKit::mapSettings() const

Associated map settings.

Should be initialized before the first use from mapcanvas map settings.

This is a readonly property.

QgsPoint QgsQuickPositionKit::position() const

GPS position in WGS84 coords.

This is a readonly property.

QgsPoint QgsQuickPositionKit::projectedPosition() const

GPS position in map coords.

This is a readonly property.

double QgsQuickPositionKit::screenAccuracy() const

Screen horizontal accuracy, 2 if not available or resolution is too small.

This is a readonly property.

QPointF QgsQuickPositionKit::screenPosition() const

GPS position in device coords (pixels).

This is a readonly property.

void QgsQuickPositionKit::setMapSettings(QgsQuickMapSettings* mapSettings)

Associated map settings.

Should be initialized before the first use from mapcanvas map settings.

This is a readonly property.

void QgsQuickPositionKit::setSimulatePositionLongLatRad(const QVector<double>& simulatePositionLongLatRad)

Uses of GPS and simulated position and sets its parameters.

Vector containing longitude, latitude and radius (meters) of simulated position e.g. [-97.36, 36.93, 2] If empty vector is assigned, GPS source will be used.

From QML context, also functions useSimulatedLocation() or useGpsLocation() could be used instead

QVector<double> QgsQuickPositionKit::simulatePositionLongLatRad() const

Uses of GPS and simulated position and sets its parameters.

Vector containing longitude, latitude and radius (meters) of simulated position e.g. [-97.36, 36.93, 2] If empty vector is assigned, GPS source will be used.

From QML context, also functions useSimulatedLocation() or useGpsLocation() could be used instead

QGeoPositionInfoSource* QgsQuickPositionKit::source() const

Returns pointer to the internal QGeoPositionInfoSource object used to receive GPS location.

Q_INVOKABLE void QgsQuickPositionKit::useSimulatedLocation(double longitude, double latitude, double radius)

Use simulated GPS source.

Parameters
longitude longitude of the centre of the emulated points
latitude latitude of the centre of the emulated points
radius distance of emulated points from the centre (in degrees WSG84)

Simulated GPS source emulates point on circle around defined point in specified radius

We do not want to have the origin point as property We basically want to set it once based on project/map cente and keep it that way regardless of mapsettings change (e.g. zoom etc)

double QgsQuickPositionKit::accuracyChanged() const signal

GPS horizontal accuracy in accuracyUnits, -1 if not available.

This is a readonly property.

double QgsQuickPositionKit::directionChanged() const signal

GPS direction, bearing in degrees clockwise from north to direction of travel.

-1 if not available

This is a readonly property.

void QgsQuickPositionKit::isSimulatedChanged() signal

GPS position and accuracy is simulated (not real from GPS sensor).

Default false (use real GPS)

This is a readonly property. To change to simulated position, see QgsQuickPositionKit::simulatePositionLongLatRad

void QgsQuickPositionKit::mapSettingsChanged() signal

Associated map settings.

Should be initialized before the first use from mapcanvas map settings.

This is a readonly property.

void QgsQuickPositionKit::positionChanged() signal

GPS position in WGS84 coords.

This is a readonly property.

void QgsQuickPositionKit::projectedPositionChanged() signal

GPS position in map coords.

This is a readonly property.

double QgsQuickPositionKit::screenAccuracyChanged() const signal

Screen horizontal accuracy, 2 if not available or resolution is too small.

This is a readonly property.

void QgsQuickPositionKit::screenPositionChanged() signal

GPS position in device coords (pixels).

This is a readonly property.

void QgsQuickPositionKit::simulatePositionLongLatRadChanged(QVector<double> simulatePositionLongLatRad) signal

Uses of GPS and simulated position and sets its parameters.

Vector containing longitude, latitude and radius (meters) of simulated position e.g. [-97.36, 36.93, 2] If empty vector is assigned, GPS source will be used.

From QML context, also functions useSimulatedLocation() or useGpsLocation() could be used instead