Skip to content

Commit

Permalink
ADSBEx: GAlt and opIcao are back in, closes #132 again
Browse files Browse the repository at this point in the history
  • Loading branch information
TwinFan committed Apr 28, 2019
1 parent a58151a commit aa39f41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
12 changes: 4 additions & 8 deletions Include/LTADSBEx.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
// #define ADSBEX_C_MSG "CMsgs"
#define ADSBEX_LAT "lat"
#define ADSBEX_LON "lon"
// #define ADSBEX_ELEVATION "GAlt" // geometric altitude
#define ADSBEX_ALT "alt" // barometric altitude
#define ADSBEX_ELEVATION "galt" // geometric altitude
// #define ADSBEX_ALT "alt" // barometric altitude
#define ADSBEX_HEADING "trak"
#define ADSBEX_GND "gnd"
// #define ADSBEX_IN_HG "InHg"
Expand All @@ -55,14 +55,14 @@
#define ADSBEX_SPD "spd"
#define ADSBEX_VSI "vsi"
#define ADSBEX_REG "reg"
// #define ADSBEX_COUNTRY "Cou"
#define ADSBEX_COUNTRY "cou"
#define ADSBEX_AC_TYPE_ICAO "type"
// #define ADSBEX_MAN "Man"
// #define ADSBEX_MDL "Mdl"
// #define ADSBEX_YEAR "Year"
#define ADSBEX_MIL "mil"
// #define ADSBEX_OP "Op"
// #define ADSBEX_OP_ICAO "OpIcao"
#define ADSBEX_OP_ICAO "opicao"
// #define ADSBEX_ENG_TYPE "EngType"
// #define ADSBEX_ENG_MOUNT "EngMount"
// #define ADSBEX_ORIGIN "From"
Expand All @@ -84,9 +84,6 @@
#define ERR_ADSBEX_NO_KEY_DEF "ADS-B Exchange: API Key missing. Get one at adsbexchange.com and enter it in Basic Settings."
#define ERR_ADSBEX_OTHER "ADS-B Exchange: Received an ERRor response: %s"

#define MSG_NO_REAL_WEATHER "No real weather active. Affects ADSBEx altitude correction. Enable in X-Plane's Flight Configuration > Weather."
constexpr std::chrono::duration INTLV_NO_REAL_WEATHER_WARN = std::chrono::minutes(10);

constexpr double ADSBEX_SMOOTH_AIRBORNE = 65.0; // smooth 65s of airborne data
constexpr double ADSBEX_SMOOTH_GROUND = 35.0; // smooth 35s of ground data

Expand All @@ -98,7 +95,6 @@ class ADSBExchangeConnection : public LTOnlineChannel, LTFlightDataChannel
protected:
std::string apiKey;
struct curl_slist* slistKey = NULL;
std::chrono::time_point<std::chrono::steady_clock> lastNoRealWeatherWarn;
public:
ADSBExchangeConnection () :
LTChannel(DR_CHANNEL_ADSB_EXCHANGE_ONLINE),
Expand Down
22 changes: 6 additions & 16 deletions Src/LTADSBEx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ bool ADSBExchangeConnection::ProcessFetchedData (mapLTFlightDataTy& fdMap)
{
LTFlightData::FDStaticData stat;
stat.reg = jog_s(pJAc, ADSBEX_REG);
stat.country = jog_s(pJAc, ADSBEX_COUNTRY);
stat.acTypeIcao = jog_s(pJAc, ADSBEX_AC_TYPE_ICAO);
stat.mil = jog_sb(pJAc, ADSBEX_MIL);
stat.trt = transpTy(jog_sl(pJAc,ADSBEX_TRT));
stat.opIcao = jog_s(pJAc, ADSBEX_OP_ICAO);
stat.call = jog_s(pJAc, ADSBEX_CALL);

// update the a/c's master data
Expand All @@ -160,8 +162,7 @@ bool ADSBExchangeConnection::ProcessFetchedData (mapLTFlightDataTy& fdMap)
dyn.pChannel = this;

// altitude, if airborne; correct for baro pressure difference
double alt_ft = dyn.gnd ? NAN : jog_sn_nan(pJAc, ADSBEX_ALT);
alt_ft += dataRefs.GetAltCorrection_ft();
const double alt_ft = dyn.gnd ? NAN : jog_sn_nan(pJAc, ADSBEX_ELEVATION);

// position and its ground status
positionTy pos (jog_sn_nan(pJAc, ADSBEX_LAT),
Expand Down Expand Up @@ -201,17 +202,6 @@ bool ADSBExchangeConnection::InitCurl ()
return false;
}

// we better have real weather enabled so that altitude correction
// is more likely to work well
// repeat this warning ever 10 minutes
if (!dataRefs.IsRealWeatherInUse() &&
std::chrono::steady_clock::now() >= lastNoRealWeatherWarn + INTLV_NO_REAL_WEATHER_WARN) {
lastNoRealWeatherWarn = std::chrono::steady_clock::now();
SHOW_MSG(logWARN, MSG_NO_REAL_WEATHER);
} else {
lastNoRealWeatherWarn = std::chrono::time_point<std::chrono::steady_clock>();
}

// let's do the standard CURL init first
if (!LTOnlineChannel::InitCurl())
return false;
Expand Down Expand Up @@ -708,9 +698,11 @@ bool ADSBExchangeHistorical::ProcessFetchedData (mapLTFlightDataTy& fdMap)
{
LTFlightData::FDStaticData stat;
stat.reg = jog_s(pJAc, ADSBEX_REG);
stat.country = jog_s(pJAc, ADSBEX_COUNTRY);
stat.acTypeIcao = jog_s(pJAc, ADSBEX_AC_TYPE_ICAO);
stat.mil = jog_sb(pJAc, ADSBEX_MIL);
stat.trt = transpTy(jog_sl(pJAc,ADSBEX_TRT));
stat.opIcao = jog_s(pJAc, ADSBEX_OP_ICAO);
stat.call = jog_s(pJAc, ADSBEX_CALL);

// update the a/c's master data
Expand All @@ -737,9 +729,7 @@ bool ADSBExchangeHistorical::ProcessFetchedData (mapLTFlightDataTy& fdMap)
(int)jog_sl(pJAc, ADSBEX_SIG));

// altitude, if airborne
double alt_ft = dyn.gnd ? NAN : jog_sn_nan(pJAc, ADSBEX_ALT);
// FIXME: Convert barometric to geometric altitude
// alt_f += (hPa - HPA_STANDARD) * FT_per_HPA;
const double alt_ft = dyn.gnd ? NAN : jog_sn_nan(pJAc, ADSBEX_ELEVATION);

// position data, including short trails
positionTy mainPos (jog_sn_nan(pJAc, ADSBEX_LAT),
Expand Down

0 comments on commit aa39f41

Please sign in to comment.