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 // and avoids unnecessary elevation fetching for low flying smaller GA aircraft
const CAircraftIcaoCode icao = this->getAircraftInRangeModelForCallsign(callsign).getAircraftIcaoCode(); const CAircraftIcaoCode icao = this->getAircraftInRangeModelForCallsign(callsign).getAircraftIcaoCode();
if (!icao.hasDesignator()) { break; } // what is that? 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); CLength cg(nullptr);
CSpeed rotateSpeed(nullptr); CSpeed rotateSpeed(nullptr);
icao.guessModelParameters(cg, rotateSpeed); icao.guessModelParameters(cg, rotateSpeed);
if (!rotateSpeed.isNull()) if (!rotateSpeed.isNull())
{ {
rotateSpeed *= 1.2; // some margin rotateSpeed *= 1.25; // some margin
if (situation.getGroundSpeed() > rotateSpeed) { break; } if (situation.getGroundSpeed() > rotateSpeed) { break; }
} }
} }
@@ -1414,6 +1420,7 @@ namespace BlackCore
} }
// we NEED elevation // we NEED elevation
// actually distance of 200k/h 100ms is just 6.1 meters
const CLength dpt = correctedSituation.getDistancePerTime(100, CElevationPlane::singlePointRadius()); const CLength dpt = correctedSituation.getDistancePerTime(100, CElevationPlane::singlePointRadius());
const CAircraftSituationList situationsBeforeStoring = this->remoteAircraftSituations(callsign); const CAircraftSituationList situationsBeforeStoring = this->remoteAircraftSituations(callsign);
const CAircraftSituation situationWithElvBeforeStoring = situationsBeforeStoring.findClosestElevationWithinRange(correctedSituation, dpt); 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 // 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 // a) average value from other planes in the vicinity (cache, not moving) or
// b) by extrapolating // b) by extrapolating
@@ -1450,11 +1457,12 @@ namespace BlackCore
bool fromNonMoving = false; bool fromNonMoving = false;
bool triedExtrapolation = false; bool triedExtrapolation = false;
bool couldNotExtrapolate = 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()) if (averagePlane.isNull())
{ {
averagePlane = this->averageElevationOfNonMovingAircraft(situation, CElevationPlane::majorAirportRadius(), 2, 3); averagePlane = this->averageElevationOfNonMovingAircraft(situation, CElevationPlane::minorAirportRadius(), 2, 3);
fromNonMoving = true; fromNonMoving = true;
} }
@@ -1464,6 +1472,7 @@ namespace BlackCore
correctedSituation.setGroundElevation(averagePlane, CAircraftSituation::Average); correctedSituation.setGroundElevation(averagePlane, CAircraftSituation::Average);
if (fromNonMoving) { m_foundInNonMovingAircraft++; } if (fromNonMoving) { m_foundInNonMovingAircraft++; }
else { m_foundInElevationsOnGnd++; } else { m_foundInElevationsOnGnd++; }
fromWhere = 10;
} }
else else
{ {
@@ -1473,6 +1482,7 @@ namespace BlackCore
const bool extrapolated = correctedSituation.extrapolateElevation(situationsBeforeStoring[0], situationsBeforeStoring[1], changesBeforeStoring); const bool extrapolated = correctedSituation.extrapolateElevation(situationsBeforeStoring[0], situationsBeforeStoring[1], changesBeforeStoring);
triedExtrapolation = true; triedExtrapolation = true;
couldNotExtrapolate = !extrapolated; couldNotExtrapolate = !extrapolated;
fromWhere = 20;
} }
} }
@@ -1484,11 +1494,19 @@ namespace BlackCore
// experimental, could become ASSERT // experimental, could become ASSERT
BLACK_VERIFY_X(needToRequestElevation, Q_FUNC_INFO, "Request should already be set"); 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(triedExtrapolation)
Q_UNUSED(couldNotExtrapolate) 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 } // gnd. elevation
} }
while (false); // do we need elevation, find on while (false); // do we need elevation, find on

View File

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

View File

@@ -302,7 +302,12 @@ namespace BlackMisc
if (situationToBeUpdated.hasGroundElevation()) { return false; } if (situationToBeUpdated.hasGroundElevation()) { return false; }
// if acceptable transfer // if acceptable transfer
if (oldSituation.transferGroundElevationFromMe(situationToBeUpdated)) { return true; } if (oldSituation.transferGroundElevationFromMe(situationToBeUpdated))
{
// change or keep type is the question
// situationToBeUpdated.setGroundElevationInfo(Extrapolated);
return true;
}
if (oldSituation.isNull() || olderSituation.isNull()) { return false; } if (oldSituation.isNull() || olderSituation.isNull()) { return false; }
if (oldChange.isNull()) { return false; } if (oldChange.isNull()) { return false; }

View File

