Ref T602, allow to define floor (round down)/round for altitude

This commit is contained in:
Klaus Basan
2019-04-12 19:07:47 +02:00
parent e67a54f497
commit e1b3f075b5
3 changed files with 5 additions and 5 deletions

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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();