Ref T231, utility functions

* corrected altitude also considering CG
* 0 if CG is NULL
This commit is contained in:
Klaus Basan
2018-01-21 19:38:57 +01:00
parent ddaba89e2d
commit ca13c21943
4 changed files with 16 additions and 5 deletions

View File

@@ -214,11 +214,13 @@ namespace BlackMisc
return this->getAltitude() - gh;
}
CAltitude CAircraftSituation::getCorrectedAltitude() const
CAltitude CAircraftSituation::getCorrectedAltitude(const CLength &centerOfGravity) const
{
if (this->getGroundElevation().isNull()) { return this->getAltitude(); }
if (this->getAltitude().getReferenceDatum() != CAltitude::MeanSeaLevel) { return this->getAltitude(); }
if (this->getGroundElevation() < this->getAltitude()) { return this->getAltitude(); }
CAltitude altPlusCG = this->getAltitude();
if (!centerOfGravity.isNull()) { altPlusCG += centerOfGravity; }
if (this->getGroundElevation().isNull()) { return altPlusCG; }
if (this->getAltitude().getReferenceDatum() != CAltitude::MeanSeaLevel) { return altPlusCG; }
if (this->getGroundElevation() < this->getAltitude()) { return altPlusCG; }
return this->getGroundElevation();
}