Skip to content

Commit

Permalink
NMEA calculate 3D RMS
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn authored and nyalldawson committed Jan 11, 2021
1 parent 77c59ef commit e0ad337
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 151 deletions.
2 changes: 2 additions & 0 deletions python/core/auto_generated/gps/qgsgpsconnection.sip.in
Expand Up @@ -82,6 +82,8 @@ Encapsulates information relating to a GPS position fix.
//! Vertical accuracy in meters
double vacc;

double hvacc;

QDateTime utcDateTime;

QChar fixMode;
Expand Down
10 changes: 10 additions & 0 deletions src/app/gps/qgsgpsinformationwidget.cpp
Expand Up @@ -960,6 +960,16 @@ void QgsGpsInformationWidget::displayGPSInformation( const QgsGpsInformation &in
mTxtVacc->setEnabled( false );
mTxtVacc->setText( tr( "Not available" ) );
}
if ( std::isfinite( info.hvacc ) )
{
mTxt3Dacc->setEnabled( true );
mTxt3Dacc->setText( tr( "%1 m" ).arg( QLocale().toString( info.hvacc, 'f', 3 ) ) );
}
else
{
mTxt3Dacc->setEnabled( false );
mTxt3Dacc->setText( tr( "Not available" ) );
}
mTxtFixMode->setText( info.fixMode == 'A' ? tr( "Automatic" ) : info.fixMode == 'M' ? tr( "Manual" ) : QString() ); // A=automatic 2d/3d, M=manual; allowing for anything else
mTxtFixType->setText( info.fixType == 3 ? tr( "3D" ) : info.fixType == 2 ? tr( "2D" ) : info.fixType == 1 ? tr( "No fix" ) : QString::number( info.fixType ) ); // 1=no fix, 2=2D, 3=3D; allowing for anything else
mTxtQuality->setText( info.qualityDescription() );
Expand Down
12 changes: 12 additions & 0 deletions src/core/gps/qgsgpsconnection.h
Expand Up @@ -172,11 +172,23 @@ class CORE_EXPORT QgsGpsInformation
double hacc = std::numeric_limits< double >::quiet_NaN();
//! Vertical accuracy in meters
double vacc = std::numeric_limits< double >::quiet_NaN();

/**
* 3D RMS
* \since QGIS 3.18
*/
double hvacc = std::numeric_limits< double >::quiet_NaN();
#else
//! Horizontal accuracy in meters
double hacc;
//! Vertical accuracy in meters
double vacc;

/**
* 3D RMS
* \since QGIS 3.18
*/
double hvacc;
#endif

/**
Expand Down
2 changes: 2 additions & 0 deletions src/core/gps/qgsnmeaconnection.cpp
Expand Up @@ -207,6 +207,8 @@ void QgsNmeaConnection::processGstSentence( const char *data, int len )
mLastGPSInformation.hacc = sqrt( ( pow( sig_lat, 2 ) + pow( sig_lon, 2 ) ) / 2.0 );
// Vertical RMS
mLastGPSInformation.vacc = sig_alt;
// 3D RMS
mLastGPSInformation.hvacc = sqrt( ( pow( sig_lat, 2 ) + pow( sig_lon, 2 ) + pow( sig_alt, 2 ) ) / 3.0 );
}
}

Expand Down

0 comments on commit e0ad337

Please sign in to comment.