Skip to content

Commit

Permalink
Include ellipsoidal altitude in available GPS information values
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 18, 2022
1 parent 5c60406 commit 913c6ae
Show file tree
Hide file tree
Showing 11 changed files with 251 additions and 199 deletions.
4 changes: 3 additions & 1 deletion python/core/auto_additions/qgis.py
Expand Up @@ -919,7 +919,9 @@
Qgis.GpsInformationComponent.TrackEndTime.__doc__ = "Timestamp at end (current point) of current track (available from QgsGpsLogger class only)"
Qgis.GpsInformationComponent.TrackDistanceSinceLastPoint.__doc__ = "Distance since last recorded location (available from QgsGpsLogger class only)"
Qgis.GpsInformationComponent.TrackTimeSinceLastPoint.__doc__ = "Time since last recorded location (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__ + '\n' + '* ``TrackDistanceSinceLastPoint``: ' + Qgis.GpsInformationComponent.TrackDistanceSinceLastPoint.__doc__ + '\n' + '* ``TrackTimeSinceLastPoint``: ' + Qgis.GpsInformationComponent.TrackTimeSinceLastPoint.__doc__
Qgis.GpsInformationComponent.GeoidalSeparation.__doc__ = "Geoidal separation, the difference between the WGS-84 Earth ellipsoid and mean-sea-level (geoid), \"-\" means mean-sea-level below ellipsoid"
Qgis.GpsInformationComponent.EllipsoidAltitude.__doc__ = "Altitude/elevation above or below the WGS-84 Earth ellipsoid"
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__ + '\n' + '* ``TrackDistanceSinceLastPoint``: ' + Qgis.GpsInformationComponent.TrackDistanceSinceLastPoint.__doc__ + '\n' + '* ``TrackTimeSinceLastPoint``: ' + Qgis.GpsInformationComponent.TrackTimeSinceLastPoint.__doc__ + '\n' + '* ``GeoidalSeparation``: ' + Qgis.GpsInformationComponent.GeoidalSeparation.__doc__ + '\n' + '* ``EllipsoidAltitude``: ' + Qgis.GpsInformationComponent.EllipsoidAltitude.__doc__
# --
Qgis.GpsInformationComponent.baseClass = Qgis
Qgis.GpsInformationComponents.baseClass = Qgis
Expand Down
2 changes: 2 additions & 0 deletions python/core/auto_generated/qgis.sip.in
Expand Up @@ -634,6 +634,8 @@ The development version
TrackEndTime,
TrackDistanceSinceLastPoint,
TrackTimeSinceLastPoint,
GeoidalSeparation,
EllipsoidAltitude,
};

