Ref T778, some smaller style fixes/improvements

for the "underground" airplanes as reported by AK

This does NOT fix the issue, but minor shortcomings
found during the investigation

* style
* checks for "developer" env.
This commit is contained in:
Klaus Basan
2020-04-03 20:17:08 +02:00
committed by Mat Sutcliffe
parent cb814583f6
commit 373e45e958
9 changed files with 74 additions and 23 deletions

View File

@@ -1391,15 +1391,21 @@ namespace BlackCore
// and avoids unnecessary elevation fetching for low flying smaller GA aircraft
const CAircraftIcaoCode icao = this->getAircraftInRangeModelForCallsign(callsign).getAircraftIcaoCode();
if (!icao.hasDesignator()) { break; } // what is that?
if (!icao.isVtol())
if (icao.isVtol())
{
// Not for VTOLs
// VTOLs over 60kts likely not on ground
// it could be that a low flying helicopter near ground
if (situation.getGroundSpeed().value(CSpeedUnit::kts()) > 60) { break; }
}
else
{
// NO VTOL
CLength cg(nullptr);
CSpeed rotateSpeed(nullptr);
icao.guessModelParameters(cg, rotateSpeed);
if (!rotateSpeed.isNull())
{
rotateSpeed *= 1.2; // some margin
rotateSpeed *= 1.25; // some margin
if (situation.getGroundSpeed() > rotateSpeed) { break; }
}
}
@@ -1414,6 +1420,7 @@ namespace BlackCore
}
// we NEED elevation
// actually distance of 200k/h 100ms is just 6.1 meters
const CLength dpt = correctedSituation.getDistancePerTime(100, CElevationPlane::singlePointRadius());
const CAircraftSituationList situationsBeforeStoring = this->remoteAircraftSituations(callsign);
const CAircraftSituation situationWithElvBeforeStoring = situationsBeforeStoring.findClosestElevationWithinRange(correctedSituation, dpt);
@@ -1435,7 +1442,7 @@ namespace BlackCore
}
// we have a new situation, so we try to get the elevation
// so far we have requested it, but we set it upfront either by
// we will requested it, but we set it upfront either by
//
// a) average value from other planes in the vicinity (cache, not moving) or
// b) by extrapolating
@@ -1450,11 +1457,12 @@ namespace BlackCore
bool fromNonMoving = false;
bool triedExtrapolation = false;
bool couldNotExtrapolate = false;
int fromWhere = -1; // debugging
CElevationPlane averagePlane = this->averageElevationOfOnGroundAircraft(situation, CElevationPlane::majorAirportRadius(), 2, 3);
CElevationPlane averagePlane = this->averageElevationOfOnGroundAircraft(situation, CElevationPlane::minorAirportRadius(), 2, 3);
if (averagePlane.isNull())
{
averagePlane = this->averageElevationOfNonMovingAircraft(situation, CElevationPlane::majorAirportRadius(), 2, 3);
averagePlane = this->averageElevationOfNonMovingAircraft(situation, CElevationPlane::minorAirportRadius(), 2, 3);
fromNonMoving = true;
}
@@ -1464,6 +1472,7 @@ namespace BlackCore
correctedSituation.setGroundElevation(averagePlane, CAircraftSituation::Average);
if (fromNonMoving) { m_foundInNonMovingAircraft++; }
else { m_foundInElevationsOnGnd++; }
fromWhere = 10;
}
else
{
@@ -1473,6 +1482,7 @@ namespace BlackCore
const bool extrapolated = correctedSituation.extrapolateElevation(situationsBeforeStoring[0], situationsBeforeStoring[1], changesBeforeStoring);
triedExtrapolation = true;
couldNotExtrapolate = !extrapolated;
fromWhere = 20;
}
}
@@ -1484,11 +1494,19 @@ namespace BlackCore
// experimental, could become ASSERT
BLACK_VERIFY_X(needToRequestElevation, Q_FUNC_INFO, "Request should already be set");
}
needToRequestElevation = true; // should be the true already
needToRequestElevation = true; // should be "true" already
Q_UNUSED(triedExtrapolation)
Q_UNUSED(couldNotExtrapolate)
}
else
{
// sanity check on the situation
if (CBuildConfig::isLocalDeveloperDebugBuild())
{
BLACK_VERIFY_X(!correctedSituation.getGroundElevation().isZeroEpsilonConsidered(), Q_FUNC_INFO, "Suspicious elevation");
}
}
} // gnd. elevation
}
while (false); // do we need elevation, find on

View File

@@ -369,7 +369,7 @@ namespace BlackCore
bool updatedForOnGroundPosition = false;
const int updated = CRemoteAircraftAware::updateAircraftGroundElevation(callsign, plane, CAircraftSituation::FromProvider, &updatedForOnGroundPosition);
// update in simulator
// update in simulator and cache
const bool likelyOnGroundElevation = updated > 0 && updatedForOnGroundPosition;
ISimulationEnvironmentProvider::rememberGroundElevation(callsign, likelyOnGroundElevation, plane); // in simulator
@@ -1220,16 +1220,24 @@ namespace BlackCore
CAltitude elevation = situation.getGroundElevation();
if (elevation.isNull())
{
// calculate elevation
const CLength cg = ownAircraft.getModel().getCG();
elevation = (cg.isNull() || situation.getAltitude().isNull()) ? CAltitude::null() : (situation.getAltitude().withOffset(cg * -1.0));
}
// own ground elevations
if (elevation.hasMeanSeaLevelValue())
{
const CCallsign cs = situation.hasCallsign() ? situation.getCallsign() : ownAircraft.getCallsign();
const CLength radius = settings.getRecordedGndRadius().isNull() ? CElevationPlane::singlePointRadius() : settings.getRecordedGndRadius();
const CCallsign cs = situation.hasCallsign() ? situation.getCallsign() : ownAircraft.getCallsign();
const CLength radius = settings.getRecordedGndRadius().isNull() ? CElevationPlane::singlePointRadius() : settings.getRecordedGndRadius();
const CElevationPlane ep(situation, radius);
const bool remembered = this->rememberGroundElevation(cs, situation.isOnGround(), ep, radius);
if (CBuildConfig::isLocalDeveloperDebugBuild())
{
const bool invalid = situation.isOnGround() && elevation.isZeroEpsilonConsidered();
BLACK_AUDIT_X(!invalid, Q_FUNC_INFO, "On ground in water");
}
Q_UNUSED(remembered) // false means it was already in that cache, or something else is wrong
}
}