mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
[xswiftbus] log message when terrain probe fails to find ground elevation
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "terrainprobe.h"
|
||||
#include "utils.h"
|
||||
#include <XPLM/XPLMGraphics.h>
|
||||
#include <limits>
|
||||
|
||||
@@ -16,7 +17,7 @@ namespace XSwiftBus
|
||||
|
||||
CTerrainProbe::~CTerrainProbe() { XPLMDestroyProbe(m_ref); }
|
||||
|
||||
double CTerrainProbe::getElevation(double degreesLatitude, double degreesLongitude, double metersAltitude) const
|
||||
double CTerrainProbe::getElevation(double degreesLatitude, double degreesLongitude, double metersAltitude, const std::string &callsign) const
|
||||
{
|
||||
double x, y, z;
|
||||
XPLMWorldToLocal(degreesLatitude, degreesLongitude, metersAltitude, &x, &y, &z);
|
||||
@@ -26,8 +27,18 @@ namespace XSwiftBus
|
||||
auto result = XPLMProbeTerrainXYZ(m_ref, static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), &probe);
|
||||
if (result != xplm_ProbeHitTerrain)
|
||||
{
|
||||
std::string error;
|
||||
if (result == xplm_ProbeError) { error = "probe error"; }
|
||||
else if (result == xplm_ProbeMissed) { error = "probe missed"; }
|
||||
else { error = "unknown probe result"; }
|
||||
WARNING_LOG(callsign + " " + error + " at " + std::to_string(degreesLatitude) + ", " + std::to_string(degreesLongitude) + ", " + std::to_string(metersAltitude));
|
||||
|
||||
return std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
if (probe.is_wet)
|
||||
{
|
||||
DEBUG_LOG(callsign + " probe hit water at " + std::to_string(degreesLatitude) + ", " + std::to_string(degreesLongitude) + ", " + std::to_string(metersAltitude));
|
||||
}
|
||||
|
||||
XPLMLocalToWorld(probe.locationX, probe.locationY, probe.locationZ, °reesLatitude, °reesLongitude, &metersAltitude);
|
||||
return metersAltitude;
|
||||
|
||||
Reference in New Issue
Block a user