mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Ref T602, allow to define floor (round down)/round for altitude
This commit is contained in:
@@ -146,7 +146,7 @@ namespace BlackGui
|
||||
{
|
||||
if (mode == AltitudeInMetersConvertedToFeet)
|
||||
{
|
||||
m_altitude = m_altitude.roundedToNearest100ft();
|
||||
m_altitude = m_altitude.roundedToNearest100ft(true);
|
||||
m_altitudeStr = m_altitude.valueRoundedWithUnit(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ namespace BlackMisc
|
||||
// the M/A formats are not supported by VATSIM, means by other clients
|
||||
|
||||
// as feed, as none of the other clients
|
||||
const CAltitude a = this->roundedToNearest100ft();
|
||||
const CAltitude a = this->roundedToNearest100ft(false);
|
||||
return a.valueRoundedWithUnit(CLengthUnit::ft(), 0);
|
||||
}
|
||||
|
||||
@@ -378,12 +378,12 @@ namespace BlackMisc
|
||||
return CLength::compare(*this, otherAltitude);
|
||||
}
|
||||
|
||||
CAltitude CAltitude::roundedToNearest100ft() const
|
||||
CAltitude CAltitude::roundedToNearest100ft(bool roundDown) const
|
||||
{
|
||||
// 23453 => 234.53
|
||||
CAltitude a = this->switchedUnit(CLengthUnit::ft());
|
||||
const double ft = a.value(CLengthUnit::ft()) / 100.0;
|
||||
const int ftR = qRound(ft) * 100;
|
||||
const int ftR = roundDown ? static_cast<int>(floor(ft)) * 100 : qRound(ft) * 100;
|
||||
a.setValueSameUnit(ftR);
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ namespace BlackMisc
|
||||
|
||||
//! Round to the nearest 100ft, like needed for China and Russia
|
||||
//! \remark https://en.wikipedia.org/wiki/Flight_level
|
||||
CAltitude roundedToNearest100ft() const;
|
||||
CAltitude roundedToNearest100ft(bool roundDown) const;
|
||||
|
||||
//! Null altitude (MSL)
|
||||
static const CAltitude &null();
|
||||
|
||||
Reference in New Issue
Block a user