Ref T778, added "likelyOnGroundElevation" as parameter for "ememberElevationAndSimulatorCG"

This commit is contained in:
Klaus Basan
2020-04-05 03:34:35 +02:00
committed by Mat Sutcliffe
parent 09a2377197
commit 829777bf3a
5 changed files with 33 additions and 22 deletions

View File

@@ -904,14 +904,14 @@ namespace BlackCore
m_simulatorInternals.setSimulatorInstallationDirectory(s.getSimulatorDirectoryOrDefault());
}
void ISimulator::rememberElevationAndSimulatorCG(const CCallsign &callsign, const CAircraftModel &model, const CElevationPlane &elevation, const CLength &simulatorCG)
void ISimulator::rememberElevationAndSimulatorCG(const CCallsign &callsign, const CAircraftModel &model, bool likelyOnGroundElevation, const CElevationPlane &elevation, const CLength &simulatorCG)
{
if (callsign.isEmpty()) { return; }
if (elevation.hasMSLGeodeticHeight())
{
const int aircraftCount = this->getAircraftInRangeCount();
this->setMaxElevationsRemembered(aircraftCount * 3); // at least 3 elevations per aircraft, even better as not all are requesting elevations
this->rememberGroundElevation(callsign, false, elevation);
this->rememberGroundElevation(callsign, likelyOnGroundElevation, elevation);
}
const QString modelString = model.getModelString();

View File

@@ -465,7 +465,7 @@ namespace BlackCore
//! Set elevation and CG in the providers and for auto publishing
//! \sa ISimulator::updateOwnSituationAndGroundElevation
void rememberElevationAndSimulatorCG(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Simulation::CAircraftModel &model, const BlackMisc::Geo::CElevationPlane &elevation, const BlackMisc::PhysicalQuantities::CLength &simulatorCG);
void rememberElevationAndSimulatorCG(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Simulation::CAircraftModel &model, bool likelyOnGroundElevation, const BlackMisc::Geo::CElevationPlane &elevation, const BlackMisc::PhysicalQuantities::CLength &simulatorCG);
//! Emit the combined status
//! \param oldStatus optionally one can capture and provide the old status for comparison. In case of equal status values no signal will be sent

View File

@@ -750,13 +750,20 @@ namespace BlackSimPlugin
BLACK_VERIFY_X(fgAircraft.hasCallsign(), Q_FUNC_INFO, "Need callsign");
if (!fgAircraft.hasCallsign()) { continue; }
const double cgValue = verticalOffsetsMeters[i]; // FG offset is swift CG
const CAltitude elevationAlt = std::isnan(elevationsMeters[i]) ? CAltitude::null() : CAltitude(elevationsMeters[i], CLengthUnit::m(), CLengthUnit::ft());
const CElevationPlane elevation(CLatitude(latitudesDeg[i], CAngleUnit::deg()), CLongitude(longitudesDeg[i], CAngleUnit::deg()), elevationAlt, CElevationPlane::singlePointRadius());
CElevationPlane elevation = CElevationPlane::null();
if (!std::isnan(elevationsMeters[i]))
{
const CAltitude elevationAlt = CAltitude(elevationsMeters[i], CLengthUnit::m(), CLengthUnit::ft());
elevation = CElevationPlane(CLatitude(latitudesDeg[i], CAngleUnit::deg()), CLongitude(longitudesDeg[i], CAngleUnit::deg()), elevationAlt, CElevationPlane::singlePointRadius());
}
const double cgValue = verticalOffsetsMeters[i]; // XP offset is swift CG
const CLength cg = std::isnan(cgValue) ?
CLength::null() :
CLength(cgValue, CLengthUnit::m(), CLengthUnit::ft());
this->rememberElevationAndSimulatorCG(cs, fgAircraft.getAircraftModel(), elevation, cg);
// if we knew "on ground" here we could set it as parameter of rememberElevationAndSimulatorCG
this->rememberElevationAndSimulatorCG(cs, fgAircraft.getAircraftModel(), false, elevation, cg);
// loopback
if (logCallsigns.contains(cs))
@@ -830,7 +837,8 @@ namespace BlackSimPlugin
if (reference.isNull()) { return false; }
CCoordinateGeodetic pos(reference);
if(!pos.hasMSLGeodeticHeight()){
if (!pos.hasMSLGeodeticHeight())
{
// testing showed: height has an influence on the returned result
// - the most accurate value seems to be returned if the height is close to the elevation
// - in normal scenarios there is no much difference of the results if 0 is used

View File

@@ -837,24 +837,20 @@ namespace BlackSimPlugin
const CCallsign cs(simObject.getCallsign());
CAircraftSituation lastSituation = m_lastSentSituations[cs];
const bool moving = lastSituation.isMoving();
const bool onGround = remoteAircraftData.isOnGround();
// CElevationPlane: deg, deg, feet
// we only remember near ground
CElevationPlane elevation;
const CElevationPlane elevation = CElevationPlane(remoteAircraftData.latitudeDeg, remoteAircraftData.longitudeDeg, remoteAircraftData.elevationFt, CElevationPlane::singlePointRadius());
if (remoteAircraftData.aboveGroundFt() < 250)
{
const CLength cg(remoteAircraftData.cgToGroundFt, CLengthUnit::ft());
this->rememberElevationAndSimulatorCG(cs, simObject.getAircraftModel(), elevation, cg);
this->rememberElevationAndSimulatorCG(cs, simObject.getAircraftModel(), onGround, elevation, cg);
}
const bool log = this->isLogCallsign(cs);
if (log)
{
if (elevation.isNull())
{
elevation = CElevationPlane(remoteAircraftData.latitudeDeg, remoteAircraftData.longitudeDeg, remoteAircraftData.elevationFt, CElevationPlane::singlePointRadius());
}
// update lat/lng/alt with real data from sim
const CAltitude alt(remoteAircraftData.altitudeFt, CAltitude::MeanSeaLevel, CAltitude::TrueAltitude, CLengthUnit::ft());
lastSituation.setPosition(elevation);
@@ -894,7 +890,7 @@ namespace BlackSimPlugin
so.setAircraftModelString(modelString);
// update in 2 providers
this->rememberElevationAndSimulatorCG(cs, simObject.getAircraftModel(), CElevationPlane::null(), cg); // env. provider
this->rememberElevationAndSimulatorCG(cs, simObject.getAircraftModel(), false, CElevationPlane::null(), cg); // env. provider
this->updateCGAndModelString(cs, cg, modelString); // remote aircraft provider
}

View File

@@ -1064,13 +1064,20 @@ namespace BlackSimPlugin
BLACK_VERIFY_X(xpAircraft.hasCallsign(), Q_FUNC_INFO, "Need callsign");
if (!xpAircraft.hasCallsign()) { continue; }
CElevationPlane elevation = CElevationPlane::null();
if (!std::isnan(elevationsMeters[i]))
{
const CAltitude elevationAlt = CAltitude(elevationsMeters[i], CLengthUnit::m(), CLengthUnit::ft());
elevation = CElevationPlane(CLatitude(latitudesDeg[i], CAngleUnit::deg()), CLongitude(longitudesDeg[i], CAngleUnit::deg()), elevationAlt, CElevationPlane::singlePointRadius());
}
const double cgValue = verticalOffsetsMeters[i]; // XP offset is swift CG
const CAltitude elevationAlt = std::isnan(elevationsMeters[i]) ? CAltitude::null() : CAltitude(elevationsMeters[i], CLengthUnit::m(), CLengthUnit::ft());
const CElevationPlane elevation(CLatitude(latitudesDeg[i], CAngleUnit::deg()), CLongitude(longitudesDeg[i], CAngleUnit::deg()), elevationAlt, CElevationPlane::singlePointRadius());
const CLength cg = std::isnan(cgValue) ?
CLength::null() :
CLength(cgValue, CLengthUnit::m(), CLengthUnit::ft());
this->rememberElevationAndSimulatorCG(cs, xpAircraft.getAircraftModel(), elevation, cg);
// if we knew "on ground" here we could set it as parameter of rememberElevationAndSimulatorCG
this->rememberElevationAndSimulatorCG(cs, xpAircraft.getAircraftModel(), false, elevation, cg);
// loopback
if (logCallsigns.contains(cs))