mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 22:15:34 +08:00
Ref T261, unify unit handling in situation altitude related values
* this is an optimization, it would work without that, but there are numerous calculations in interpolation which are faster and easier to debug in the same unit * PQ switch unit functions use "const &PQUnit"
This commit is contained in:
committed by
Roland Winklmeier
parent
337f661499
commit
23c54938ea
@@ -510,10 +510,16 @@ namespace BlackMisc
|
||||
{
|
||||
m_groundElevationPlane = CElevationPlane(*this);
|
||||
m_groundElevationPlane.setSinglePointRadius();
|
||||
m_groundElevationPlane.setGeodeticHeight(altitude);
|
||||
m_groundElevationPlane.setGeodeticHeight(altitude.switchedUnit(this->getAltitudeUnit()));
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftSituation::setGroundElevation(const CElevationPlane &elevationPlane)
|
||||
{
|
||||
m_groundElevationPlane = elevationPlane;
|
||||
m_groundElevationPlane.switchUnit(this->getAltitudeOrDefaultUnit()); // we use ft as internal unit, no "must" but simplification
|
||||
}
|
||||
|
||||
bool CAircraftSituation::setGroundElevationChecked(const CElevationPlane &elevationPlane)
|
||||
{
|
||||
if (elevationPlane.isNull()) { return false; }
|
||||
@@ -522,7 +528,7 @@ namespace BlackMisc
|
||||
if (m_groundElevationPlane.isNull() || distance < m_groundElevationPlane.getRadius())
|
||||
{
|
||||
// better values
|
||||
m_groundElevationPlane = elevationPlane;
|
||||
this->setGroundElevation(elevationPlane);
|
||||
m_groundElevationPlane.setRadius(distance);
|
||||
return true;
|
||||
}
|
||||
@@ -548,6 +554,12 @@ namespace BlackMisc
|
||||
return this->getAltitude() - gh;
|
||||
}
|
||||
|
||||
const CLengthUnit &CAircraftSituation::getAltitudeOrDefaultUnit() const
|
||||
{
|
||||
if (this->getAltitude().isNull()) { return CAltitude::defaultUnit(); }
|
||||
return m_position.geodeticHeight().getUnit();
|
||||
}
|
||||
|
||||
CAltitude CAircraftSituation::getCorrectedAltitude(bool enableDragToGround, CAircraftSituation::AltitudeCorrection *correction) const
|
||||
{
|
||||
return this->getCorrectedAltitude(m_cg, enableDragToGround, correction);
|
||||
@@ -571,7 +583,7 @@ namespace BlackMisc
|
||||
}
|
||||
else
|
||||
{
|
||||
const CAltitude groundPlusCG = this->getGroundElevation().withOffset(centerOfGravity);
|
||||
const CAltitude groundPlusCG = this->getGroundElevation().withOffset(centerOfGravity).switchedUnit(this->getAltitudeOrDefaultUnit());
|
||||
if (groundPlusCG.isNull())
|
||||
{
|
||||
if (correction) { *correction = NoElevation; }
|
||||
@@ -615,6 +627,11 @@ namespace BlackMisc
|
||||
return altCor;
|
||||
}
|
||||
|
||||
void CAircraftSituation::setAltitude(const CAltitude &altitude)
|
||||
{
|
||||
m_position.setGeodeticHeight(altitude.switchedUnit(CAltitude::defaultUnit()));
|
||||
}
|
||||
|
||||
CAltitude CAircraftSituation::addAltitudeOffset(const CLength &offset)
|
||||
{
|
||||
if (offset.isNull()) { return this->getAltitude(); }
|
||||
@@ -675,6 +692,11 @@ namespace BlackMisc
|
||||
m_correspondingCallsign.setTypeHint(CCallsign::Aircraft);
|
||||
}
|
||||
|
||||
void CAircraftSituation::setCG(const CLength &cg)
|
||||
{
|
||||
m_cg = cg.switchedUnit(this->getAltitudeOrDefaultUnit());
|
||||
}
|
||||
|
||||
bool CAircraftSituation::adjustGroundFlag(const CAircraftParts &parts, bool alwaysSetDetails, double timeDeviationFactor, qint64 *differenceMs)
|
||||
{
|
||||
Q_ASSERT_X(timeDeviationFactor >= 0 && timeDeviationFactor <= 1.0, Q_FUNC_INFO, "Expect 0..1");
|
||||
|
||||
Reference in New Issue
Block a user