Ref T259, Ref T243 removed interpolation hints

* no longer needed with providers in that form
* pure refactoring commit, just guarantees compilation
* already minor adjustments to use providers
This commit is contained in:
Klaus Basan
2018-03-20 20:15:26 +01:00
parent 476768f6ec
commit 0c06ac26f7
37 changed files with 140 additions and 586 deletions

View File

@@ -407,6 +407,13 @@ namespace BlackCore
return m_aircraftInRange.containsCallsign(callsign); return m_aircraftInRange.containsCallsign(callsign);
} }
bool CAirspaceMonitor::isVtolAircraft(const CCallsign &callsign) const
{
if (callsign.isEmpty()) { return false; }
const CSimulatedAircraft aircraft = this->getAircraftInRangeForCallsign(callsign);
return aircraft.isVtol();
}
CAtcStation CAirspaceMonitor::getAtcStationForComUnit(const CComSystem &comSystem) CAtcStation CAirspaceMonitor::getAtcStationForComUnit(const CComSystem &comSystem)
{ {
CAtcStation station; CAtcStation station;

View File

@@ -94,6 +94,7 @@ namespace BlackCore
virtual BlackMisc::Simulation::CAircraftModel getAircraftInRangeModelForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override; virtual BlackMisc::Simulation::CAircraftModel getAircraftInRangeModelForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override;
virtual int getAircraftInRangeCount() const override; virtual int getAircraftInRangeCount() const override;
virtual bool isAircraftInRange(const BlackMisc::Aviation::CCallsign &callsign) const override; virtual bool isAircraftInRange(const BlackMisc::Aviation::CCallsign &callsign) const override;
virtual bool isVtolAircraft(const BlackMisc::Aviation::CCallsign &callsign) const override;
virtual BlackMisc::Simulation::CAirspaceAircraftSnapshot getLatestAirspaceAircraftSnapshot() const override; virtual BlackMisc::Simulation::CAirspaceAircraftSnapshot getLatestAirspaceAircraftSnapshot() const override;
virtual BlackMisc::Aviation::CAircraftSituationList remoteAircraftSituations(const BlackMisc::Aviation::CCallsign &callsign) const override; virtual BlackMisc::Aviation::CAircraftSituationList remoteAircraftSituations(const BlackMisc::Aviation::CCallsign &callsign) const override;
virtual int remoteAircraftSituationsCount(const BlackMisc::Aviation::CCallsign &callsign) const override; virtual int remoteAircraftSituationsCount(const BlackMisc::Aviation::CCallsign &callsign) const override;

View File

@@ -531,6 +531,12 @@ namespace BlackCore
return m_airspace->isAircraftInRange(callsign); return m_airspace->isAircraftInRange(callsign);
} }
bool CContextNetwork::isVtolAircraft(const CCallsign &callsign) const
{
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
return m_airspace->isVtolAircraft(callsign);
}
CSimulatedAircraft CContextNetwork::getAircraftInRangeForCallsign(const CCallsign &callsign) const CSimulatedAircraft CContextNetwork::getAircraftInRangeForCallsign(const CCallsign &callsign) const
{ {
if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; } if (this->isDebugEnabled()) { CLogMessage(this, BlackMisc::CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << callsign; }

View File

@@ -118,6 +118,7 @@ namespace BlackCore
virtual BlackMisc::Aviation::CCallsignSet getAircraftInRangeCallsigns() const override; virtual BlackMisc::Aviation::CCallsignSet getAircraftInRangeCallsigns() const override;
virtual int getAircraftInRangeCount() const override; virtual int getAircraftInRangeCount() const override;
virtual bool isAircraftInRange(const BlackMisc::Aviation::CCallsign &callsign) const override; virtual bool isAircraftInRange(const BlackMisc::Aviation::CCallsign &callsign) const override;
virtual bool isVtolAircraft(const BlackMisc::Aviation::CCallsign &callsign) const override;
virtual BlackMisc::Simulation::CSimulatedAircraft getAircraftInRangeForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override; virtual BlackMisc::Simulation::CSimulatedAircraft getAircraftInRangeForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override;
virtual BlackMisc::Simulation::CAircraftModel getAircraftInRangeModelForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override; virtual BlackMisc::Simulation::CAircraftModel getAircraftInRangeModelForCallsign(const BlackMisc::Aviation::CCallsign &callsign) const override;
virtual BlackMisc::CStatusMessageList getReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign) const override; virtual BlackMisc::CStatusMessageList getReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;

View File

@@ -16,7 +16,6 @@
#include "blackmisc/simulation/aircraftmodellist.h" #include "blackmisc/simulation/aircraftmodellist.h"
#include "blackmisc/simulation/airspaceaircraftsnapshot.h" #include "blackmisc/simulation/airspaceaircraftsnapshot.h"
#include "blackmisc/simulation/interpolator.h" #include "blackmisc/simulation/interpolator.h"
#include "blackmisc/simulation/interpolationhints.h"
#include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/simulation/simulatedaircraft.h"
#include "blackmisc/pq/physicalquantity.h" #include "blackmisc/pq/physicalquantity.h"
#include "blackmisc/simplecommandparser.h" #include "blackmisc/simplecommandparser.h"
@@ -571,7 +570,6 @@ namespace BlackCore
CStatusMessageList msgs; CStatusMessageList msgs;
if (!CBuildConfig::isLocalDeveloperDebugBuild()) { return msgs; } if (!CBuildConfig::isLocalDeveloperDebugBuild()) { return msgs; }
if (!m_addAgainAircraftWhenRemoved.isEmpty()) { msgs.push_back(CStatusMessage(this).error("m_addAgainAircraftWhenRemoved not empty: '%1'") << m_addAgainAircraftWhenRemoved.getCallsignStrings(true).join(", ")); } if (!m_addAgainAircraftWhenRemoved.isEmpty()) { msgs.push_back(CStatusMessage(this).error("m_addAgainAircraftWhenRemoved not empty: '%1'") << m_addAgainAircraftWhenRemoved.getCallsignStrings(true).join(", ")); }
if (!m_hints.isEmpty()) { msgs.push_back(CStatusMessage(this).error("m_hints not empty: '%1'") << CCallsignSet(m_hints.keys()).getCallsignStrings(true).join(", ")); }
return msgs; return msgs;
} }
@@ -679,7 +677,6 @@ namespace BlackCore
// rendering related stuff // rendering related stuff
m_addAgainAircraftWhenRemoved.clear(); m_addAgainAircraftWhenRemoved.clear();
m_callsignsToBeRendered.clear(); m_callsignsToBeRendered.clear();
m_hints.clear();
this->resetHighlighting(); this->resetHighlighting();
this->resetAircraftStatistics(); this->resetAircraftStatistics();
@@ -762,11 +759,9 @@ namespace BlackCore
static const QString sep("\n"); static const QString sep("\n");
if (s.tsCurrent > 0) if (s.tsCurrent > 0)
{ {
dm = QStringLiteral("Hints: ") % s.usedHints.asString(false, true) % dm = QStringLiteral("Setup: ") % s.usedSetup.toQString(true) %
QStringLiteral("\n") %
QStringLiteral("Setup: ") % s.usedSetup.toQString(true) %
QStringLiteral("\n\n") % QStringLiteral("\n\n") %
QStringLiteral("Situation: ") % s.toQString(false, false, true, true, true, true, sep); QStringLiteral("Situation: ") % s.toQString(false, true, true, true, true, sep);
} }
if (p.tsCurrent > 0) { dm += (dm.isEmpty() ? QStringLiteral("") : QStringLiteral("\n\n")) % QStringLiteral("Parts: ") % p.toQString(sep); } if (p.tsCurrent > 0) { dm += (dm.isEmpty() ? QStringLiteral("") : QStringLiteral("\n\n")) % QStringLiteral("Parts: ") % p.toQString(sep); }
if (!dm.isEmpty()) if (!dm.isEmpty())

View File

@@ -27,7 +27,6 @@
#include "blackmisc/simulation/simulatorinternals.h" #include "blackmisc/simulation/simulatorinternals.h"
#include "blackmisc/simulation/settings/simulatorsettings.h" #include "blackmisc/simulation/settings/simulatorsettings.h"
#include "blackmisc/simulation/interpolationrenderingsetup.h" #include "blackmisc/simulation/interpolationrenderingsetup.h"
#include "blackmisc/simulation/interpolationhints.h"
#include "blackmisc/simulation/interpolationlogger.h" #include "blackmisc/simulation/interpolationlogger.h"
#include "blackmisc/aviation/callsignset.h" #include "blackmisc/aviation/callsignset.h"
#include "blackmisc/pq/length.h" #include "blackmisc/pq/length.h"
@@ -221,7 +220,6 @@ namespace BlackCore
// some optional functionality which can be used by the simulators as needed // some optional functionality which can be used by the simulators as needed
BlackMisc::Simulation::CSimulatedAircraftList m_addAgainAircraftWhenRemoved; //!< add this model again when removed, normally used to change model BlackMisc::Simulation::CSimulatedAircraftList m_addAgainAircraftWhenRemoved; //!< add this model again when removed, normally used to change model
QHash<BlackMisc::Aviation::CCallsign, BlackMisc::Simulation::CInterpolationHints> m_hints; //!< hints for callsign, contains last ground elevation fetched
// weather // weather
bool m_isWeatherActivated = false; //!< Is simulator weather activated? bool m_isWeatherActivated = false; //!< Is simulator weather activated?

View File

@@ -159,7 +159,6 @@ namespace BlackMisc
GlobalIndexCAtcStationsSettings = 14800, GlobalIndexCAtcStationsSettings = 14800,
GlobalIndexRawFsdMessageSettings = 14900, GlobalIndexRawFsdMessageSettings = 14900,
GlobalIndexCInterpolatioRenderingSetup = 16000, GlobalIndexCInterpolatioRenderingSetup = 16000,
GlobalIndexCInterpolationHints = 16100,
GlobalIndexSwiftPilotClient = 17000, GlobalIndexSwiftPilotClient = 17000,
GlobalIndexSwiftCore = 17100, GlobalIndexSwiftCore = 17100,
GlobalIndexSwiftLauncher = 17200, GlobalIndexSwiftLauncher = 17200,

View File

