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

View File

@@ -182,7 +182,7 @@ namespace BlackMisc
const CAltitude &getAltitude() const { return m_position.geodeticHeight(); }
//! Get altitude under consideration of ground elevation
CAltitude getCorrectedAltitude() const;
CAltitude getCorrectedAltitude(const PhysicalQuantities::CLength &centerOfGravity = {}) const;
//! Set altitude
void setAltitude(const CAltitude &altitude) { m_position.setGeodeticHeight(altitude); }

View File

@@ -45,6 +45,12 @@ namespace BlackMisc
return m_elevationPlane.isWithinRange(coordinate);
}
const CLength &CInterpolationHints::getCGAboveGroundOrZero() const
{
static const CLength zero;
return this->hasCGAboveGround() ? this->getCGAboveGround() : zero;
}
void CInterpolationHints::setAircraftParts(const CAircraftParts &parts, bool hasParts)
{
m_hasParts = hasParts;

View File

@@ -66,6 +66,9 @@ namespace BlackMisc
//! Get CG above ground
const PhysicalQuantities::CLength &getCGAboveGround() const { return m_cgAboveGround;}
//! Get CG above ground or 0 ("Zero")
const PhysicalQuantities::CLength &getCGAboveGroundOrZero() const;
//! Has CG above ground
bool hasCGAboveGround() const { return m_cgAboveGround.isNull(); }