Skip to content

Commit

Permalink
Add more GPS component flags
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 14, 2022
1 parent 7c4cb30 commit b572e54
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 5 deletions.
16 changes: 13 additions & 3 deletions python/core/auto_additions/qgis.py
Expand Up @@ -905,9 +905,19 @@
Qgis.GpsInformationComponent.Altitude.__doc__ = "Altitude/elevation above or below the mean sea level"
Qgis.GpsInformationComponent.GroundSpeed.__doc__ = "Ground speed"
Qgis.GpsInformationComponent.Bearing.__doc__ = "Bearing measured in degrees clockwise from true north to the direction of travel"
Qgis.GpsInformationComponent.TotalTrackLength.__doc__ = "Total distance of current GPS track (available from QGIS app library only)"
Qgis.GpsInformationComponent.TrackDistanceFromStart.__doc__ = "Direct distance from first vertex in current GPS track to last vertex (available from QGIS app library only)"
Qgis.GpsInformationComponent.__doc__ = 'GPS information component.\n\n.. versionadded:: 3.30\n\n' + '* ``Location``: ' + Qgis.GpsInformationComponent.Location.__doc__ + '\n' + '* ``Altitude``: ' + Qgis.GpsInformationComponent.Altitude.__doc__ + '\n' + '* ``GroundSpeed``: ' + Qgis.GpsInformationComponent.GroundSpeed.__doc__ + '\n' + '* ``Bearing``: ' + Qgis.GpsInformationComponent.Bearing.__doc__ + '\n' + '* ``TotalTrackLength``: ' + Qgis.GpsInformationComponent.TotalTrackLength.__doc__ + '\n' + '* ``TrackDistanceFromStart``: ' + Qgis.GpsInformationComponent.TrackDistanceFromStart.__doc__
Qgis.GpsInformationComponent.TotalTrackLength.__doc__ = "Total distance of current GPS track (available from QgsGpsLogger class only)"
Qgis.GpsInformationComponent.TrackDistanceFromStart.__doc__ = "Direct distance from first vertex in current GPS track to last vertex (available from QgsGpsLogger class only)"
Qgis.GpsInformationComponent.Pdop.__doc__ = "Dilution of precision"
Qgis.GpsInformationComponent.Hdop.__doc__ = "Horizontal dilution of precision"
Qgis.GpsInformationComponent.Vdop.__doc__ = "Vertical dilution of precision"
Qgis.GpsInformationComponent.HorizontalAccuracy.__doc__ = "Horizontal accuracy in meters"
Qgis.GpsInformationComponent.VerticalAccuracy.__doc__ = "Vertical accuracy in meters"
Qgis.GpsInformationComponent.HvAccuracy.__doc__ = "3D RMS"
Qgis.GpsInformationComponent.SatellitesUsed.__doc__ = "Count of satellites used in obtaining the fix"
Qgis.GpsInformationComponent.Timestamp.__doc__ = "Timestamp"
Qgis.GpsInformationComponent.TrackStartTime.__doc__ = "Timestamp at start of current track (available from QgsGpsLogger class only)"
Qgis.GpsInformationComponent.TrackEndTime.__doc__ = "Timestamp at end (current point) of current track (available from QgsGpsLogger class only)"
Qgis.GpsInformationComponent.__doc__ = 'GPS information component.\n\n.. versionadded:: 3.30\n\n' + '* ``Location``: ' + Qgis.GpsInformationComponent.Location.__doc__ + '\n' + '* ``Altitude``: ' + Qgis.GpsInformationComponent.Altitude.__doc__ + '\n' + '* ``GroundSpeed``: ' + Qgis.GpsInformationComponent.GroundSpeed.__doc__ + '\n' + '* ``Bearing``: ' + Qgis.GpsInformationComponent.Bearing.__doc__ + '\n' + '* ``TotalTrackLength``: ' + Qgis.GpsInformationComponent.TotalTrackLength.__doc__ + '\n' + '* ``TrackDistanceFromStart``: ' + Qgis.GpsInformationComponent.TrackDistanceFromStart.__doc__ + '\n' + '* ``Pdop``: ' + Qgis.GpsInformationComponent.Pdop.__doc__ + '\n' + '* ``Hdop``: ' + Qgis.GpsInformationComponent.Hdop.__doc__ + '\n' + '* ``Vdop``: ' + Qgis.GpsInformationComponent.Vdop.__doc__ + '\n' + '* ``HorizontalAccuracy``: ' + Qgis.GpsInformationComponent.HorizontalAccuracy.__doc__ + '\n' + '* ``VerticalAccuracy``: ' + Qgis.GpsInformationComponent.VerticalAccuracy.__doc__ + '\n' + '* ``HvAccuracy``: ' + Qgis.GpsInformationComponent.HvAccuracy.__doc__ + '\n' + '* ``SatellitesUsed``: ' + Qgis.GpsInformationComponent.SatellitesUsed.__doc__ + '\n' + '* ``Timestamp``: ' + Qgis.GpsInformationComponent.Timestamp.__doc__ + '\n' + '* ``TrackStartTime``: ' + Qgis.GpsInformationComponent.TrackStartTime.__doc__ + '\n' + '* ``TrackEndTime``: ' + Qgis.GpsInformationComponent.TrackEndTime.__doc__
# --
Qgis.GpsInformationComponent.baseClass = Qgis
Qgis.GpsInformationComponents.baseClass = Qgis
Expand Down
5 changes: 5 additions & 0 deletions python/core/auto_generated/gps/qgsgpslogger.sip.in
Expand Up @@ -150,6 +150,11 @@ The returned length is calculated using ellipsoidal calculations.
Returns the direct length from the first vertex in the track to the last (in meters).

