mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 10:45:37 +08:00
refs #865, hints get ground elevation from provider or from set value
* using CAltitude for elevation provider * null() for CAltitude * formatting of members * fixme in fs9 client
This commit is contained in:
committed by
Mathew Sutcliffe
parent
0a99c82ddc
commit
38585d10b2
@@ -106,5 +106,11 @@ namespace BlackMisc
|
|||||||
return BlackMisc::CIcon::iconByIndex(CIcons::GeoPosition);
|
return BlackMisc::CIcon::iconByIndex(CIcons::GeoPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CAltitude &CAltitude::null()
|
||||||
|
{
|
||||||
|
static const CAltitude null(0, CAltitude::MeanSeaLevel, CLengthUnit::nullUnit());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace BlackMisc
|
|||||||
/*!
|
/*!
|
||||||
* Enum type to distinguish between MSL and AGL
|
* Enum type to distinguish between MSL and AGL
|
||||||
*/
|
*/
|
||||||
enum ReferenceDatum : uint
|
enum ReferenceDatum
|
||||||
{
|
{
|
||||||
MeanSeaLevel = 0, //!< MSL
|
MeanSeaLevel = 0, //!< MSL
|
||||||
AboveGround, //!< AGL
|
AboveGround, //!< AGL
|
||||||
@@ -115,6 +115,9 @@ namespace BlackMisc
|
|||||||
//! \copydoc BlackMisc::Mixin::Icon::toIcon
|
//! \copydoc BlackMisc::Mixin::Icon::toIcon
|
||||||
BlackMisc::CIcon toIcon() const;
|
BlackMisc::CIcon toIcon() const;
|
||||||
|
|
||||||
|
//! Null altitude (MSL)
|
||||||
|
static const CAltitude &null();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ReferenceDatum m_datum; //!< MSL or AGL?
|
ReferenceDatum m_datum; //!< MSL or AGL?
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "interpolationhints.h"
|
#include "interpolationhints.h"
|
||||||
#include "blackmisc/aviation/aircraftsituation.h"
|
#include "blackmisc/aviation/aircraftsituation.h"
|
||||||
|
|
||||||
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
|
|
||||||
@@ -22,6 +23,13 @@ namespace BlackMisc
|
|||||||
CInterpolationHints::CInterpolationHints(bool isVtolAircraft) : m_isVtol(isVtolAircraft)
|
CInterpolationHints::CInterpolationHints(bool isVtolAircraft) : m_isVtol(isVtolAircraft)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
CAltitude CInterpolationHints::getGroundElevation(const Aviation::CAircraftSituation &situation) const
|
||||||
|
{
|
||||||
|
if (m_elevationProvider) { return m_elevationProvider(situation); }
|
||||||
|
if (m_elevation.isNull() || !m_elevation.isWithinRange(situation)) { return CAltitude::null(); }
|
||||||
|
return m_elevation.geodeticHeight();
|
||||||
|
}
|
||||||
|
|
||||||
void CInterpolationHints::resetElevation()
|
void CInterpolationHints::resetElevation()
|
||||||
{
|
{
|
||||||
m_elevation = CElevationPlane();
|
m_elevation = CElevationPlane();
|
||||||
@@ -33,6 +41,12 @@ namespace BlackMisc
|
|||||||
return m_elevation.isWithinRange(coordinate);
|
return m_elevation.isWithinRange(coordinate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInterpolationHints::setAircraftParts(const CAircraftParts &parts, bool hasParts)
|
||||||
|
{
|
||||||
|
m_hasParts = hasParts;
|
||||||
|
m_aircraftParts = parts;
|
||||||
|
}
|
||||||
|
|
||||||
CVariant CInterpolationHints::propertyByIndex(const CPropertyIndex &index) const
|
CVariant CInterpolationHints::propertyByIndex(const CPropertyIndex &index) const
|
||||||
{
|
{
|
||||||
if (index.isMyself()) { return CVariant::from(*this); }
|
if (index.isMyself()) { return CVariant::from(*this); }
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
namespace Aviation { class CAircraftSituation; }
|
namespace Aviation { class CAircraftSituation; }
|
||||||
|
|
||||||
namespace Simulation
|
namespace Simulation
|
||||||
{
|
{
|
||||||
//! Hints for interpolator such as ground elevation
|
//! Hints for interpolator such as ground elevation
|
||||||
@@ -45,6 +44,9 @@ namespace BlackMisc
|
|||||||
//! Get elevation
|
//! Get elevation
|
||||||
const BlackMisc::Geo::CElevationPlane &getElevation() const { return m_elevation;}
|
const BlackMisc::Geo::CElevationPlane &getElevation() const { return m_elevation;}
|
||||||
|
|
||||||
|
//! Get elevation from CInterpolationHints::getElevationProvider or CInterpolationHints::getElevation
|
||||||
|
Aviation::CAltitude getGroundElevation(const BlackMisc::Aviation::CAircraftSituation &situation) const;
|
||||||
|
|
||||||
//! Set elevation
|
//! Set elevation
|
||||||
void setElevation(const BlackMisc::Geo::CElevationPlane &elevation) { m_elevation = elevation; }
|
void setElevation(const BlackMisc::Geo::CElevationPlane &elevation) { m_elevation = elevation; }
|
||||||
|
|
||||||
@@ -69,16 +71,18 @@ namespace BlackMisc
|
|||||||
//! Has valid aircraft parts?
|
//! Has valid aircraft parts?
|
||||||
bool hasAircraftParts() const { return m_hasParts; }
|
bool hasAircraftParts() const { return m_hasParts; }
|
||||||
|
|
||||||
//! Aircraft parts
|
//! Aircraft parts required for interpolation
|
||||||
BlackMisc::Aviation::CAircraftParts getAircraftParts() const { return m_aircraftParts; }
|
BlackMisc::Aviation::CAircraftParts getAircraftParts() const { return m_aircraftParts; }
|
||||||
|
|
||||||
//! Set aircraft parts
|
//! Set aircraft parts required for interpolation if any
|
||||||
void setAircraftParts(const BlackMisc::Aviation::CAircraftParts &parts) { m_hasParts = true; m_aircraftParts = parts; }
|
//! \remark when used to reset value (default object) use hasParts false. Needed as there is no null parts object
|
||||||
|
void setAircraftParts(const BlackMisc::Aviation::CAircraftParts &parts, bool hasParts = true);
|
||||||
|
|
||||||
//! Function object that can obtain ground elevation
|
//! Function object that can obtain ground elevation
|
||||||
using ElevationProvider = std::function<BlackMisc::PhysicalQuantities::CLength(const BlackMisc::Aviation::CAircraftSituation &)>;
|
using ElevationProvider = std::function<BlackMisc::Aviation::CAltitude(const BlackMisc::Aviation::CAircraftSituation &)>;
|
||||||
|
|
||||||
//! Function object that can obtain ground elevation
|
//! Function object that can obtain ground elevation
|
||||||
|
//! \remark either a provider or a value set can be used
|
||||||
const ElevationProvider &getElevationProvider() const { return m_elevationProvider; }
|
const ElevationProvider &getElevationProvider() const { return m_elevationProvider; }
|
||||||
|
|
||||||
//! Set function object that can obtain ground elevation
|
//! Set function object that can obtain ground elevation
|
||||||
@@ -98,11 +102,11 @@ namespace BlackMisc
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_isVtol = false; //!< VTOL aircraft?
|
bool m_isVtol = false; //!< VTOL aircraft?
|
||||||
BlackMisc::Geo::CElevationPlane m_elevation; //!< aircraft's elevation if available
|
|
||||||
BlackMisc::PhysicalQuantities::CLength m_cgAboveGround { 0, nullptr }; //!< center of gravity above ground
|
|
||||||
bool m_hasParts = false; //!< Has valid aircraft parts?
|
bool m_hasParts = false; //!< Has valid aircraft parts?
|
||||||
BlackMisc::Aviation::CAircraftParts m_aircraftParts; //!< Aircraft parts
|
BlackMisc::Aviation::CAircraftParts m_aircraftParts; //!< Aircraft parts
|
||||||
|
BlackMisc::Geo::CElevationPlane m_elevation; //!< aircraft's elevation if available
|
||||||
ElevationProvider m_elevationProvider; //!< Provider of ground elevation (lazy computation)
|
ElevationProvider m_elevationProvider; //!< Provider of ground elevation (lazy computation)
|
||||||
|
BlackMisc::PhysicalQuantities::CLength m_cgAboveGround { 0, nullptr }; //!< center of gravity above ground
|
||||||
|
|
||||||
BLACK_METACLASS(
|
BLACK_METACLASS(
|
||||||
CInterpolationHints,
|
CInterpolationHints,
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ namespace BlackSimPlugin
|
|||||||
if (m_clientStatus == Disconnected) { return; }
|
if (m_clientStatus == Disconnected) { return; }
|
||||||
|
|
||||||
IInterpolator::InterpolationStatus status;
|
IInterpolator::InterpolationStatus status;
|
||||||
const CInterpolationHints hints;
|
const CInterpolationHints hints; // \fixme 201701 #865 KB if there is an elevation provider for FS9 add it here or set elevation
|
||||||
const CAircraftSituation situation = this->m_interpolator->getInterpolatedSituation(m_callsign, -1, hints, status);
|
const CAircraftSituation situation = this->m_interpolator->getInterpolatedSituation(m_callsign, -1, hints, status);
|
||||||
|
|
||||||
// Test only for successful interpolation. FS9 requires constant positions
|
// Test only for successful interpolation. FS9 requires constant positions
|
||||||
|
|||||||
@@ -50,12 +50,14 @@ namespace XBus
|
|||||||
hints.setElevationProvider([this](const auto &situation)
|
hints.setElevationProvider([this](const auto &situation)
|
||||||
{
|
{
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
const auto meters = terrainProbe.getElevation(situation.latitude().value(CAngleUnit::deg()),
|
using namespace BlackMisc::Aviation;
|
||||||
|
const auto meters = terrainProbe.getElevation(
|
||||||
|
situation.latitude().value(CAngleUnit::deg()),
|
||||||
situation.longitude().value(CAngleUnit::deg()),
|
situation.longitude().value(CAngleUnit::deg()),
|
||||||
situation.getAltitude().value(CLengthUnit::m()));
|
situation.getAltitude().value(CLengthUnit::m()));
|
||||||
if (std::isnan(meters)) { return CLength(0, nullptr); }
|
if (std::isnan(meters)) { return CAltitude::null(); }
|
||||||
constexpr decltype(meters) fudgeFactor = 3.0; //! \fixme Value should be different for each plane, derived from the CSL model geometry
|
constexpr decltype(meters) fudgeFactor = 3.0; //! \fixme Value should be different for each plane, derived from the CSL model geometry
|
||||||
return CLength(meters + fudgeFactor, CLengthUnit::m());
|
return CAltitude(CLength(meters + fudgeFactor, CLengthUnit::m()), CAltitude::MeanSeaLevel);
|
||||||
});
|
});
|
||||||
return hints;
|
return hints;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user