mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Ref T505, heading normalize
This commit is contained in:
committed by
Mat Sutcliffe
parent
b476ce4894
commit
8bd6fdf9fc
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
#include "blackmisc/aviation/heading.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
using BlackMisc::PhysicalQuantities::CAngle;
|
||||
@@ -22,11 +21,19 @@ namespace BlackMisc
|
||||
{
|
||||
return i18n ?
|
||||
QStringLiteral("%1 %2").arg(CAngle::convertToQString(i18n),
|
||||
this->isMagneticHeading() ?
|
||||
QCoreApplication::translate("Aviation", "magnetic") :
|
||||
QCoreApplication::translate("Aviation", "true")) :
|
||||
this->isMagneticHeading() ?
|
||||
QCoreApplication::translate("Aviation", "magnetic") :
|
||||
QCoreApplication::translate("Aviation", "true")) :
|
||||
QStringLiteral("%1 %2").arg(CAngle::convertToQString(i18n),
|
||||
this->isMagneticHeading() ? "magnetic" : "true");
|
||||
this->isMagneticHeading() ? "magnetic" : "true");
|
||||
}
|
||||
|
||||
void CHeading::normalizeTo360Degrees()
|
||||
{
|
||||
const double v = normalizeDegrees360(this->value(CAngleUnit::deg()));
|
||||
const CAngleUnit u = this->getUnit();
|
||||
*this = CHeading(v, this->getReferenceNorth(), CAngleUnit::deg());
|
||||
this->switchUnit(u);
|
||||
}
|
||||
|
||||
void CHeading::normalizeToPlusMinus180Degrees()
|
||||
@@ -44,6 +51,13 @@ namespace BlackMisc
|
||||
return copy;
|
||||
}
|
||||
|
||||
CHeading CHeading::normalizedTo360Degrees() const
|
||||
{
|
||||
CHeading copy(*this);
|
||||
copy.normalizeTo360Degrees();
|
||||
return copy;
|
||||
}
|
||||
|
||||
void CHeading::registerMetadata()
|
||||
{
|
||||
Mixin::MetaType<CHeading>::registerMetadata();
|
||||
|
||||
@@ -87,12 +87,18 @@ namespace BlackMisc
|
||||
//! Get reference north (magnetic or true)
|
||||
ReferenceNorth getReferenceNorth() const { return m_north; }
|
||||
|
||||
//! Normalize to [0, 359.99]
|
||||
void normalizeTo360Degrees();
|
||||
|
||||
//! Normalize to +- 180deg, [-179.99, 180.0]
|
||||
void normalizeToPlusMinus180Degrees();
|
||||
|
||||
//! As [-179.99, 180.0] normalized heading
|
||||
CHeading normalizedToPlusMinus180Degrees() const;
|
||||
|
||||
//! As [0, 359.99] normalized heading
|
||||
CHeading normalizedTo360Degrees() const;
|
||||
|
||||
//! Register metadata
|
||||
static void registerMetadata();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user