mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Ref T236, getGroundElevation can be used with and without provider
This commit is contained in:
@@ -27,11 +27,13 @@ namespace BlackMisc
|
||||
m_isVtol(isVtolAircraft), m_hasParts(hasParts), m_logInterpolation(log)
|
||||
{ }
|
||||
|
||||
CAltitude CInterpolationHints::getGroundElevation(const CAircraftSituation &situation) const
|
||||
CAltitude CInterpolationHints::getGroundElevation(const CAircraftSituation &situation, bool useProvider, bool forceProvider) const
|
||||
{
|
||||
if (m_elevationProvider) { return m_elevationProvider(situation); }
|
||||
if (m_elevationPlane.isNull() || !m_elevationPlane.isWithinRange(situation)) { return CAltitude::null(); }
|
||||
return m_elevationPlane.geodeticHeight();
|
||||
const bool validPlane = m_elevationPlane.isWithinRange(situation);
|
||||
Q_ASSERT_X(!(forceProvider && !useProvider), Q_FUNC_INFO, "Invalid parameter combination");
|
||||
if (forceProvider && useProvider && m_elevationProvider) { return m_elevationProvider(situation); }
|
||||
if (!validPlane && useProvider && m_elevationProvider) { return m_elevationProvider(situation); }
|
||||
return validPlane ? this->m_elevationPlane.getAltitude() : CAltitude::null();
|
||||
}
|
||||
|
||||
void CInterpolationHints::resetElevationPlane()
|
||||
|
||||
@@ -56,9 +56,12 @@ namespace BlackMisc
|
||||
|
||||
//! Get elevation from CInterpolationHints::getElevationProvider or CInterpolationHints::getElevation
|
||||
//! \remark avoid unnecessary calls on XPlane (calling elevation provider)
|
||||
//! @param situation
|
||||
//! @param useProvider using the provider if available
|
||||
//! @param forceProvider use the provider and ignore any plane
|
||||
//! \see setElevationProvider
|
||||
//! \see setElevationPlane
|
||||
Aviation::CAltitude getGroundElevation(const Aviation::CAircraftSituation &situation) const;
|
||||
Aviation::CAltitude getGroundElevation(const Aviation::CAircraftSituation &situation, bool useProvider, bool forceProvider = false) const;
|
||||
|
||||
//! Check if elevation is within radius and can be used
|
||||
bool isWithinRange(const Geo::ICoordinateGeodetic &coordinate) const;
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace BlackMisc
|
||||
// * for FSX/P3D provided as hints.getElevation which is set to current position of remote aircraft in simulator
|
||||
// * As XP uses lazy init we will call getGroundElevation only when needed
|
||||
// * default here via getElevationPlane
|
||||
CAltitude currentGroundElevation(hints.getElevationPlane().getAltitudeIfWithinRadius(currentSituation));
|
||||
CAltitude currentGroundElevation(hints.getGroundElevation(currentSituation, false, false));
|
||||
currentSituation.setGroundElevationChecked(currentGroundElevation); // set as default
|
||||
|
||||
// data, split situations by time
|
||||
@@ -109,7 +109,12 @@ namespace BlackMisc
|
||||
log.groundFactor = groundFactor;
|
||||
if (groundFactor > 0.0)
|
||||
{
|
||||
currentGroundElevation = hints.getGroundElevation(currentSituation); // "expensive on XPlane"
|
||||
// if not having an ground elevation yet, we fetch from provider
|
||||
if (!currentGroundElevation.isNull())
|
||||
{
|
||||
currentGroundElevation = hints.getGroundElevation(currentSituation, true); // "expensive on XPlane" if provider is called
|
||||
}
|
||||
|
||||
if (!currentGroundElevation.isNull())
|
||||
{
|
||||
Q_ASSERT_X(currentGroundElevation.getReferenceDatum() == CAltitude::MeanSeaLevel, Q_FUNC_INFO, "Need MSL value");
|
||||
@@ -322,7 +327,7 @@ namespace BlackMisc
|
||||
void CInterpolator<Derived>::setGroundElevationFromHint(const CInterpolationHints &hints, CAircraftSituation &situation, bool override)
|
||||
{
|
||||
if (!override && situation.hasGroundElevation()) { return; }
|
||||
const CAltitude elevation = hints.getGroundElevation(situation);
|
||||
const CAltitude elevation = hints.getGroundElevation(situation, false);
|
||||
if (elevation.isNull()) { return; }
|
||||
situation.setGroundElevation(elevation);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user