@@ -1,223 +0,0 @@
/* Copyright (C) 2016
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "interpolationhints.h"
#include "interpolationlogger.h"
#include "blackmisc/aviation/aircraftsituation.h"
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Geo;
using namespace BlackMisc::PhysicalQuantities;
#include <QStringBuilder>
namespace BlackMisc
{
namespace Simulation
{
CInterpolationHints::CInterpolationHints() { }
CInterpolationHints::CInterpolationHints(bool isVtolAircraft) : m_isVtol(isVtolAircraft)
{ }
CInterpolationHints::CInterpolationHints(bool isVtolAircraft, bool hasParts, bool log) :
m_isVtol(isVtolAircraft), m_hasParts(hasParts), m_logInterpolation(log)
{ }
const CElevationPlane &CInterpolationHints::getElevationPlane(ICoordinateGeodetic &reference, const CLength &radius, SituationLog *log) const
{
if (m_elevationPlane.isNull())
{
if (log)
{
static const QString lm("By provider (no valid plane)");
log->elevationInfo = lm;
}
return CElevationPlane::null();
}
const CLength d = reference.calculateGreatCircleDistance(m_elevationPlane);
if (d <= radius)
{
if (log)
{
static const QString lm("Using elevation plane, distance: %1");
log->elevationInfo = lm.arg(d.valueRoundedWithUnit(CLengthUnit::m(), 1));
}
return m_elevationPlane;
}
else
{
if (log)
{
static const QString lm("Invalid elevation plane, distance: %1");
log->elevationInfo = lm.arg(d.valueRoundedWithUnit(CLengthUnit::m(), 1));
}
return CElevationPlane::null();
}
}
CAltitude CInterpolationHints::getGroundElevation(const CAircraftSituation &situation, bool useProvider, bool forceProvider, SituationLog *log) const
{
return this->getGroundElevation(situation, CLength::null(), useProvider, forceProvider, log);
}
CAltitude CInterpolationHints::getGroundElevation(const CAircraftSituation &situation, const CLength &validRadius, bool useProvider, bool forceProvider, SituationLog *log) const
{
Q_ASSERT_X(!(forceProvider && !useProvider), Q_FUNC_INFO, "Invalid parameter combination");
if (forceProvider && useProvider && m_elevationProvider)
{
if (log)
{
static const QString lm("By provider (forced)");
log->elevationInfo = lm;
}
Q_ASSERT_X(false, Q_FUNC_INFO, "Elevation provider must no longer be used");
return m_elevationProvider(situation);
}
const CLength radius = CLength::maxValue(validRadius, m_elevationPlane.getRadius());
const bool validPlane = m_elevationPlane.isWithinRange(situation, radius);
if (!validPlane && useProvider && m_elevationProvider)
{
if (log)
{
static const QString lm("By provider (no valid plane)");
log->elevationInfo = lm;
}
return m_elevationProvider(situation);
}
if (validPlane)
{
if (log)
{
static const QString lm("Using elevation plane, radius: %1");
log->elevationInfo = lm.arg(radius.valueRoundedWithUnit(CLengthUnit::m(), 1));
}
return m_elevationPlane.getAltitude();
}
if (log)
{
static const QString lm("Not using provider, no valid plane");
log->elevationInfo = lm;
}
return CAltitude::null();
}
CAltitude CInterpolationHints::getGroundElevation(const CAircraftSituation &situation, const CLength &validRadius, SituationLog *log) const
{
return this->getGroundElevation(situation, validRadius, false, false, log);
}
CAltitude CInterpolationHints::getGroundElevation(const CAircraftSituation &situation, SituationLog *log) const
{
return this->getGroundElevation(situation, CLength::null(), log);
}
void CInterpolationHints::resetElevationPlane()
{
m_elevationPlane = CElevationPlane();
}
bool CInterpolationHints::isWithinRange(const Geo::ICoordinateGeodetic &coordinate) const
{
if (m_elevationPlane.isNull()) { return false; }
return m_elevationPlane.isWithinRange(coordinate);
}
const CLength &CInterpolationHints::getCGAboveGroundOrZero() const
{
static const CLength zero;
return this->hasCGAboveGround() ? this->getCGAboveGround() : zero;
}
void CInterpolationHints::setAircraftParts(const CAircraftParts &parts, bool hasParts)
{
m_hasParts = hasParts;
m_aircraftParts = parts;
}
bool CInterpolationHints::hasElevationProvider() const
{
return static_cast<bool>(m_elevationProvider);
}
CVariant CInterpolationHints::propertyByIndex(const CPropertyIndex &index) const
{
if (index.isMyself()) { return CVariant::from(*this); }
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexCenterOfGravity: return m_cgAboveGround.propertyByIndex(index.copyFrontRemoved());
case IndexElevationPlane: return m_elevationPlane.propertyByIndex(index.copyFrontRemoved());
case IndexIsVtolAircraft: return CVariant::fromValue(m_isVtol);
default: return CValueObject::propertyByIndex(index);
}
}
void CInterpolationHints::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
{
if (index.isMyself()) { (*this) = variant.to<CInterpolationHints>(); return; }
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexCenterOfGravity:
m_cgAboveGround.setPropertyByIndex(index.copyFrontRemoved(), variant);
break;
case IndexElevationPlane:
m_elevationPlane.setPropertyByIndex(index.copyFrontRemoved(), variant);
break;
case IndexIsVtolAircraft:
m_isVtol = variant.toBool();
break;
default:
CValueObject::setPropertyByIndex(index, variant);
break;
}
}
QString CInterpolationHints::convertToQString(bool i18n) const
{
Q_UNUSED(i18n);
return this->asString(true, true);
}
QString CInterpolationHints::asString(bool withParts, bool withElevationPlane) const
{
return
QStringLiteral("VTOL: ") % boolToYesNo(m_isVtol) %
QStringLiteral(" parts: ") % boolToYesNo(m_hasParts) %
(
withParts && m_hasParts ?
QStringLiteral(" parts: ") % m_aircraftParts.toQString(true) :
QStringLiteral("")
) %
QStringLiteral(" CG: ") % m_cgAboveGround.valueRoundedWithUnit(CLengthUnit::m(), 1) %
(
withElevationPlane ?
QStringLiteral(" elv.plane: ") % m_elevationPlane.toQString(true) :
QStringLiteral(" elv.plane: ") % boolToNullNotNull(m_elevationPlane.isNull())
) %
QStringLiteral(" elv.pr.: ") % boolToYesNo(m_elevationProvider ? true : false);
}
QString CInterpolationHints::debugInfo(const CElevationPlane &deltaElevation) const
{
static const QString s("Lat: %1 Lng: %2 Elv: %3");
if (m_elevationPlane.isNull() || deltaElevation.isNull()) return "null";
return s.arg(
(deltaElevation.latitude() - m_elevationPlane.latitude()).valueRoundedWithUnit(CAngleUnit::deg(), 10),
(deltaElevation.longitude() - m_elevationPlane.longitude()).valueRoundedWithUnit(CAngleUnit::deg(), 10),
(deltaElevation.geodeticHeight() - m_elevationPlane.geodeticHeight()).valueRoundedWithUnit(CLengthUnit::ft(), 2)
);
}
} // namespace
} // namespace

View File

@@ -1,179 +0,0 @@
/* Copyright (C) 2016
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKMISC_SIMULATION_INTERPOLATIONHINTS_H
#define BLACKMISC_SIMULATION_INTERPOLATIONHINTS_H
#include "blackmisc/blackmiscexport.h"
#include "blackmisc/geo/elevationplane.h"
#include "blackmisc/valueobject.h"
#include "blackmisc/aviation/aircraftparts.h"
namespace BlackMisc
{
namespace Aviation { class CAircraftSituation; }
namespace Simulation
{
struct SituationLog;
//! Hints for interpolator such as ground elevation
class BLACKMISC_EXPORT CInterpolationHints : public CValueObject<CInterpolationHints>
{
public:
//! Property indexes
enum ColumnIndex
{
IndexElevationPlane = CPropertyIndex::GlobalIndexCInterpolationHints,
IndexCenterOfGravity,
IndexIsVtolAircraft
};
//! Default constructor.
CInterpolationHints();
//! Constructor
CInterpolationHints(bool isVtolAircraft);
//! Constructor
CInterpolationHints(bool isVtolAircraft, bool hasParts, bool log);
//! Get elevation plane
const Geo::CElevationPlane &getElevationPlane() const { return m_elevationPlane;}
//! Get elevation plane
const Geo::CElevationPlane &getElevationPlane(Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &radius, SituationLog *log = nullptr) const;
//! Set elevation
//! \remark used to store a ground elevation and use it as well for nearby situatons
void setElevationPlane(const Geo::CElevationPlane &elevation) { m_elevationPlane = elevation; }
//! Elevation plane set to null
void resetElevationPlane();
private:
//! \todo KB 2018-03 ground flag refactoring
//! Get elevation from CInterpolationHints::getElevationProvider or CInterpolationHints::getElevation
//! \remark avoid unnecessary calls on XPlane (calling elevation provider)
//! \param situation where to check
//! \param useProvider using the provider if available
//! \param forceProvider use the provider and ignore any elevation plane
//! \param log optional chance to write info about elevation
//! \see setElevationProvider
//! \see setElevationPlane
//! \deprecated
Aviation::CAltitude getGroundElevation(const Aviation::CAircraftSituation &situation, bool useProvider, bool forceProvider = false, SituationLog *log = nullptr) const;
//! Get elevation from CInterpolationHints::getElevationProvider or CInterpolationHints::getElevation
//! \remark if validRadius is >= Geo::CElevationPlane::radius use validRadius
//! \deprecated
Aviation::CAltitude getGroundElevation(const Aviation::CAircraftSituation &situation, const PhysicalQuantities::CLength &validRadius, bool useProvider, bool forceProvider = false, SituationLog *log = nullptr) const;
//! Get ground elevation by using the elevation plane
//! \deprecated
Aviation::CAltitude getGroundElevation(const Aviation::CAircraftSituation &situation, const PhysicalQuantities::CLength &validRadius, SituationLog *log = nullptr) const;
//! Get ground elevation by using the elevation plane
//! \deprecated
Aviation::CAltitude getGroundElevation(const Aviation::CAircraftSituation &situation, SituationLog *log = nullptr) const;
public:
//! Check if elevation is within radius and can be used
bool isWithinRange(const Geo::ICoordinateGeodetic &coordinate) const;
//! Get CG above ground
const PhysicalQuantities::CLength &getCGAboveGround() const { return m_cgAboveGround;}
//! Get CG above ground or 0 ("Zero")
const PhysicalQuantities::CLength &getCGAboveGroundOrZero() const;
//! Has CG above ground
bool hasCGAboveGround() const { return m_cgAboveGround.isNull(); }
//! Set CG above ground
void setCGAboveGround(const PhysicalQuantities::CLength &cgAboveGround) { m_cgAboveGround = cgAboveGround; }
//! VTOL aircraft?
bool isVtolAircraft() const { return m_isVtol; }
//! VTOL aircraft
void setVtolAircraft(bool vtol) { m_isVtol = vtol; }
//! Log interpolation?
bool isLoggingInterpolation() const { return m_logInterpolation; }
//! Log interpolation?
void setLoggingInterpolation(bool log) { m_logInterpolation = log; }
//! Has valid aircraft parts?
bool hasAircraftParts() const { return m_hasParts; }
//! Aircraft parts required for interpolation
Aviation::CAircraftParts getAircraftParts() const { return m_aircraftParts; }
//! Set aircraft parts required for interpolation if any
//! \remark when used to reset value (default object) use hasParts false. Needed as there is no null parts object
void setAircraftParts(const Aviation::CAircraftParts &parts, bool hasParts = true);
//! Function object that can obtain ground elevation
using ElevationProvider = std::function<Aviation::CAltitude(const Aviation::CAircraftSituation &)>;
//! Has elevation provider?
//! \deprecated
bool hasElevationProvider() const;
//! Set function object that can obtain ground elevation
//! \remark either a provider can be used or an elevation plan can be set
//! \see setElevationPlane
//! \see getGroundElevation
//! \deprecated
void setElevationProvider(const ElevationProvider &ep) { m_elevationProvider = ep; }
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
CVariant propertyByIndex(const CPropertyIndex &index) const;
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
//! \copydoc BlackMisc::Mixin::String::toQString
QString convertToQString(bool i18n = false) const;
//! Formatted as string
QString asString(bool withParts, bool withElevationPlane) const;
//! For debugging
QString debugInfo(const Geo::CElevationPlane &deltaElevation) const;
private:
bool m_isVtol = false; //!< VTOL aircraft?
bool m_hasParts = false; //!< Has valid aircraft parts?
bool m_logInterpolation = false; //!< Log.interpolation
Aviation::CAircraftParts m_aircraftParts; //!< Aircraft parts
Geo::CElevationPlane m_elevationPlane; //!< Aircraft's elevation if available
ElevationProvider m_elevationProvider; //!< Provider of ground elevation (lazy computation)
PhysicalQuantities::CLength m_cgAboveGround { 0, nullptr }; //!< center of gravity above ground
BLACK_METACLASS(
CInterpolationHints,
BLACK_METAMEMBER(isVtol),
BLACK_METAMEMBER(elevationPlane),
BLACK_METAMEMBER(cgAboveGround),
BLACK_METAMEMBER(hasParts),
BLACK_METAMEMBER(aircraftParts),
BLACK_METAMEMBER(logInterpolation)
// elevationProvider not included
);
};
} // namespace
} // namespace
Q_DECLARE_METATYPE(BlackMisc::Simulation::CInterpolationHints)
#endif // guard

View File

@@ -407,7 +407,7 @@ namespace BlackMisc
} }
QString SituationLog::toQString( QString SituationLog::toQString(
bool withHints, bool withSetup, bool withSetup,
bool withCurrentSituation, bool withCurrentSituation,
bool withElevation, bool withOtherPositions, bool withDeltaTimes, const QString &separator) const bool withElevation, bool withOtherPositions, bool withDeltaTimes, const QString &separator) const
{ {
@@ -419,11 +419,6 @@ namespace BlackMisc
QStringLiteral(" | type: ") % this->interpolationType() % QStringLiteral(" | type: ") % this->interpolationType() %
QStringLiteral(" | gnd.fa.: ") % QString::number(groundFactor) % QStringLiteral(" | gnd.fa.: ") % QString::number(groundFactor) %
QStringLiteral(" | #nw.sit.: ") % QString::number(noNetworkSituations) % QStringLiteral(" | #nw.sit.: ") % QString::number(noNetworkSituations) %
(
withHints ?
separator % QStringLiteral("hints: ") % usedHints.asString(false, true) :
QStringLiteral("")
) %
( (
withSetup ? withSetup ?
separator % QStringLiteral("setup: ") % usedSetup.toQString(true) : separator % QStringLiteral("setup: ") % usedSetup.toQString(true) :

View File

@@ -13,7 +13,6 @@
#define BLACKMISC_SIMULATION_INTERPOLATIONLOGGER_H #define BLACKMISC_SIMULATION_INTERPOLATIONLOGGER_H
#include "interpolationrenderingsetup.h" #include "interpolationrenderingsetup.h"
#include "interpolationhints.h"
#include "blackmisc/simulation/remoteaircraftprovider.h" #include "blackmisc/simulation/remoteaircraftprovider.h"
#include "blackmisc/aviation/aircraftpartslist.h" #include "blackmisc/aviation/aircraftpartslist.h"
#include "blackmisc/aviation/aircraftsituationlist.h" #include "blackmisc/aviation/aircraftsituationlist.h"
@@ -48,7 +47,6 @@ namespace BlackMisc
Aviation::CAircraftSituation situationCurrent; //!< interpolated situation Aviation::CAircraftSituation situationCurrent; //!< interpolated situation
PhysicalQuantities::CLength cgAboveGround; //!< center of gravity PhysicalQuantities::CLength cgAboveGround; //!< center of gravity
CInterpolationAndRenderingSetupPerCallsign usedSetup; //!< used setup CInterpolationAndRenderingSetupPerCallsign usedSetup; //!< used setup
CInterpolationHints usedHints; //!< hints
//! Delta time between interpolation and current time //! Delta time between interpolation and current time
double deltaCurrentToInterpolatedTime() const double deltaCurrentToInterpolatedTime() const
@@ -72,10 +70,9 @@ namespace BlackMisc
} }
//! To string //! To string
QString toQString( QString toQString(bool withSetup,
bool withHints, bool withSetup, bool withCurrentSituation, bool withElevation,
bool withCurrentSituation, bool withElevation, bool withOtherPositions, bool withDeltaTimes, const QString &separator = {" "}) const;
bool withOtherPositions, bool withDeltaTimes, const QString &separator = {" "}) const;
}; };
//! Log entry for parts interpolation //! Log entry for parts interpolation

View File

@@ -9,7 +9,6 @@
#include "interpolator.h" #include "interpolator.h"
#include "blackconfig/buildconfig.h" #include "blackconfig/buildconfig.h"
#include "blackmisc/simulation/interpolationhints.h"
#include "blackmisc/simulation/interpolationlogger.h" #include "blackmisc/simulation/interpolationlogger.h"
#include "blackmisc/simulation/interpolatorlinear.h" #include "blackmisc/simulation/interpolatorlinear.h"
#include "blackmisc/simulation/interpolatorspline.h" #include "blackmisc/simulation/interpolatorspline.h"
@@ -54,14 +53,14 @@ namespace BlackMisc
template <typename Derived> template <typename Derived>
CAircraftSituation CInterpolator<Derived>::getInterpolatedSituation( CAircraftSituation CInterpolator<Derived>::getInterpolatedSituation(
qint64 currentTimeMsSinceEpoc, qint64 currentTimeMsSinceEpoc,
const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints, const CInterpolationAndRenderingSetupPerCallsign &setup,
CInterpolationStatus &status) CInterpolationStatus &status)
{ {
Q_ASSERT_X(!m_callsign.isEmpty(), Q_FUNC_INFO, "Missing callsign"); Q_ASSERT_X(!m_callsign.isEmpty(), Q_FUNC_INFO, "Missing callsign");
// this code is used by linear and spline interpolator // this code is used by linear and spline interpolator
status.reset(); status.reset();
const bool doLogging = this->hasAttachedLogger() && hints.isLoggingInterpolation(); const bool doLogging = this->hasAttachedLogger() && setup.logInterpolation();
SituationLog log; SituationLog log;
SituationLog *logP = doLogging ? &log : nullptr; SituationLog *logP = doLogging ? &log : nullptr;
@@ -81,15 +80,15 @@ namespace BlackMisc
// * As XP uses lazy init we will call getGroundElevation only when needed // * As XP uses lazy init we will call getGroundElevation only when needed
// * default here via getElevationPlane // * default here via getElevationPlane
// CAltitude currentGroundElevation(hints.getGroundElevation(currentSituation, currentSituation.getDistancePerTime(1000), true, false, logP)); // CAltitude currentGroundElevation(hints.getGroundElevation(currentSituation, currentSituation.getDistancePerTime(1000), true, false, logP));
const CElevationPlane currentGroundElevation = hints.getElevationPlane(currentSituation, currentSituation.getDistancePerTime(1000), logP); const CElevationPlane currentGroundElevation = this->findClosestElevationWithinRange(currentSituation, currentSituation.getDistancePerTime(1000));
currentSituation.setGroundElevation(currentGroundElevation); // set as default currentSituation.setGroundElevationChecked(currentGroundElevation); // set as default
// data, split situations by time // data, split situations by time
if (currentTimeMsSinceEpoc < 0) { currentTimeMsSinceEpoc = QDateTime::currentMSecsSinceEpoch(); } if (currentTimeMsSinceEpoc < 0) { currentTimeMsSinceEpoc = QDateTime::currentMSecsSinceEpoch(); }
// interpolant function from derived class // interpolant function from derived class
// CInterpolatorLinear::Interpolant or CInterpolatorSpline::Interpolant // CInterpolatorLinear::Interpolant or CInterpolatorSpline::Interpolant
const auto interpolant = derived()->getInterpolant(currentTimeMsSinceEpoc, setup, hints, status, log); const auto interpolant = derived()->getInterpolant(currentTimeMsSinceEpoc, setup, status, log);
// succeeded so far? // succeeded so far?
if (!status.isInterpolated()) if (!status.isInterpolated())
@@ -99,12 +98,12 @@ namespace BlackMisc
} }
// use derived interpolant function // use derived interpolant function
currentSituation.setPosition(interpolant.interpolatePosition(setup, hints)); currentSituation.setPosition(interpolant.interpolatePosition(setup));
currentSituation.setAltitude(interpolant.interpolateAltitude(setup, hints)); currentSituation.setAltitude(interpolant.interpolateAltitude(setup));
currentSituation.setMSecsSinceEpoch(interpolant.getInterpolatedTime()); currentSituation.setMSecsSinceEpoch(interpolant.getInterpolatedTime());
// PBH before ground so we can use PBH in guessing ground // PBH before ground so we can use PBH in guessing ground
if (setup.isForcingFullInterpolation() || hints.isVtolAircraft() || status.isInterpolated()) if (setup.isForcingFullInterpolation() || status.isInterpolated())
{ {
const auto pbh = interpolant.pbh(); const auto pbh = interpolant.pbh();
currentSituation.setHeading(pbh.getHeading()); currentSituation.setHeading(pbh.getHeading());
@@ -118,9 +117,9 @@ namespace BlackMisc
constexpr double NoGroundFactor = -1; constexpr double NoGroundFactor = -1;
double groundFactor = NoGroundFactor; double groundFactor = NoGroundFactor;
if (hints.hasAircraftParts()) if (setup.isAircraftPartsEnabled())
{ {
groundFactor = hints.getAircraftParts().isOnGroundInterpolated(); // groundFactor = hints.getAircraftParts().isOnGroundInterpolated();
if (groundFactor > 0.0) if (groundFactor > 0.0)
{ {
// if not having an ground elevation yet, we fetch from provider (if there is a provider) // if not having an ground elevation yet, we fetch from provider (if there is a provider)
@@ -131,8 +130,9 @@ namespace BlackMisc
if (!currentGroundElevation.isNull()) if (!currentGroundElevation.isNull())
{ {
Q_ASSERT_X(currentGroundElevation.getReferenceDatum() == CAltitude::MeanSeaLevel, Q_FUNC_INFO, "Need MSL value"); Q_ASSERT_X(currentGroundElevation.getAltitude().getReferenceDatum() == CAltitude::MeanSeaLevel, Q_FUNC_INFO, "Need MSL value");
const CAltitude groundElevationCG = currentGroundElevation.withOffset(hints.getCGAboveGround()); const CLength cg = this->getCG(m_callsign);
const CAltitude groundElevationCG = currentGroundElevation.getAltitude().withOffset(cg);
currentSituation.setGroundElevationChecked(currentGroundElevation); currentSituation.setGroundElevationChecked(currentGroundElevation);
// alt = ground + aboveGround * groundFactor // alt = ground + aboveGround * groundFactor
// = ground + (altitude - ground) * groundFactor // = ground + (altitude - ground) * groundFactor
@@ -146,7 +146,7 @@ namespace BlackMisc
// depending on ground factor set ground flag and reliability // depending on ground factor set ground flag and reliability
// it will use the hints ground flag or elevation/CG or guessing // it will use the hints ground flag or elevation/CG or guessing
CInterpolator::setGroundFlagFromInterpolator(hints, groundFactor, currentSituation); // CInterpolator::setGroundFlagFromInterpolator(hints, groundFactor, currentSituation);
// we transfer ground elevation for future usage // we transfer ground elevation for future usage
if (currentSituation.hasGroundElevation()) if (currentSituation.hasGroundElevation())
@@ -165,7 +165,6 @@ namespace BlackMisc
log.callsign = m_callsign; log.callsign = m_callsign;
log.groundFactor = groundFactor; log.groundFactor = groundFactor;
log.situationCurrent = currentSituation; log.situationCurrent = currentSituation;
log.usedHints = hints;
log.usedSetup = setup; log.usedSetup = setup;
m_logger->logInterpolation(log); m_logger->logInterpolation(log);
} }
@@ -412,7 +411,7 @@ namespace BlackMisc
} }
template <typename Derived> template <typename Derived>
void CInterpolator<Derived>::setGroundFlagFromInterpolator(const CInterpolationHints &hints, double groundFactor, CAircraftSituation &situation) void CInterpolator<Derived>::setGroundFlagFromInterpolator(double groundFactor, CAircraftSituation &situation) const
{ {
// by interpolation // by interpolation
if (groundFactor >= 1.0) if (groundFactor >= 1.0)
@@ -428,15 +427,17 @@ namespace BlackMisc
// on elevation and CG // on elevation and CG
// remark: to some extend redundant as situation.getCorrectedAltitude() already corrects altitude // remark: to some extend redundant as situation.getCorrectedAltitude() already corrects altitude
Q_ASSERT_X(!m_callsign.isEmpty(), Q_FUNC_INFO, "Need callsign");
if (situation.hasGroundElevation()) if (situation.hasGroundElevation())
{ {
static const CLength onGroundThresholdLimit(1.0, CLengthUnit::m()); static const CLength onGroundThresholdLimit(1.0, CLengthUnit::m());
static const CLength notOnGroundThresholdLimit(10.0, CLengthUnit::m()); // upper boundary static const CLength notOnGroundThresholdLimit(10.0, CLengthUnit::m()); // upper boundary
CLength offset = onGroundThresholdLimit; // very small offset from allowed CLength offset = onGroundThresholdLimit; // very small offset from allowed
CAircraftSituation::OnGroundReliability reliability = CAircraftSituation::OnGroundByElevation; CAircraftSituation::OnGroundDetails reliability = CAircraftSituation::OnGroundByElevation;
if (hints.hasCGAboveGround()) CLength cg = this->getCG(m_callsign);
if (!cg.isNull())
{ {
offset += hints.getCGAboveGround(); offset += cg;
reliability = CAircraftSituation::OnGroundByElevationAndCG; reliability = CAircraftSituation::OnGroundByElevationAndCG;
} }
else else
@@ -465,7 +466,7 @@ namespace BlackMisc
} }
// for VTOL aircraft we give up // for VTOL aircraft we give up
if (hints.isVtolAircraft()) if (this->isVtolAircraft(m_callsign))
{ {
situation.setOnGround(CAircraftSituation::OnGroundSituationUnknown, CAircraftSituation::OnGroundReliabilityNoSet); situation.setOnGround(CAircraftSituation::OnGroundSituationUnknown, CAircraftSituation::OnGroundReliabilityNoSet);
return; return;

View File

@@ -14,6 +14,8 @@
#include "interpolationrenderingsetup.h" #include "interpolationrenderingsetup.h"
#include "blackmisc/simulation/remoteaircraftprovider.h" #include "blackmisc/simulation/remoteaircraftprovider.h"
#include "blackmisc/simulation/interpolationsetupprovider.h"
#include "blackmisc/simulation/simulationenvironmentprovider.h"
#include "blackmisc/aviation/aircraftpartslist.h" #include "blackmisc/aviation/aircraftpartslist.h"
#include "blackmisc/aviation/aircraftsituation.h" #include "blackmisc/aviation/aircraftsituation.h"
#include "blackmisc/aviation/aircraftpartslist.h" #include "blackmisc/aviation/aircraftpartslist.h"
@@ -29,7 +31,6 @@ namespace BlackMisc
namespace Aviation { class CCallsign; } namespace Aviation { class CCallsign; }
namespace Simulation namespace Simulation
{ {
class CInterpolationHints;
class CInterpolationLogger; class CInterpolationLogger;
class CInterpolatorLinear; class CInterpolatorLinear;
class CInterpolatorSpline; class CInterpolatorSpline;
@@ -38,14 +39,18 @@ namespace BlackMisc
//! Interpolator, calculation inbetween positions //! Interpolator, calculation inbetween positions
template <typename Derived> template <typename Derived>
class CInterpolator : public QObject class CInterpolator :
public CSimulationEnvironmentAware,
public CInterpolationSetupAware,
public CRemoteAircraftAware,
public QObject
{ {
public: public:
//! Log categories //! Log categories
const CLogCategoryList &getLogCategories(); const CLogCategoryList &getLogCategories();
//! Current interpolated situation //! Current interpolated situation
Aviation::CAircraftSituation getInterpolatedSituation(qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints, CInterpolationStatus &status); Aviation::CAircraftSituation getInterpolatedSituation(qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup, CInterpolationStatus &status);
//! Parts before given offset time (aka pending parts) //! Parts before given offset time (aka pending parts)
Aviation::CAircraftParts getInterpolatedParts( Aviation::CAircraftParts getInterpolatedParts(
@@ -78,7 +83,6 @@ namespace BlackMisc
} }
//! Attach an observer to read the interpolator's state for debugging //! Attach an observer to read the interpolator's state for debugging
//! \remark situation logging requires CInterpolationHints::isLoggingInterpolation to be \c true
//! \remark parts logging has a \c bool \c log flag //! \remark parts logging has a \c bool \c log flag
void attachLogger(CInterpolationLogger *logger) { m_logger = logger; } void attachLogger(CInterpolationLogger *logger) { m_logger = logger; }
@@ -112,7 +116,7 @@ namespace BlackMisc
CInterpolator(const QString &objectName, const Aviation::CCallsign &callsign, QObject *parent); CInterpolator(const QString &objectName, const Aviation::CCallsign &callsign, QObject *parent);
//! Set on ground flag //! Set on ground flag
static void setGroundFlagFromInterpolator(const CInterpolationHints &hints, double groundFactor, Aviation::CAircraftSituation &situation); void setGroundFlagFromInterpolator(double groundFactor, Aviation::CAircraftSituation &situation) const;
private: private:
CInterpolationLogger *m_logger = nullptr; CInterpolationLogger *m_logger = nullptr;

View File

@@ -15,7 +15,6 @@
#include "blackmisc/aviation/aircraftparts.h" #include "blackmisc/aviation/aircraftparts.h"
#include "blackmisc/aviation/aircraftsituation.h" #include "blackmisc/aviation/aircraftsituation.h"
#include "blackmisc/aviation/callsign.h" #include "blackmisc/aviation/callsign.h"
#include "blackmisc/simulation/interpolationhints.h"
#include "blackmisc/simulation/interpolationlogger.h" #include "blackmisc/simulation/interpolationlogger.h"
#include "blackmisc/simulation/interpolationrenderingsetup.h" #include "blackmisc/simulation/interpolationrenderingsetup.h"
#include "blackmisc/simulation/interpolator.h" #include "blackmisc/simulation/interpolator.h"
@@ -38,11 +37,11 @@ namespace BlackMisc
//! \copydoc CInterpolator::getInterpolatedSituation //! \copydoc CInterpolator::getInterpolatedSituation
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation( BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
qint64, const CInterpolationAndRenderingSetupGlobal &, const CInterpolationHints &, CInterpolationStatus &) { return {}; } qint64, const CInterpolationAndRenderingSetupPerCallsign &, CInterpolationStatus &) { return {}; }
//! \copydoc CInterpolator::getInterpolatedParts //! \copydoc CInterpolator::getInterpolatedParts
BlackMisc::Aviation::CAircraftParts getInterpolatedParts( BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
qint64, const CInterpolationAndRenderingSetupGlobal &, CPartsStatus &, bool = false) const { return {}; } qint64, const CInterpolationAndRenderingSetupPerCallsign &, CPartsStatus &, bool = false) const { return {}; }
//! \copydoc CInterpolator::addAircraftSituation //! \copydoc CInterpolator::addAircraftSituation
void addAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &) {} void addAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &) {}

View File

@@ -14,7 +14,6 @@
#include "blackmisc/geo/coordinategeodetic.h" #include "blackmisc/geo/coordinategeodetic.h"
#include "blackmisc/pq/length.h" #include "blackmisc/pq/length.h"
#include "blackmisc/pq/physicalquantity.h" #include "blackmisc/pq/physicalquantity.h"
#include "blackmisc/simulation/interpolationhints.h"
#include "blackmisc/logmessage.h" #include "blackmisc/logmessage.h"
#include "blackmisc/compare.h" #include "blackmisc/compare.h"
#include "blackmisc/verify.h" #include "blackmisc/verify.h"
@@ -49,11 +48,12 @@ namespace BlackMisc
m_pbh(m_simulationTimeFraction, situation1, situation2) m_pbh(m_simulationTimeFraction, situation1, situation2)
{} {}
CInterpolatorLinear::Interpolant CInterpolatorLinear::getInterpolant(qint64 currentTimeMsSinceEpoc, CInterpolatorLinear::Interpolant CInterpolatorLinear::getInterpolant(
const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints, CInterpolationStatus &status, SituationLog &log) const qint64 currentTimeMsSinceEpoc,
const CInterpolationAndRenderingSetupPerCallsign &setup,
CInterpolationStatus &status, SituationLog &log) const
{ {
Q_UNUSED(setup); Q_UNUSED(setup);
Q_UNUSED(hints);
status.reset(); status.reset();
// with the latest updates of T243 the order and the offsets are supposed to be correct // with the latest updates of T243 the order and the offsets are supposed to be correct
@@ -118,11 +118,10 @@ namespace BlackMisc
// take hint into account to calculate elevation and above ground level // take hint into account to calculate elevation and above ground level
// do not call for XP (lazy init) // do not call for XP (lazy init)
if (!hints.hasElevationProvider()) const CElevationPlane planeOld = this->findClosestElevationWithinRange(oldSituation, CElevationPlane::singlePointRadius());
{ const CElevationPlane planeNew = this->findClosestElevationWithinRange(newSituation, CElevationPlane::singlePointRadius());
oldSituation.setGroundElevationChecked(hints.getElevationPlane()); oldSituation.setGroundElevationChecked(planeOld);
newSituation.setGroundElevationChecked(hints.getElevationPlane()); newSituation.setGroundElevationChecked(planeNew);
}
CAircraftSituation currentSituation(oldSituation); // also sets ground elevation if available CAircraftSituation currentSituation(oldSituation); // also sets ground elevation if available
@@ -144,7 +143,7 @@ namespace BlackMisc
currentSituation.setMSecsSinceEpoch(interpolatedTime); currentSituation.setMSecsSinceEpoch(interpolatedTime);
status.setInterpolatedAndCheckSituation(true, currentSituation); status.setInterpolatedAndCheckSituation(true, currentSituation);
if (this->hasAttachedLogger() && hints.isLoggingInterpolation()) if (this->hasAttachedLogger() && setup.logInterpolation())
{ {
log.tsCurrent = currentTimeMsSinceEpoc; log.tsCurrent = currentTimeMsSinceEpoc;
log.deltaSampleTimesMs = sampleDeltaTimeMs; log.deltaSampleTimesMs = sampleDeltaTimeMs;
@@ -159,10 +158,9 @@ namespace BlackMisc
return { oldSituation, newSituation, simulationTimeFraction, interpolatedTime }; return { oldSituation, newSituation, simulationTimeFraction, interpolatedTime };
} }
CCoordinateGeodetic CInterpolatorLinear::Interpolant::interpolatePosition(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const CCoordinateGeodetic CInterpolatorLinear::Interpolant::interpolatePosition(const CInterpolationAndRenderingSetupPerCallsign &setup) const
{ {
Q_UNUSED(setup); Q_UNUSED(setup);
Q_UNUSED(hints);
const std::array<double, 3> oldVec(m_oldSituation.getPosition().normalVectorDouble()); const std::array<double, 3> oldVec(m_oldSituation.getPosition().normalVectorDouble());
const std::array<double, 3> newVec(m_newSituation.getPosition().normalVectorDouble()); const std::array<double, 3> newVec(m_newSituation.getPosition().normalVectorDouble());
@@ -175,10 +173,9 @@ namespace BlackMisc
return currentPosition; return currentPosition;
} }
CAltitude CInterpolatorLinear::Interpolant::interpolateAltitude(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const CAltitude CInterpolatorLinear::Interpolant::interpolateAltitude(const CInterpolationAndRenderingSetupPerCallsign &setup) const
{ {
Q_UNUSED(setup); Q_UNUSED(setup);
Q_UNUSED(hints);
// Interpolate altitude: Alt = (AltB - AltA) * t + AltA // Interpolate altitude: Alt = (AltB - AltA) * t + AltA
// avoid underflow below ground elevation by using getCorrectedAltitude // avoid underflow below ground elevation by using getCorrectedAltitude

View File

@@ -49,8 +49,8 @@ namespace BlackMisc
//! Perform the interpolation //! Perform the interpolation
//! @{ //! @{
Geo::CCoordinateGeodetic interpolatePosition(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const; Geo::CCoordinateGeodetic interpolatePosition(const CInterpolationAndRenderingSetupPerCallsign &setup) const;
Aviation::CAltitude interpolateAltitude(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const; Aviation::CAltitude interpolateAltitude(const CInterpolationAndRenderingSetupPerCallsign &setup) const;
//! @} //! @}
//! Interpolator for pitch, bank, heading, groundspeed //! Interpolator for pitch, bank, heading, groundspeed
@@ -75,8 +75,7 @@ namespace BlackMisc
}; };
//! Get the interpolant for the given time point //! Get the interpolant for the given time point
Interpolant getInterpolant(qint64 currentTimeMsSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup, Interpolant getInterpolant(qint64 currentTimeMsSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup, CInterpolationStatus &status, SituationLog &log) const;
const CInterpolationHints &hints, CInterpolationStatus &status, SituationLog &log) const;
}; };
} // ns } // ns
} // ns } // ns

View File

@@ -24,13 +24,13 @@ namespace BlackMisc
{} {}
CAircraftSituation CInterpolatorMulti::getInterpolatedSituation(qint64 currentTimeSinceEpoc, CAircraftSituation CInterpolatorMulti::getInterpolatedSituation(qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationAndRenderingSetupPerCallsign &setup,
const CInterpolationHints &hints, CInterpolationStatus &status) CInterpolationStatus &status)
{ {
switch (m_mode) switch (m_mode)
{ {
case ModeLinear: return m_linear.getInterpolatedSituation(currentTimeSinceEpoc, setup, hints, status); case ModeLinear: return m_linear.getInterpolatedSituation(currentTimeSinceEpoc, setup, status);
case ModeSpline: return m_spline.getInterpolatedSituation(currentTimeSinceEpoc, setup, hints, status); case ModeSpline: return m_spline.getInterpolatedSituation(currentTimeSinceEpoc, setup, status);
default: break; default: break;
} }
return {}; return {};

View File

@@ -34,10 +34,11 @@ namespace BlackMisc
Aviation::CAircraftSituation getInterpolatedSituation( Aviation::CAircraftSituation getInterpolatedSituation(
qint64 currentTimeSinceEpoc, qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationAndRenderingSetupPerCallsign &setup,
const CInterpolationHints &hints, CInterpolationStatus &status); CInterpolationStatus &status);
//! \copydoc CInterpolator::getInterpolatedParts //! \copydoc CInterpolator::getInterpolatedParts
Aviation::CAircraftParts getInterpolatedParts(qint64 currentTimeSinceEpoc, Aviation::CAircraftParts getInterpolatedParts(
qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationAndRenderingSetupPerCallsign &setup,
CPartsStatus &partsStatus, bool log = false) const; CPartsStatus &partsStatus, bool log = false) const;

View File

@@ -8,7 +8,6 @@
*/ */
#include "blackmisc/simulation/interpolatorspline.h" #include "blackmisc/simulation/interpolatorspline.h"
#include "blackmisc/simulation/interpolationhints.h"
#include "blackmisc/logmessage.h" #include "blackmisc/logmessage.h"
#include "blackmisc/verify.h" #include "blackmisc/verify.h"
@@ -95,11 +94,12 @@ namespace BlackMisc
} }
} }
CInterpolatorSpline::Interpolant CInterpolatorSpline::getInterpolant(qint64 currentTimeMsSinceEpoc, CInterpolatorSpline::Interpolant CInterpolatorSpline::getInterpolant(
const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints, CInterpolationStatus &status, qint64 currentTimeMsSinceEpoc,
SituationLog &log) const CInterpolationAndRenderingSetupPerCallsign &setup,
CInterpolationStatus &status,
SituationLog &log)
{ {
Q_UNUSED(hints);
Q_UNUSED(setup); Q_UNUSED(setup);
// recalculate derivatives only if they changed // recalculate derivatives only if they changed
@@ -135,17 +135,19 @@ namespace BlackMisc
// - on an airport the plane does not move very fast, or not at all // - on an airport the plane does not move very fast, or not at all
// - and the elevation remains (almost) constant for a wider area // - and the elevation remains (almost) constant for a wider area
// - flying the ground elevation not really matters // - flying the ground elevation not really matters
if (!hints.getElevationPlane().isNull()) const CElevationPlane plane0 = this->findClosestElevationWithinRange(m_s[0], CElevationPlane::singlePointRadius());
{ const CElevationPlane plane1 = this->findClosestElevationWithinRange(m_s[1], CElevationPlane::singlePointRadius());
// do not override existing values const CElevationPlane plane2 = this->findClosestElevationWithinRange(m_s[2], CElevationPlane::singlePointRadius());
m_s[0].setGroundElevationChecked(hints.getElevationPlane());
m_s[1].setGroundElevationChecked(hints.getElevationPlane());
m_s[2].setGroundElevationChecked(hints.getElevationPlane());
}
const double a0 = m_s[0].getCorrectedAltitude(hints.getCGAboveGround()).value(); // do not override existing values
const double a1 = m_s[1].getCorrectedAltitude(hints.getCGAboveGround()).value(); m_s[0].setGroundElevationChecked(plane0);
const double a2 = m_s[2].getCorrectedAltitude(hints.getCGAboveGround()).value(); m_s[1].setGroundElevationChecked(plane1);
m_s[2].setGroundElevationChecked(plane2);
const CLength cg = this->getCG(m_callsign);
const double a0 = m_s[0].getCorrectedAltitude(cg).value();
const double a1 = m_s[1].getCorrectedAltitude(cg).value();
const double a2 = m_s[2].getCorrectedAltitude(cg).value();
const std::array<std::array<double, 3>, 3> normals {{ m_s[0].getPosition().normalVectorDouble(), m_s[1].getPosition().normalVectorDouble(), m_s[2].getPosition().normalVectorDouble() }}; const std::array<std::array<double, 3>, 3> normals {{ m_s[0].getPosition().normalVectorDouble(), m_s[1].getPosition().normalVectorDouble(), m_s[2].getPosition().normalVectorDouble() }};
PosArray pa; PosArray pa;
@@ -190,7 +192,7 @@ namespace BlackMisc
status.setInterpolated(true); status.setInterpolated(true);
m_interpolant.setTimes(currentTimeMsSinceEpoc, timeFraction, interpolatedTime); m_interpolant.setTimes(currentTimeMsSinceEpoc, timeFraction, interpolatedTime);
if (this->hasAttachedLogger() && hints.isLoggingInterpolation()) if (this->hasAttachedLogger() && setup.logInterpolation())
{ {
log.interpolationSituations.push_back(m_s[0]); log.interpolationSituations.push_back(m_s[0]);
log.interpolationSituations.push_back(m_s[1]); log.interpolationSituations.push_back(m_s[1]);
@@ -205,10 +207,9 @@ namespace BlackMisc
return m_interpolant; return m_interpolant;
} }
CCoordinateGeodetic CInterpolatorSpline::Interpolant::interpolatePosition(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const CCoordinateGeodetic CInterpolatorSpline::Interpolant::interpolatePosition(const CInterpolationAndRenderingSetupPerCallsign &setup) const
{ {
Q_UNUSED(setup); Q_UNUSED(setup);
Q_UNUSED(hints);
const double newX = evalSplineInterval(m_currentTimeMsSinceEpoc, m_pa.t[1], m_pa.t[2], m_pa.x[1], m_pa.x[2], m_pa.dx[1], m_pa.dx[2]); const double newX = evalSplineInterval(m_currentTimeMsSinceEpoc, m_pa.t[1], m_pa.t[2], m_pa.x[1], m_pa.x[2], m_pa.dx[1], m_pa.dx[2]);
const double newY = evalSplineInterval(m_currentTimeMsSinceEpoc, m_pa.t[1], m_pa.t[2], m_pa.y[1], m_pa.y[2], m_pa.dy[1], m_pa.dy[2]); const double newY = evalSplineInterval(m_currentTimeMsSinceEpoc, m_pa.t[1], m_pa.t[2], m_pa.y[1], m_pa.y[2], m_pa.dy[1], m_pa.dy[2]);
@@ -219,10 +220,9 @@ namespace BlackMisc
return currentPosition; return currentPosition;
} }
CAltitude CInterpolatorSpline::Interpolant::interpolateAltitude(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const CAltitude CInterpolatorSpline::Interpolant::interpolateAltitude(const CInterpolationAndRenderingSetupPerCallsign &setup) const
{ {
Q_UNUSED(setup); Q_UNUSED(setup);
Q_UNUSED(hints);
const double newA = evalSplineInterval(m_currentTimeMsSinceEpoc, m_pa.t[1], m_pa.t[2], m_pa.a[1], m_pa.a[2], m_pa.da[1], m_pa.da[2]); const double newA = evalSplineInterval(m_currentTimeMsSinceEpoc, m_pa.t[1], m_pa.t[2], m_pa.a[1], m_pa.a[2], m_pa.da[1], m_pa.da[2]);
return CAltitude(newA, m_altitudeUnit); return CAltitude(newA, m_altitudeUnit);

View File

@@ -63,8 +63,8 @@ namespace BlackMisc
//! Perform the interpolation //! Perform the interpolation
//! @{ //! @{
Geo::CCoordinateGeodetic interpolatePosition(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const; Geo::CCoordinateGeodetic interpolatePosition(const CInterpolationAndRenderingSetupPerCallsign &setup) const;
Aviation::CAltitude interpolateAltitude(const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationHints &hints) const; Aviation::CAltitude interpolateAltitude(const CInterpolationAndRenderingSetupPerCallsign &setup) const;
//! @} //! @}
//! Interpolator for pitch, bank, heading, groundspeed //! Interpolator for pitch, bank, heading, groundspeed
@@ -92,8 +92,7 @@ namespace BlackMisc
//! Strategy used by CInterpolator::getInterpolatedSituation //! Strategy used by CInterpolator::getInterpolatedSituation
Interpolant getInterpolant(qint64 currentTimeMsSinceEpoc, Interpolant getInterpolant(qint64 currentTimeMsSinceEpoc,
const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationAndRenderingSetupPerCallsign &setup, CInterpolationStatus &status, SituationLog &log);
const CInterpolationHints &hints, CInterpolationStatus &status, SituationLog &log);
private: private:
qint64 m_prevSampleAdjustedTime = 0; //!< previous sample time + offset qint64 m_prevSampleAdjustedTime = 0; //!< previous sample time + offset

View File

@@ -32,7 +32,6 @@ namespace BlackMisc
CInterpolationAndRenderingSetupPerCallsign::registerMetadata(); CInterpolationAndRenderingSetupPerCallsign::registerMetadata();
CInterpolationAndRenderingSetupGlobal::registerMetadata(); CInterpolationAndRenderingSetupGlobal::registerMetadata();
CInterpolationSetupList::registerMetadata(); CInterpolationSetupList::registerMetadata();
CInterpolationHints::registerMetadata();
CMatchingStatisticsEntry::registerMetadata(); CMatchingStatisticsEntry::registerMetadata();
CMatchingStatistics::registerMetadata(); CMatchingStatistics::registerMetadata();
CModelSettings::registerMetadata(); CModelSettings::registerMetadata();

View File

@@ -28,6 +28,12 @@ namespace BlackMisc
return this->provider()->isAircraftInRange(callsign); return this->provider()->isAircraftInRange(callsign);
} }
bool CRemoteAircraftAware::isVtolAircraft(const CCallsign &callsign) const
{
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");
return this->provider()->isVtolAircraft(callsign);
}
int CRemoteAircraftAware::getAircraftInRangeCount() const int CRemoteAircraftAware::getAircraftInRangeCount() const
{ {
Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available"); Q_ASSERT_X(this->provider(), Q_FUNC_INFO, "No object available");

View File

@@ -75,6 +75,10 @@ namespace BlackMisc
//! \threadsafe //! \threadsafe
virtual bool isAircraftInRange(const BlackMisc::Aviation::CCallsign &callsign) const = 0; virtual bool isAircraftInRange(const BlackMisc::Aviation::CCallsign &callsign) const = 0;
//! Is VTOL aircraft?
//! \threadsafe
virtual bool isVtolAircraft(const BlackMisc::Aviation::CCallsign &callsign) const = 0;
//! Current snapshot //! Current snapshot
//! \threadsafe //! \threadsafe
virtual BlackMisc::Simulation::CAirspaceAircraftSnapshot getLatestAirspaceAircraftSnapshot() const = 0; virtual BlackMisc::Simulation::CAirspaceAircraftSnapshot getLatestAirspaceAircraftSnapshot() const = 0;
@@ -195,6 +199,9 @@ namespace BlackMisc
//! \copydoc IRemoteAircraftProvider::isAircraftInRange //! \copydoc IRemoteAircraftProvider::isAircraftInRange
bool isAircraftInRange(const BlackMisc::Aviation::CCallsign &callsign) const; bool isAircraftInRange(const BlackMisc::Aviation::CCallsign &callsign) const;
//! \copydoc IRemoteAircraftProvider::isVtolAircraft
bool isVtolAircraft(const BlackMisc::Aviation::CCallsign &callsign) const;
//! \copydoc IRemoteAircraftProvider::getAircraftInRangeCount //! \copydoc IRemoteAircraftProvider::getAircraftInRangeCount
int getAircraftInRangeCount() const; int getAircraftInRangeCount() const;

View File

@@ -19,7 +19,6 @@
#include "blackmisc/simulation/airspaceaircraftsnapshot.h" #include "blackmisc/simulation/airspaceaircraftsnapshot.h"
#include "blackmisc/simulation/distributorlist.h" #include "blackmisc/simulation/distributorlist.h"
#include "blackmisc/simulation/distributorlistpreferences.h" #include "blackmisc/simulation/distributorlistpreferences.h"
#include "blackmisc/simulation/interpolationhints.h"
#include "blackmisc/simulation/interpolationrenderingsetup.h" #include "blackmisc/simulation/interpolationrenderingsetup.h"
#include "blackmisc/simulation/interpolationsetuplist.h" #include "blackmisc/simulation/interpolationsetuplist.h"
#include "blackmisc/simulation/matchingstatistics.h" #include "blackmisc/simulation/matchingstatistics.h"

View File

@@ -36,7 +36,7 @@ namespace BlackMisc
return this->rememberGroundElevation(elevationPlane, elevationPlane.getRadius()); return this->rememberGroundElevation(elevationPlane, elevationPlane.getRadius());
} }
bool ISimulationEnvironmentProvider::insertCG(const CLength &cg, const Aviation::CCallsign &cs) bool ISimulationEnvironmentProvider::insertCG(const CLength &cg, const CCallsign &cs)
{ {
if (cs.isEmpty()) { return false; } if (cs.isEmpty()) { return false; }
const bool remove = cg.isNull(); const bool remove = cg.isNull();
@@ -77,7 +77,7 @@ namespace BlackMisc
return delta; return delta;
} }
CElevationPlane ISimulationEnvironmentProvider::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) CElevationPlane ISimulationEnvironmentProvider::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const
{ {
return this->getElevationCoordinates().findClosestWithinRange(reference, range); return this->getElevationCoordinates().findClosestWithinRange(reference, range);
} }
@@ -153,7 +153,7 @@ namespace BlackMisc
this->clearCGs(); this->clearCGs();
} }
CElevationPlane CSimulationEnvironmentAware::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) CElevationPlane CSimulationEnvironmentAware::findClosestElevationWithinRange(const ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const
{ {
if (!this->hasProvider()) { return CElevationPlane::null(); } if (!this->hasProvider()) { return CElevationPlane::null(); }
return this->provider()->findClosestElevationWithinRange(reference, range); return this->provider()->findClosestElevationWithinRange(reference, range);
@@ -177,6 +177,12 @@ namespace BlackMisc
return this->provider()->getDefaultModel(); return this->provider()->getDefaultModel();
} }
CLength CSimulationEnvironmentAware::getCG(const CCallsign &callsign) const
{
if (!this->hasProvider()) { return CLength::null(); }
return this->provider()->getCG(callsign);
}
bool CSimulationEnvironmentAware::hasCG(const CCallsign &callsign) const bool CSimulationEnvironmentAware::hasCG(const CCallsign &callsign) const
{ {
if (!this->hasProvider()) { return false; } if (!this->hasProvider()) { return false; }

View File

@@ -37,7 +37,7 @@ namespace BlackMisc
//! Find closest elevation //! Find closest elevation
//! \threadsafe //! \threadsafe
Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range); Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const;
//! Get the represented plugin //! Get the represented plugin
//! \threadsafe //! \threadsafe
@@ -122,7 +122,7 @@ namespace BlackMisc
void setSimulationEnvironmentProvider(ISimulationEnvironmentProvider *provider) { this->setProvider(provider); } void setSimulationEnvironmentProvider(ISimulationEnvironmentProvider *provider) { this->setProvider(provider); }
//! \copydoc ISimulationEnvironmentProvider::findClosestElevationWithinRange //! \copydoc ISimulationEnvironmentProvider::findClosestElevationWithinRange
Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range); Geo::CElevationPlane findClosestElevationWithinRange(const Geo::ICoordinateGeodetic &reference, const PhysicalQuantities::CLength &range) const;
//! \copydoc ISimulationEnvironmentProvider::getSimulatorPluginInfo //! \copydoc ISimulationEnvironmentProvider::getSimulatorPluginInfo
CSimulatorPluginInfo getSimulatorPluginInfo() const; CSimulatorPluginInfo getSimulatorPluginInfo() const;

View File

@@ -439,11 +439,8 @@ namespace BlackSimPlugin
CInterpolatorMulti *im = m_interpolators[cs]; CInterpolatorMulti *im = m_interpolators[cs];
CInterpolationStatus statusInterpolation; CInterpolationStatus statusInterpolation;
CPartsStatus statusParts; CPartsStatus statusParts;
CInterpolationHints hints;
Q_ASSERT_X(im, Q_FUNC_INFO, "interpolator missing"); Q_ASSERT_X(im, Q_FUNC_INFO, "interpolator missing");
if (m_hints.contains(cs)) { hints = m_hints[cs]; } const CAircraftSituation s = im->getInterpolatedSituation(now, setup, statusInterpolation);
hints.setLoggingInterpolation(log);
const CAircraftSituation s = im->getInterpolatedSituation(now, setup, hints, statusInterpolation);
const CAircraftParts p = im->getInterpolatedParts(now, setup, statusParts, log); const CAircraftParts p = im->getInterpolatedParts(now, setup, statusParts, log);
m_countInterpolatedParts++; m_countInterpolatedParts++;
m_countInterpolatedSituations++; m_countInterpolatedSituations++;

View File

@@ -15,7 +15,6 @@
#include "directplayerror.h" #include "directplayerror.h"
#include "directplayutils.h" #include "directplayutils.h"
#include "blackcore/simulator.h" #include "blackcore/simulator.h"
#include "blackmisc/simulation/interpolationhints.h"
#include "blackmisc/aviation/aircraftsituation.h" #include "blackmisc/aviation/aircraftsituation.h"
#include "blackmisc/geo/coordinategeodetic.h" #include "blackmisc/geo/coordinategeodetic.h"
#include "blackmisc/logmessage.h" #include "blackmisc/logmessage.h"
@@ -174,10 +173,8 @@ namespace BlackSimPlugin
if (m_clientStatus == Disconnected) { return; } if (m_clientStatus == Disconnected) { return; }
CInterpolationStatus status; CInterpolationStatus status;
CInterpolationHints hints; // \fixme 201701 #865 KB if there is an elevation provider for FS9 add it here or set elevation
CInterpolationAndRenderingSetupPerCallsign setup = this->simulator()->getInterpolationSetupPerCallsignOrDefault(m_callsign); CInterpolationAndRenderingSetupPerCallsign setup = this->simulator()->getInterpolationSetupPerCallsignOrDefault(m_callsign);
hints.setLoggingInterpolation(setup.logInterpolation()); const CAircraftSituation situation = m_interpolator.getInterpolatedSituation(-1, setup, status);
const CAircraftSituation situation = m_interpolator.getInterpolatedSituation(-1, setup, hints, status);
// Test only for successful position. FS9 requires constant positions // Test only for successful position. FS9 requires constant positions
if (!status.hasValidSituation()) { return; } if (!status.hasValidSituation()) { return; }

View File

@@ -163,10 +163,10 @@ namespace BlackSimPlugin
CAircraftSituation CSimConnectObject::getInterpolatedSituation( CAircraftSituation CSimConnectObject::getInterpolatedSituation(
qint64 currentTimeSinceEpoc, qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationAndRenderingSetupPerCallsign &setup,
const CInterpolationHints &hints, CInterpolationStatus &status) const CInterpolationStatus &status) const
{ {
Q_ASSERT(m_interpolator); Q_ASSERT(m_interpolator);
return m_interpolator->getInterpolatedSituation(currentTimeSinceEpoc, setup, hints, status); return m_interpolator->getInterpolatedSituation(currentTimeSinceEpoc, setup, status);
} }
CAircraftParts CSimConnectObject::getInterpolatedParts( CAircraftParts CSimConnectObject::getInterpolatedParts(

View File

@@ -164,7 +164,7 @@ namespace BlackSimPlugin
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation( BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
qint64 currentTimeSinceEpoc, qint64 currentTimeSinceEpoc,
const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup, const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup,
const BlackMisc::Simulation::CInterpolationHints &hints, BlackMisc::Simulation::CInterpolationStatus &status) const; BlackMisc::Simulation::CInterpolationStatus &status) const;
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatedParts //! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatedParts
BlackMisc::Aviation::CAircraftParts getInterpolatedParts( BlackMisc::Aviation::CAircraftParts getInterpolatedParts(

View File

@@ -15,7 +15,6 @@
#include "blackmisc/simulation/fscommon/fscommonutil.h" #include "blackmisc/simulation/fscommon/fscommonutil.h"
#include "blackmisc/simulation/aircraftmodel.h" #include "blackmisc/simulation/aircraftmodel.h"
#include "blackmisc/simulation/interpolatormulti.h" #include "blackmisc/simulation/interpolatormulti.h"
#include "blackmisc/simulation/interpolationhints.h"
#include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/simulation/simulatorplugininfo.h"
#include "blackmisc/aviation/airportlist.h" #include "blackmisc/aviation/airportlist.h"
#include "blackmisc/geo/elevationplane.h" #include "blackmisc/geo/elevationplane.h"
@@ -489,11 +488,6 @@ namespace BlackSimPlugin
CElevationPlane elevation(remoteAircraftData.latitude, remoteAircraftData.longitude, remoteAircraftData.elevation); CElevationPlane elevation(remoteAircraftData.latitude, remoteAircraftData.longitude, remoteAircraftData.elevation);
elevation.setSinglePointRadius(); elevation.setSinglePointRadius();
// const QString debug(hints.debugInfo(elevation));
CInterpolationHints &hints = m_hints[simObject.getCallsign()];
hints.setElevationPlane(elevation); // update elevation
hints.setCGAboveGround({ remoteAircraftData.cgToGround, CLengthUnit::ft() }); // normally never changing, but if user changes ModelMatching update possible
// set it in the remote aircraft provider // set it in the remote aircraft provider
this->updateAircraftGroundElevation(simObject.getCallsign(), elevation); this->updateAircraftGroundElevation(simObject.getCallsign(), elevation);
@@ -915,7 +909,6 @@ namespace BlackSimPlugin
// clean up anyway // clean up anyway
this->removeFromAddPendingAndAddAgainAircraft(callsign); this->removeFromAddPendingAndAddAgainAircraft(callsign);
m_hints.remove(callsign);
// really remove from simulator // really remove from simulator
if (!m_simConnectObjects.contains(callsign)) { return false; } // already fully removed or not yet added if (!m_simConnectObjects.contains(callsign)) { return false; } // already fully removed or not yet added
@@ -1126,10 +1119,7 @@ namespace BlackSimPlugin
// get interpolated situation // get interpolated situation
CInterpolationStatus interpolatorStatus; CInterpolationStatus interpolatorStatus;
CInterpolationHints hints(m_hints[callsign]); const CAircraftSituation interpolatedSituation = simObject.getInterpolatedSituation(currentTimestamp, setup, interpolatorStatus);
hints.setAircraftParts(useAircraftParts ? parts : CAircraftParts(), useAircraftParts);
hints.setLoggingInterpolation(logInterpolationAndParts);
const CAircraftSituation interpolatedSituation = simObject.getInterpolatedSituation(currentTimestamp, setup, hints, interpolatorStatus);
if (interpolatorStatus.hasValidSituation()) if (interpolatorStatus.hasValidSituation())
{ {

View File

@@ -632,9 +632,6 @@ namespace BlackSimPlugin
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "wrong thread"); Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "wrong thread");
if (callsign.isEmpty()) { return false; } // can happen if an object is not an aircraft if (callsign.isEmpty()) { return false; } // can happen if an object is not an aircraft
// clean up anyway
m_hints.remove(callsign);
// really remove from simulator // really remove from simulator
if (!m_xplaneAircraftObjects.contains(callsign)) { return false; } // already fully removed or not yet added if (!m_xplaneAircraftObjects.contains(callsign)) { return false; } // already fully removed or not yet added
@@ -837,10 +834,7 @@ namespace BlackSimPlugin
// get interpolated situation // get interpolated situation
CInterpolationStatus interpolatorStatus; CInterpolationStatus interpolatorStatus;
CInterpolationHints hints(m_hints[callsign]); const CAircraftSituation interpolatedSituation = xplaneAircraft.getInterpolatedSituation(currentTimestamp, setup, interpolatorStatus);
hints.setAircraftParts(useAircraftParts ? parts : CAircraftParts(), useAircraftParts);
hints.setLoggingInterpolation(logInterpolationAndParts);
const CAircraftSituation interpolatedSituation = xplaneAircraft.getInterpolatedSituation(currentTimestamp, setup, hints, interpolatorStatus);
if (interpolatorStatus.hasValidSituation()) if (interpolatorStatus.hasValidSituation())
{ {
@@ -999,13 +993,8 @@ namespace BlackSimPlugin
CElevationPlane elevation(CLatitude(latitudeDeg, CAngleUnit::deg()), CLongitude(longitudeDeg, CAngleUnit::deg()), CAltitude(elevationMeters, CLengthUnit::m())); CElevationPlane elevation(CLatitude(latitudeDeg, CAngleUnit::deg()), CLongitude(longitudeDeg, CAngleUnit::deg()), CAltitude(elevationMeters, CLengthUnit::m()));
elevation.setSinglePointRadius(); elevation.setSinglePointRadius();
this->rememberGroundElevation(elevation);
// The entire vertical offset (CG offset) is still very experimental in X-Plane. Libxplanemp simply calculates the lowest Y this->insertCG(CLength(modelVerticalOffsetMeters, CLengthUnit::m()), callsign);
// value from all the OpenGL model vertices. I assume its in meters.
// The unit of modelVerticalOffset is still very unknown. This needs to be confirmed.
CInterpolationHints &hints = m_hints[cs];
hints.setElevationPlane(elevation); // update elevation
hints.setCGAboveGround({ modelVerticalOffsetMeters, CLengthUnit::m() });
// set it in the remote aircraft provider // set it in the remote aircraft provider
this->updateAircraftGroundElevation(cs, elevation); this->updateAircraftGroundElevation(cs, elevation);

View File

@@ -92,10 +92,10 @@ namespace BlackSimPlugin
CAircraftSituation CXPlaneMPAircraft::getInterpolatedSituation( CAircraftSituation CXPlaneMPAircraft::getInterpolatedSituation(
qint64 currentTimeSinceEpoc, qint64 currentTimeSinceEpoc,
const CInterpolationAndRenderingSetupPerCallsign &setup, const CInterpolationAndRenderingSetupPerCallsign &setup,
const CInterpolationHints &hints, CInterpolationStatus &status) const CInterpolationStatus &status) const
{ {
Q_ASSERT(m_interpolator); Q_ASSERT(m_interpolator);
return m_interpolator->getInterpolatedSituation(currentTimeSinceEpoc, setup, hints, status); return m_interpolator->getInterpolatedSituation(currentTimeSinceEpoc, setup, status);
} }
CAircraftParts CXPlaneMPAircraft::getInterpolatedParts( CAircraftParts CXPlaneMPAircraft::getInterpolatedParts(

View File

@@ -90,7 +90,7 @@ namespace BlackSimPlugin
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation( BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
qint64 currentTimeSinceEpoc, qint64 currentTimeSinceEpoc,
const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup, const BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign &setup,
const BlackMisc::Simulation::CInterpolationHints &hints, BlackMisc::Simulation::CInterpolationStatus &status) const; BlackMisc::Simulation::CInterpolationStatus &status) const;
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatedParts //! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatedParts
BlackMisc::Aviation::CAircraftParts getInterpolatedParts( BlackMisc::Aviation::CAircraftParts getInterpolatedParts(

View File

@@ -15,7 +15,6 @@
#include "traffic.h" #include "traffic.h"
#include "utils.h" #include "utils.h"
#include "blackmisc/simulation/interpolator.h" #include "blackmisc/simulation/interpolator.h"
#include "blackmisc/simulation/interpolationhints.h"
#include "blackmisc/aviation/aircraftsituation.h" #include "blackmisc/aviation/aircraftsituation.h"
#include "blackmisc/aviation/callsign.h" #include "blackmisc/aviation/callsign.h"
#include "blackmisc/verify.h" #include "blackmisc/verify.h"
@@ -47,34 +46,6 @@ namespace XSwiftBus
surfaces.lights.timeOffset = static_cast<quint16>(qrand() % 0xffff); surfaces.lights.timeOffset = static_cast<quint16>(qrand() % 0xffff);
} }
BlackMisc::Simulation::CInterpolationHints CTraffic::Plane::hints()
{
//! \todo MS 865 CInterpolationAndRenderingSetup allows to setup interpolation in the GUI
// Also to disable aircraft parts / or logging parts (log file). I wonder if you want to consider it here
// e.g. interpolator->getInterpolatorSetup().getLogCallsigns().contains(callsign)
// if the setup is needed more than once, store it here to avoid multiple locks
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Simulation;
CInterpolationAndRenderingSetupPerCallsign setup;
CInterpolationHints hints;
CPartsStatus status;
constexpr double fudgeFactor = 3.0; //! \fixme Value should be different for each plane, derived from the CSL model geometry
hints.setAircraftParts(interpolator.getInterpolatedParts(-1, setup, status));
hints.setCGAboveGround({ fudgeFactor, CLengthUnit::m() }); // fudge factor
hints.setElevationProvider([this](const auto & situation)
{
const auto meters = terrainProbe.getElevation(
situation.latitude().value(CAngleUnit::deg()),
situation.longitude().value(CAngleUnit::deg()),
situation.getAltitude().value(CLengthUnit::m()));
if (std::isnan(meters)) { return CAltitude::null(); }
return CAltitude(CLength(meters, CLengthUnit::m()), CAltitude::MeanSeaLevel);
});
return hints;
}
CTraffic::CTraffic(QObject *parent) : CTraffic::CTraffic(QObject *parent) :
QObject(parent) QObject(parent)
{ {
@@ -432,7 +403,7 @@ namespace XSwiftBus
{ {
BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign setup; BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign setup;
BlackMisc::Simulation::CInterpolationStatus status; BlackMisc::Simulation::CInterpolationStatus status;
BlackMisc::Aviation::CAircraftSituation situation = plane->interpolator.getInterpolatedSituation(-1, setup, plane->hints(), status); BlackMisc::Aviation::CAircraftSituation situation = plane->interpolator.getInterpolatedSituation(-1, setup, status);
if (! status.hasValidSituation()) { return xpmpData_Unavailable; } if (! status.hasValidSituation()) { return xpmpData_Unavailable; }
//! \fixme KB 2018-01 commented out with T229. Change detection needs to go somewhere else //! \fixme KB 2018-01 commented out with T229. Change detection needs to go somewhere else

View File

@@ -31,7 +31,6 @@
#define XSWIFTBUS_TRAFFIC_OBJECTPATH "/xswiftbus/traffic" #define XSWIFTBUS_TRAFFIC_OBJECTPATH "/xswiftbus/traffic"
//! \endcond //! \endcond
namespace BlackMisc { namespace Simulation { class CInterpolationHints; } }
namespace XSwiftBus namespace XSwiftBus
{ {
/*! /*!
@@ -154,7 +153,6 @@ namespace XSwiftBus
char label[32] {}; char label[32] {};
BlackMisc::Simulation::CInterpolatorMulti interpolator; BlackMisc::Simulation::CInterpolatorMulti interpolator;
CTerrainProbe terrainProbe; CTerrainProbe terrainProbe;
BlackMisc::Simulation::CInterpolationHints hints();
XPMPPlaneSurfaces_t surfaces; XPMPPlaneSurfaces_t surfaces;
QVector<std::pair<qint64, std::function<void(Plane *)>>> pendingSurfaces; QVector<std::pair<qint64, std::function<void(Plane *)>>> pendingSurfaces;
float targetGearPosition = 0; float targetGearPosition = 0;

View File

@@ -34,7 +34,6 @@
#include "blackmisc/pq/physicalquantity.h" #include "blackmisc/pq/physicalquantity.h"
#include "blackmisc/pq/speed.h" #include "blackmisc/pq/speed.h"
#include "blackmisc/pq/units.h" #include "blackmisc/pq/units.h"
#include "blackmisc/simulation/interpolationhints.h"
#include "blackmisc/simulation/remoteaircraftprovider.h" #include "blackmisc/simulation/remoteaircraftprovider.h"
#include <QCoreApplication> #include <QCoreApplication>
@@ -84,7 +83,6 @@ namespace BlackMiscTest
// interpolation functional check // interpolation functional check
CInterpolationStatus status; CInterpolationStatus status;
const CInterpolationHints hints;
const CInterpolationAndRenderingSetupPerCallsign setup; const CInterpolationAndRenderingSetupPerCallsign setup;
double latOld = 360.0; double latOld = 360.0;
double lngOld = 360.0; double lngOld = 360.0;
@@ -93,9 +91,9 @@ namespace BlackMiscTest
// This will use time range // This will use time range
// from: ts - 2 * deltaT + offset // from: ts - 2 * deltaT + offset
// to: ts + offset // to: ts + offset
CAircraftSituation currentSituation(interpolator.getInterpolatedSituation CAircraftSituation currentSituation(
(currentTime, setup, hints, status) interpolator.getInterpolatedSituation(currentTime, setup, status)
); );
QVERIFY2(status.isInterpolated(), "Value was not interpolated"); QVERIFY2(status.isInterpolated(), "Value was not interpolated");
const double latDeg = currentSituation.getPosition().latitude().valueRounded(CAngleUnit::deg(), 5); const double latDeg = currentSituation.getPosition().latitude().valueRounded(CAngleUnit::deg(), 5);
const double lngDeg = currentSituation.getPosition().longitude().valueRounded(CAngleUnit::deg(), 5); const double lngDeg = currentSituation.getPosition().longitude().valueRounded(CAngleUnit::deg(), 5);
@@ -123,9 +121,9 @@ namespace BlackMiscTest
// This will use range // This will use range
// from: ts - 2* deltaT + offset // from: ts - 2* deltaT + offset
// to: ts + offset // to: ts + offset
CAircraftSituation currentSituation(interpolator.getInterpolatedSituation CAircraftSituation currentSituation(
(currentTime, setup, hints, status) interpolator.getInterpolatedSituation(currentTime, setup, status)
); );
QVERIFY2(status.isInterpolated(), "Not interpolated"); QVERIFY2(status.isInterpolated(), "Not interpolated");
QVERIFY2(!currentSituation.getCallsign().isEmpty(), "Empty callsign"); QVERIFY2(!currentSituation.getCallsign().isEmpty(), "Empty callsign");
QVERIFY2(currentSituation.getCallsign() == cs, "Wrong callsign"); QVERIFY2(currentSituation.getCallsign() == cs, "Wrong callsign");