mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
refs #865, adjusted interpolator to use elevation or elevation provider
* adjusted IInterpolator::setGroundElevationFromHint * removed cgAboveGround from getCorrectedAltitude
This commit is contained in:
committed by
Mathew Sutcliffe
parent
38585d10b2
commit
daab5eed49
@@ -8,11 +8,13 @@
|
||||
*/
|
||||
|
||||
#include "interpolator.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/simulation/interpolationhints.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/pq/length.h"
|
||||
#include <QDateTime>
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -68,7 +70,7 @@ namespace BlackMisc
|
||||
const auto soonestLanding = std::find_if(partsNewer.begin(), partsNewer.end(), [](auto && p) { return p.isOnGround(); });
|
||||
|
||||
// our clairvoyance is limited by the time offset
|
||||
const double significantPast = 5.0;
|
||||
const double significantPast = 5.0; // \fixme 20170121 KB would it make sense to centrally define the update time (5secs), in case it changes. I see a lot of 5.0 hardcoded here
|
||||
const double predictableFuture = soonestLanding == partsNewer.end() ? 5.0 : std::min(5.0, static_cast<double>(soonestLanding->getTimeOffsetMs()) / 1000.0);
|
||||
|
||||
const double secondsSinceTakeoff = latestTakeoff == partsOlder.end() ? 5.0 : (currentTimeMsSinceEpoch - latestTakeoff->getAdjustedMSecsSinceEpoch()) / 1000.0;
|
||||
@@ -107,10 +109,10 @@ namespace BlackMisc
|
||||
|
||||
void IInterpolator::setGroundElevationFromHint(const CInterpolationHints &hints, CAircraftSituation &situation)
|
||||
{
|
||||
if (hints.getElevation().isNull()) return;
|
||||
if (situation.hasGroundElevation()) return;
|
||||
if (!hints.isWithinRange(situation)) return;
|
||||
situation.setGroundElevation(hints.getElevation().geodeticHeight());
|
||||
if (situation.hasGroundElevation()) { return; }
|
||||
const CAltitude elevation = hints.getGroundElevation(situation);
|
||||
if (elevation.isNull()) { return; }
|
||||
situation.setGroundElevation(elevation);
|
||||
}
|
||||
|
||||
bool IInterpolator::InterpolationStatus::allTrue() const
|
||||
|
||||
@@ -100,8 +100,8 @@ namespace BlackMisc
|
||||
// take hint into account to calculate elevation and above ground level
|
||||
if (!hints.getElevation().isNull())
|
||||
{
|
||||
setGroundElevationFromHint(hints, oldSituation);
|
||||
setGroundElevationFromHint(hints, newSituation);
|
||||
IInterpolator::setGroundElevationFromHint(hints, oldSituation);
|
||||
IInterpolator::setGroundElevationFromHint(hints, newSituation);
|
||||
}
|
||||
|
||||
CAircraftSituation currentSituation(oldSituation);
|
||||
@@ -135,8 +135,8 @@ namespace BlackMisc
|
||||
currentSituation.setPosition(currentPosition);
|
||||
|
||||
// Interpolate altitude: Alt = (AltB - AltA) * t + AltA
|
||||
const CAltitude oldAlt(oldSituation.getCorrectedAltitude(hints.getCGAboveGround()));
|
||||
const CAltitude newAlt(newSituation.getCorrectedAltitude(hints.getCGAboveGround()));
|
||||
const CAltitude oldAlt(oldSituation.getCorrectedAltitude()); // avoid underflow below ground elevation
|
||||
const CAltitude newAlt(newSituation.getCorrectedAltitude());
|
||||
Q_ASSERT_X(oldAlt.getReferenceDatum() == newAlt.getReferenceDatum(), Q_FUNC_INFO, "mismatch in reference"); // otherwise no calculation is possible
|
||||
currentSituation.setAltitude(CAltitude((newAlt - oldAlt)
|
||||
* simulationTimeFraction
|
||||
@@ -149,11 +149,12 @@ namespace BlackMisc
|
||||
const double groundFactor = hints.getAircraftParts().isOnGroundInterpolated();
|
||||
if (groundFactor > 0.0)
|
||||
{
|
||||
const auto &groundElevation = hints.getElevationProvider();
|
||||
if (groundElevation)
|
||||
const CAltitude groundElevation = hints.getGroundElevation(currentSituation);
|
||||
Q_ASSERT_X(groundElevation.getReferenceDatum() == CAltitude::MeanSeaLevel, Q_FUNC_INFO, "Need MSL value");
|
||||
if (!groundElevation.isNull())
|
||||
{
|
||||
currentSituation.setAltitude(CAltitude(currentSituation.getAltitude() * (1.0 - groundFactor)
|
||||
+ groundElevation(currentSituation) * groundFactor,
|
||||
+ groundElevation * groundFactor,
|
||||
oldAlt.getReferenceDatum()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user