The returned length is calculated using ellipsoidal calculations.
%End

QVariant componentValue( Qgis::GpsInformationComponent component ) const;
%Docstring
Returns the value of the corresponding GPS information ``component``.
%End

signals:
Expand Down
10 changes: 10 additions & 0 deletions python/core/auto_generated/qgis.sip.in
Expand Up @@ -622,6 +622,16 @@ The development version
Bearing,
TotalTrackLength,
TrackDistanceFromStart,
Pdop,
Hdop,
Vdop,
HorizontalAccuracy,
VerticalAccuracy,
HvAccuracy,
SatellitesUsed,
Timestamp,
TrackStartTime,
TrackEndTime,
};

typedef QFlags<Qgis::GpsInformationComponent> GpsInformationComponents;
Expand Down
13 changes: 13 additions & 0 deletions src/app/gps/qgsgpstoolbar.cpp
Expand Up @@ -280,6 +280,19 @@ void QgsGpsToolBar::updateLocationLabel()

break;
}

case Qgis::GpsInformationComponent::Pdop:
case Qgis::GpsInformationComponent::Hdop:
case Qgis::GpsInformationComponent::Vdop:
case Qgis::GpsInformationComponent::HorizontalAccuracy:
case Qgis::GpsInformationComponent::VerticalAccuracy:
case Qgis::GpsInformationComponent::HvAccuracy:
case Qgis::GpsInformationComponent::SatellitesUsed:
case Qgis::GpsInformationComponent::Timestamp:
case Qgis::GpsInformationComponent::TrackStartTime:
case Qgis::GpsInformationComponent::TrackEndTime:
// not supported yet
break;
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions src/core/gps/qgsgpsconnection.cpp
Expand Up @@ -141,8 +141,28 @@ QVariant QgsGpsInformation::componentValue( Qgis::GpsInformationComponent compon
case Qgis::GpsInformationComponent::Bearing:
return std::isnan( direction ) ? QVariant() : direction;

case Qgis::GpsInformationComponent::Pdop:
return pdop;
case Qgis::GpsInformationComponent::Hdop:
return hdop;
case Qgis::GpsInformationComponent::Vdop:
return vdop;
case Qgis::GpsInformationComponent::HorizontalAccuracy:
return hacc;
case Qgis::GpsInformationComponent::VerticalAccuracy:
return vacc;
case Qgis::GpsInformationComponent::HvAccuracy:
return hvacc;
case Qgis::GpsInformationComponent::SatellitesUsed:
return satellitesUsed;

case Qgis::GpsInformationComponent::Timestamp:
return utcDateTime;

case Qgis::GpsInformationComponent::TotalTrackLength:
case Qgis::GpsInformationComponent::TrackDistanceFromStart:
case Qgis::GpsInformationComponent::TrackStartTime:
case Qgis::GpsInformationComponent::TrackEndTime:
return QVariant(); // not available
}
BUILTIN_UNREACHABLE
Expand Down
35 changes: 35 additions & 0 deletions src/core/gps/qgsgpslogger.cpp
Expand Up @@ -180,6 +180,41 @@ double QgsGpsLogger::trackDistanceFromStart() const
return mDistanceCalculator.measureLine( { QgsPointXY( mCaptureListWgs84.constFirst() ), QgsPointXY( mCaptureListWgs84.constLast() )} );
}

