Skip to content

Commit

Permalink
Move antenna height logic to the receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
domi4484 committed Aug 9, 2023
1 parent e731b3c commit dcdbe6c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/core/positioning/internalgnssreceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
***************************************************************************/

#include "internalgnssreceiver.h"
#include "positioning.h"

#include <QGuiApplication>
#include <qgsapplication.h>
Expand Down Expand Up @@ -132,10 +133,15 @@ void InternalGnssReceiver::handlePositionUpdated( const QGeoPositionInfo &positi
longitude = positionInfo.coordinate().longitude();
updatePositionInformation = true;
}

double antennaHeight = 0.0;
if ( Positioning *positioning = qobject_cast<Positioning *>( parent() ) )
antennaHeight = positioning->antennaHeight();

double elevation = mLastGnssPositionInformation.elevation();
if ( !qgsDoubleNear( positionInfo.coordinate().altitude(), elevation ) )
{
elevation = positionInfo.coordinate().altitude();
elevation = positionInfo.coordinate().altitude() - antennaHeight;
updatePositionInformation = true;
}

Expand Down
8 changes: 7 additions & 1 deletion src/core/positioning/nmeagnssreceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ void NmeaGnssReceiver::stateChanged( const QgsGpsInformation &info )
mLastGnssPositionValid = !std::isnan( info.latitude );

bool ellipsoidalElevation = false;
double antennaHeight = 0.0;
if ( Positioning *positioning = qobject_cast<Positioning *>( parent() ) )
{
ellipsoidalElevation = positioning->ellipsoidalElevation();
antennaHeight = positioning->antennaHeight();
}

if ( info.utcTime != mLastGnssPositionUtcTime )
Expand All @@ -73,9 +75,13 @@ void NmeaGnssReceiver::stateChanged( const QgsGpsInformation &info )
emit lastGnssPositionInformationChanged( mLastGnssPositionInformation );
}

double elevation = info.elevation - antennaHeight;
if ( ellipsoidalElevation )
elevation += info.elevation_diff;

// QgsGpsInformation's speed is served in km/h, translate to m/s
mCurrentNmeaGnssPositionInformation = GnssPositionInformation( info.latitude, info.longitude,
ellipsoidalElevation ? info.elevation + info.elevation_diff : info.elevation,
elevation,
info.speed * 1000 / 60 / 60, info.direction, info.satellitesInView, info.pdop, info.hdop, info.vdop,
info.hacc, info.vacc, info.utcDateTime, info.fixMode, info.fixType, info.quality, info.satellitesUsed, info.status,
info.satPrn, info.satInfoComplete, std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
Expand Down
4 changes: 0 additions & 4 deletions src/core/positioning/positioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,6 @@ void Positioning::lastGnssPositionInformationChanged( const GnssPositionInformat
mSourcePosition.clear();
}

// With IMU active the antenna height is corrected by the device
if ( mAntennaHeight && !mPositionInformation.imuCorrection() )
mSourcePosition.setZ( mSourcePosition.z() - mAntennaHeight );

if ( mCoordinateTransformer )
{
mCoordinateTransformer->setSourcePosition( mSourcePosition );
Expand Down

0 comments on commit dcdbe6c

Please sign in to comment.