private void UpdateAltitudeAGL(FlightData flightData, F4SharedMem.FlightData fromFalcon, uint lod = 2) { try { float terrainHeight = _terrainDB.CalculateTerrainHeight(fromFalcon.x, fromFalcon.y, lod); float agl = -fromFalcon.z - terrainHeight; //reset AGL altitude to zero if we're on the ground if ( ((fromFalcon.lightBits & (int)LightBits.ONGROUND) == (int)LightBits.ONGROUND) || ( ((fromFalcon.lightBits3 & (int)LightBits3.OnGround) == (int)LightBits3.OnGround) ) ) { agl = 0; } if (agl < 0) { agl = 0; } flightData.AltitudeAboveGroundLevelInDecimalFeet = agl; } catch (Exception e) { Log.Debug(e.Message, e); flightData.AltitudeAboveGroundLevelInDecimalFeet = flightData.TrueAltitudeAboveMeanSeaLevelInDecimalFeet; } }
public float ComputeRadarAltitude(FlightData flightData, TerrainDB terrainDB, uint lod = 2) { var terrainHeight = terrainDB?.CalculateTerrainHeight(flightData.x, flightData.y, lod) ?? 0; var ralt = -flightData.z - terrainHeight; //reset AGL altitude to zero if we're on the ground if (WeightOnWheels(flightData) || OnGround(flightData)) { ralt = 0; } if (ralt < 0) { ralt = 0; } return(ralt); }