@@ -68,6 +68,7 @@ namespace BlackMisc
const CElevationPlane &elevationPlane, CAircraftSituation::GndElevationInfo info, const CAircraftModel &model, const CElevationPlane &elevationPlane, CAircraftSituation::GndElevationInfo info, const CAircraftModel &model,
CAircraftSituationChange *changeOut, bool *setForOnGroundPosition) CAircraftSituationChange *changeOut, bool *setForOnGroundPosition)
{ {
if (setForOnGroundPosition) { *setForOnGroundPosition = false; } // set a default
if (elevationPlane.isNull()) { return 0; } if (elevationPlane.isNull()) { return 0; }
if (this->isEmpty()) { return 0; } if (this->isEmpty()) { return 0; }

View File

@@ -29,7 +29,7 @@ namespace BlackMisc
CElevationPlane CCoordinateGeodeticList::averageGeodeticHeight(const CCoordinateGeodetic &reference, const CLength &range, const CLength &maxDeviation, int minValues, int sufficentValues) const CElevationPlane CCoordinateGeodeticList::averageGeodeticHeight(const CCoordinateGeodetic &reference, const CLength &range, const CLength &maxDeviation, int minValues, int sufficentValues) const
{ {
if (this->size() < minValues) { return CElevationPlane::null(); } // no change to succeed if (this->size() < minValues) { return CElevationPlane::null(); } // no chance to succeed
QList<double> valuesInFt; QList<double> valuesInFt;
const CCoordinateGeodeticList sorted = this->findWithGeodeticMSLHeight().findWithinRange(reference, range).sortedByEuclideanDistanceSquared(reference); const CCoordinateGeodeticList sorted = this->findWithGeodeticMSLHeight().findWithinRange(reference, range).sortedByEuclideanDistanceSquared(reference);

View File

@@ -426,9 +426,9 @@ namespace BlackMisc
if (!situationNew.hasGroundElevation()) { continue; } if (!situationNew.hasGroundElevation()) { continue; }
newPosTs = situationNew.getMSecsSinceEpoch(); newPosTs = situationNew.getMSecsSinceEpoch();
kml += CKmlUtils::asPlacemark( kml += CKmlUtils::asPlacemark(
QStringLiteral("%1: %2 %3 %4 alt.cor: %5").arg(n++).arg( QStringLiteral("%1: %2 %3 info: %4 alt.cor: %5").arg(n++).arg(
situationNew.getFormattedUtcTimestampHmsz(), situationNew.getFormattedUtcTimestampHmsz(),
situationNew.getGroundElevationPlane().getAltitude().toQString(true), situationNew.getGroundElevationAndInfo(),
log.elevationInfo, log.altCorrection), log.elevationInfo, log.altCorrection),
situationNew.getGroundElevationPlane().toQString(true), situationNew.getGroundElevationPlane().toQString(true),
situationNew.getGroundElevationPlane(), s) % u"\n"; situationNew.getGroundElevationPlane(), s) % u"\n";

View File

@@ -145,6 +145,16 @@ namespace BlackMisc
BLACK_VERIFY_X(details, Q_FUNC_INFO, "Once gnd.from parts -> always gnd. from parts"); BLACK_VERIFY_X(details, Q_FUNC_INFO, "Once gnd.from parts -> always gnd. from parts");
} }
if (CBuildConfig::isLocalDeveloperDebugBuild())
{
for (const CAircraftSituation &s : situations)
{
if (!s.hasGroundElevation()) { continue; }
BLACK_VERIFY_X(!s.getGroundElevation().isZeroEpsilonConsidered(), Q_FUNC_INFO, "Suspicous 0 gnd. value");
}
}
// result // result
return sorted && details; return sorted && details;
} }

View File

@@ -9,9 +9,12 @@
#include "simulationenvironmentprovider.h" #include "simulationenvironmentprovider.h"
#include "blackmisc/aviation/aircraftsituationchange.h" #include "blackmisc/aviation/aircraftsituationchange.h"
#include "verify.h" #include "blackmisc/verify.h"
#include "blackconfig/buildconfig.h"
#include <QStringBuilder> #include <QStringBuilder>
using namespace BlackConfig;
using namespace BlackMisc::Aviation; using namespace BlackMisc::Aviation;
using namespace BlackMisc::Geo; using namespace BlackMisc::Geo;
using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::PhysicalQuantities;
@@ -50,6 +53,12 @@ namespace BlackMisc
{ {
if (m_elvCoordinatesGnd.size() > m_maxElevationsGnd) { m_elvCoordinatesGnd.pop_back(); } if (m_elvCoordinatesGnd.size() > m_maxElevationsGnd) { m_elvCoordinatesGnd.pop_back(); }
m_elvCoordinatesGnd.push_front(elevationCoordinate); m_elvCoordinatesGnd.push_front(elevationCoordinate);
if (CBuildConfig::isLocalDeveloperDebugBuild())
{
BLACK_VERIFY_X(!elevationCoordinate.geodeticHeight().isNull(), Q_FUNC_INFO, "NULL value");
BLACK_VERIFY_X(!elevationCoordinate.geodeticHeight().isZeroEpsilonConsidered(), Q_FUNC_INFO, "Suspicous 0 value");
}
} }
else else
{ {