Ref T773, return flag if elevation was set for a ground position

This commit is contained in:
Klaus Basan
2020-02-18 00:37:42 +01:00
committed by Mat Sutcliffe
parent a7ae5290d0
commit b128d40342
2 changed files with 16 additions and 4 deletions

View File

@@ -64,7 +64,9 @@ namespace BlackMisc
return c;
}
int CAircraftSituationList::setGroundElevationCheckedAndGuessGround(const CElevationPlane &elevationPlane, CAircraftSituation::GndElevationInfo info, const CAircraftModel &model, CAircraftSituationChange *changeOut)
int CAircraftSituationList::setGroundElevationCheckedAndGuessGround(
const CElevationPlane &elevationPlane, CAircraftSituation::GndElevationInfo info, const CAircraftModel &model,
CAircraftSituationChange *changeOut, bool *setForOnGroundPosition)
{
if (elevationPlane.isNull()) { return 0; }
if (this->isEmpty()) { return 0; }
@@ -74,6 +76,7 @@ namespace BlackMisc
const CAircraftSituationChange simpleChange(*this, model.getCG(), model.isVtol(), true, false);
int c = 0; // changed elevations
bool latest = true;
bool setForOnGndPosition = false;
for (CAircraftSituation &s : *this)
{
@@ -82,12 +85,21 @@ namespace BlackMisc
{
// simpleChange is only valid for the latest situation
// this will do nothing if not appropriate!
s.guessOnGround(latest ? simpleChange : CAircraftSituationChange::null(), model);
const bool guessed = s.guessOnGround(latest ? simpleChange : CAircraftSituationChange::null(), model);
Q_UNUSED(guessed)
c++;
// if not guessed and "on ground" we mark the "elevation"
// as an elevation for a ground position
if (!setForOnGndPosition && s.hasInboundGroundDetails() && s.isOnGround())
{
setForOnGndPosition = true;
}
}
latest = false;
latest = false; // only first pos. is "the latest" one
}
if (setForOnGroundPosition) { *setForOnGroundPosition = setForOnGndPosition; }
if (changeOut)
{
const CAircraftSituationChange change(*this, model.getCG(), model.isVtol(), true, true);

View File

@@ -67,7 +67,7 @@ namespace BlackMisc
//! Set ground elevation from elevation plane and guess ground
//! \note requires a sorted list latest first
int setGroundElevationCheckedAndGuessGround(const Geo::CElevationPlane &elevationPlane, CAircraftSituation::GndElevationInfo info, const Simulation::CAircraftModel &model, CAircraftSituationChange *changeOut);
int setGroundElevationCheckedAndGuessGround(const Geo::CElevationPlane &elevationPlane, CAircraftSituation::GndElevationInfo info, const Simulation::CAircraftModel &model, CAircraftSituationChange *changeOut, bool *setForOnGroundPosition);
//! Adjust flag from parts by using CAircraftSituation::adjustGroundFlag
int adjustGroundFlag(const CAircraftParts &parts, double timeDeviationFactor = 0.1);