QVariant QgsGpsLogger::componentValue( Qgis::GpsInformationComponent component ) const
{
if ( !mConnection )
return QVariant();

switch ( component )
{
case Qgis::GpsInformationComponent::Location:
case Qgis::GpsInformationComponent::Altitude:
case Qgis::GpsInformationComponent::GroundSpeed:
case Qgis::GpsInformationComponent::Bearing:
case Qgis::GpsInformationComponent::Pdop:
case Qgis::GpsInformationComponent::Hdop:
case Qgis::GpsInformationComponent::Vdop:
case Qgis::GpsInformationComponent::HorizontalAccuracy:
case Qgis::GpsInformationComponent::VerticalAccuracy:
case Qgis::GpsInformationComponent::HvAccuracy:
case Qgis::GpsInformationComponent::SatellitesUsed:
return mConnection->currentGPSInformation().componentValue( component );

case Qgis::GpsInformationComponent::Timestamp:
return lastTimestamp();

case Qgis::GpsInformationComponent::TotalTrackLength:
return totalTrackLength();
case Qgis::GpsInformationComponent::TrackDistanceFromStart:
return trackDistanceFromStart();
case Qgis::GpsInformationComponent::TrackStartTime:
return trackStartTime();
case Qgis::GpsInformationComponent::TrackEndTime:
return lastTimestamp();
}
BUILTIN_UNREACHABLE
}

void QgsGpsLogger::switchAcquisition()
{
if ( mAcquisitionInterval > 0 )
Expand Down
5 changes: 5 additions & 0 deletions src/core/gps/qgsgpslogger.h
Expand Up @@ -174,6 +174,11 @@ class CORE_EXPORT QgsGpsLogger : public QObject
*/
double trackDistanceFromStart() const;

/**
* Returns the value of the corresponding GPS information \a component.
*/
QVariant componentValue( Qgis::GpsInformationComponent component ) const;

signals:

/**
Expand Down
14 changes: 12 additions & 2 deletions src/core/qgis.h
Expand Up @@ -1012,8 +1012,18 @@ class CORE_EXPORT Qgis
Altitude = 1 << 1, //!< Altitude/elevation above or below the mean sea level
GroundSpeed = 1 << 2, //!< Ground speed
Bearing = 1 << 3, //!< Bearing measured in degrees clockwise from true north to the direction of travel
TotalTrackLength = 1 << 4, //!< Total distance of current GPS track (available from QGIS app library only)
TrackDistanceFromStart = 1 << 5, //!< Direct distance from first vertex in current GPS track to last vertex (available from QGIS app library only)
TotalTrackLength = 1 << 4, //!< Total distance of current GPS track (available from QgsGpsLogger class only)
TrackDistanceFromStart = 1 << 5, //!< Direct distance from first vertex in current GPS track to last vertex (available from QgsGpsLogger class only)
Pdop = 1 << 6, //!< Dilution of precision
Hdop = 1 << 7, //!< Horizontal dilution of precision
Vdop = 1 << 8, //!< Vertical dilution of precision
HorizontalAccuracy = 1 << 9, //!< Horizontal accuracy in meters
VerticalAccuracy = 1 << 10, //!< Vertical accuracy in meters
HvAccuracy = 1 << 11, //!< 3D RMS
SatellitesUsed = 1 << 12, //!< Count of satellites used in obtaining the fix
Timestamp = 1 << 13, //!< Timestamp
TrackStartTime = 1 << 14, //!< Timestamp at start of current track (available from QgsGpsLogger class only)
TrackEndTime = 1 << 15, //!< Timestamp at end (current point) of current track (available from QgsGpsLogger class only)
};

/**
Expand Down

0 comments on commit b572e54

Please sign in to comment.