typedef QFlags<Qgis::GpsInformationComponent> GpsInformationComponents;
Expand Down
1 change: 1 addition & 0 deletions src/app/gps/qgsappgpslogging.cpp
Expand Up @@ -27,6 +27,7 @@ const std::vector< std::tuple< Qgis::GpsInformationComponent, std::tuple< QVaria
{
{ Qgis::GpsInformationComponent::Timestamp, { QVariant::DateTime, QStringLiteral( "timestamp" )}},
{ Qgis::GpsInformationComponent::Altitude, { QVariant::Double, QStringLiteral( "altitude" )}},
{ Qgis::GpsInformationComponent::EllipsoidAltitude, { QVariant::Double, QStringLiteral( "altitude_wgs84" )}},
{ Qgis::GpsInformationComponent::GroundSpeed, { QVariant::Double, QStringLiteral( "ground_speed" )}},
{ Qgis::GpsInformationComponent::Bearing, { QVariant::Double, QStringLiteral( "bearing" )}},
{ Qgis::GpsInformationComponent::Pdop, { QVariant::Double, QStringLiteral( "pdop" )}},
Expand Down
1 change: 1 addition & 0 deletions src/app/gps/qgsgpsinformationwidget.cpp
Expand Up @@ -449,6 +449,7 @@ void QgsGpsInformationWidget::displayGPSInformation( const QgsGpsInformation &in

mTxtAltitude->setText( tr( "%1 m" ).arg( info.elevation, 0, 'f', 3 ) );
mTxtAltitudeDiff->setText( tr( "%1 m" ).arg( info.elevation_diff, 0, 'f', 3 ) );
mTxtAltitudeEllipsoid->setText( tr( "%1 m" ).arg( info.elevation + info.elevation_diff, 0, 'f', 3 ) );

if ( mDateTimeFormat.isEmpty() )
{
Expand Down
10 changes: 8 additions & 2 deletions src/app/gps/qgsgpstoolbar.cpp
Expand Up @@ -26,9 +26,9 @@
#include "qgsprojectgpssettings.h"
#include "qgsmaplayermodel.h"
#include "qgsmaplayerproxymodel.h"
#include "qgsgpsconnection.h"
#include "qgsappgpsdigitizing.h"
#include "qgsunittypes.h"
#include "qgsgpsinformation.h"

#include <QLabel>
#include <QToolButton>
Expand Down Expand Up @@ -235,6 +235,7 @@ void QgsGpsToolBar::updateLocationLabel()
{
Qgis::GpsInformationComponent::Location,
Qgis::GpsInformationComponent::Altitude,
Qgis::GpsInformationComponent::EllipsoidAltitude,
Qgis::GpsInformationComponent::Bearing,
Qgis::GpsInformationComponent::GroundSpeed,
Qgis::GpsInformationComponent::TotalTrackLength,
Expand All @@ -252,6 +253,9 @@ void QgsGpsToolBar::updateLocationLabel()
case Qgis::GpsInformationComponent::Altitude:
parts << tr( "%1 m" ).arg( value.toDouble( ) );
break;
case Qgis::GpsInformationComponent::EllipsoidAltitude:
parts << tr( "%1 m" ).arg( value.toDouble( ) );
break;
case Qgis::GpsInformationComponent::GroundSpeed:
parts << tr( "%1 km/h" ).arg( value.toDouble( ) );
break;
Expand Down Expand Up @@ -281,6 +285,7 @@ void QgsGpsToolBar::updateLocationLabel()
break;
}

case Qgis::GpsInformationComponent::GeoidalSeparation:
case Qgis::GpsInformationComponent::Pdop:
case Qgis::GpsInformationComponent::Hdop:
case Qgis::GpsInformationComponent::Vdop:
Expand Down Expand Up @@ -434,7 +439,8 @@ void QgsGpsToolBar::createLocationWidget()
for ( const auto &it : std::vector< std::pair< Qgis::GpsInformationComponent, QString> >
{
{ Qgis::GpsInformationComponent::Location, tr( "Show Location" ) },
{ Qgis::GpsInformationComponent::Altitude, tr( "Show Altitude" ) },
{ Qgis::GpsInformationComponent::Altitude, tr( "Show Altitude (Geoid)" ) },
{ Qgis::GpsInformationComponent::EllipsoidAltitude, tr( "Show Altitude (WGS-84 Ellipsoid)" ) },
{ Qgis::GpsInformationComponent::GroundSpeed, tr( "Show Ground Speed" ) },
{ Qgis::GpsInformationComponent::Bearing, tr( "Show Bearing" ) },
{ Qgis::GpsInformationComponent::TotalTrackLength, tr( "Show Total Track Length" ) },
Expand Down
9 changes: 8 additions & 1 deletion src/core/gps/qgsgpsinformation.cpp
Expand Up @@ -131,7 +131,14 @@ QVariant QgsGpsInformation::componentValue( Qgis::GpsInformationComponent compon
return QgsPointXY( longitude, latitude );

case Qgis::GpsInformationComponent::Altitude:
return elevation;
return std::isnan( elevation ) ? QVariant() : elevation;

case Qgis::GpsInformationComponent::GeoidalSeparation:
return std::isnan( elevation_diff ) ? QVariant() : elevation_diff;

case Qgis::GpsInformationComponent::EllipsoidAltitude:
return std::isnan( elevation ) || std::isnan( elevation_diff ) ? QVariant() : elevation + elevation_diff;

case Qgis::GpsInformationComponent::GroundSpeed:
return speed;
case Qgis::GpsInformationComponent::Bearing:
Expand Down
9 changes: 7 additions & 2 deletions src/core/gps/qgsgpsinformation.h
Expand Up @@ -54,8 +54,13 @@ class CORE_EXPORT QgsGpsInformation
double elevation = 0;

/**
* Geoidal separation (Diff. between WGS-84 earth ellipsoid and
* mean sea level.
* Geoidal separation (in meters).
*
* The difference between the WGS-84 Earth ellipsoid and the mean sea level (geoid).
*
* Negative values indicate that mean sea level is below the ellipsoid.
*
* This value can be added to the elevation value to obtain the geoidal elevation.
*
* \since QGIS 3.18
*/
Expand Down
2 changes: 2 additions & 0 deletions src/core/gps/qgsgpslogger.cpp
Expand Up @@ -189,6 +189,8 @@ QVariant QgsGpsLogger::componentValue( Qgis::GpsInformationComponent component )
{
case Qgis::GpsInformationComponent::Location:
case Qgis::GpsInformationComponent::Altitude:
case Qgis::GpsInformationComponent::GeoidalSeparation:
case Qgis::GpsInformationComponent::EllipsoidAltitude:
case Qgis::GpsInformationComponent::GroundSpeed:
case Qgis::GpsInformationComponent::Bearing:
case Qgis::GpsInformationComponent::Pdop:
Expand Down
4 changes: 4 additions & 0 deletions src/core/gps/qgsvectorlayergpslogger.cpp
Expand Up @@ -118,6 +118,8 @@ void QgsVectorLayerGpsLogger::endCurrentTrack()
{
case Qgis::GpsInformationComponent::Location:
case Qgis::GpsInformationComponent::Altitude:
case Qgis::GpsInformationComponent::GeoidalSeparation:
case Qgis::GpsInformationComponent::EllipsoidAltitude:
case Qgis::GpsInformationComponent::GroundSpeed:
case Qgis::GpsInformationComponent::Bearing:
case Qgis::GpsInformationComponent::Pdop:
Expand Down Expand Up @@ -206,6 +208,8 @@ void QgsVectorLayerGpsLogger::gpsStateChanged( const QgsGpsInformation &info )
{
case Qgis::GpsInformationComponent::Location:
case Qgis::GpsInformationComponent::Altitude:
case Qgis::GpsInformationComponent::GeoidalSeparation:
case Qgis::GpsInformationComponent::EllipsoidAltitude:
case Qgis::GpsInformationComponent::GroundSpeed:
case Qgis::GpsInformationComponent::Bearing:
case Qgis::GpsInformationComponent::Pdop:
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgis.h
Expand Up @@ -1026,6 +1026,8 @@ class CORE_EXPORT Qgis
TrackEndTime = 1 << 15, //!< Timestamp at end (current point) of current track (available from QgsGpsLogger class only)
TrackDistanceSinceLastPoint = 1 << 16, //!< Distance since last recorded location (available from QgsGpsLogger class only)
TrackTimeSinceLastPoint = 1 << 17, //!< Time since last recorded location (available from QgsGpsLogger class only)
GeoidalSeparation = 1 << 18, //!< Geoidal separation, the difference between the WGS-84 Earth ellipsoid and mean-sea-level (geoid), "-" means mean-sea-level below ellipsoid
EllipsoidAltitude = 1 << 19, //!< Altitude/elevation above or below the WGS-84 Earth ellipsoid
};

/**
Expand Down

0 comments on commit 913c6ae

Please sign in to comment.