Skip to content

Commit 68366fb

Browse files
committed
ADSBEx: Dynamically support v2 and v1
1 parent 24a73e3 commit 68366fb

File tree

3 files changed

+360
-175
lines changed

3 files changed

+360
-175
lines changed

Include/LTADSBEx.h

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,51 @@
5252
#define ADSBEX_TOTAL "total"
5353
#define ADSBEX_NOW "now"
5454
#define ADSBEX_AIRCRAFT_ARR "ac"
55-
#define ADSBEX_TRANSP_ICAO "hex" // Key data
56-
#define ADSBEX_RADAR_CODE "squawk" // Dynamic data
57-
#define ADSBEX_FLIGHT "flight"
58-
#define ADSBEX_LAT "lat"
59-
#define ADSBEX_LON "lon"
60-
#define ADSBEX_ALT_GEOM "alt_geom" // geometric altitude
61-
#define ADSBEX_ALT_BARO "alt_baro" // barometric altitude
62-
#define ADSBEX_NAV_QNH "nav_qnh" // QNH of barometric altitude
63-
#define ADSBEX_HEADING "true_heading"
64-
#define ADSBEX_TRACK "track"
65-
#define ADSBEX_SEE_POS "seen_pos"
66-
#define ADSBEX_SPD "gs"
67-
#define ADSBEX_VSI_GEOM "geom_rate"
68-
#define ADSBEX_VSI_BARO "baro_rate"
69-
#define ADSBEX_REG "r"
70-
#define ADSBEX_AC_TYPE_ICAO "t"
71-
#define ADSBEX_AC_CATEGORY "category"
72-
#define ADSBEX_FLAGS "dbFlags"
55+
56+
// Version 2 keys
57+
#define ADSBEX_V2_TRANSP_ICAO "hex" // Key data
58+
#define ADSBEX_V2_RADAR_CODE "squawk" // Dynamic data
59+
#define ADSBEX_V2_FLIGHT "flight"
60+
#define ADSBEX_V2_LAT "lat"
61+
#define ADSBEX_V2_LON "lon"
62+
#define ADSBEX_V2_ALT_GEOM "alt_geom" // geometric altitude
63+
#define ADSBEX_V2_ALT_BARO "alt_baro" // barometric altitude
64+
#define ADSBEX_V2_NAV_QNH "nav_qnh" // QNH of barometric altitude
65+
#define ADSBEX_V2_HEADING "true_heading"
66+
#define ADSBEX_V2_TRACK "track"
67+
#define ADSBEX_V2_SEE_POS "seen_pos"
68+
#define ADSBEX_V2_SPD "gs"
69+
#define ADSBEX_V2_VSI_GEOM "geom_rate"
70+
#define ADSBEX_V2_VSI_BARO "baro_rate"
71+
#define ADSBEX_V2_REG "r"
72+
#define ADSBEX_V2_AC_TYPE_ICAO "t"
73+
#define ADSBEX_V2_AC_CATEGORY "category"
74+
#define ADSBEX_V2_FLAGS "dbFlags"
75+
76+
// Version 1 keys
77+
#define ADSBEX_TIME "ctime"
78+
#define ADSBEX_V1_TRANSP_ICAO "icao" // Key data
79+
#define ADSBEX_V1_RADAR_CODE "sqk" // Dynamic data
80+
#define ADSBEX_V1_CALL "call"
81+
#define ADSBEX_V1_LAT "lat"
82+
#define ADSBEX_V1_LON "lon"
83+
#define ADSBEX_V1_ELEVATION "galt" // geometric altitude
84+
#define ADSBEX_V1_ALT "alt" // barometric altitude
85+
#define ADSBEX_V1_HEADING "trak"
86+
#define ADSBEX_V1_GND "gnd"
87+
#define ADSBEX_V1_POS_TIME "postime"
88+
#define ADSBEX_V1_SPD "spd"
89+
#define ADSBEX_V1_VSI "vsi"
90+
#define ADSBEX_V1_REG "reg"
91+
#define ADSBEX_V1_COUNTRY "cou"
92+
#define ADSBEX_V1_AC_TYPE_ICAO "type"
93+
#define ADSBEX_V1_MIL "mil"
94+
#define ADSBEX_V1_OP_ICAO "opicao"
95+
#define ADSBEX_V1_ORIGIN "from"
96+
#define ADSBEX_V1_DESTINATION "to"
97+
98+
#define ADSBEX_V1_TYPE_GND "-GND"
99+
73100

74101
// Testing an API key
75102
#define ADSBEX_VERIFY_KEY_URL "https://adsbexchange.com/api/aircraft/icao/000000"
@@ -119,6 +146,18 @@ class ADSBExchangeConnection : public LTOnlineChannel, LTFlightDataChannel
119146
// need to add/cleanup API key
120147
virtual bool InitCurl ();
121148
virtual void CleanupCurl ();
149+
150+
/// Process v2 data
151+
void ProcessV2 (JSON_Object* pJAc, LTFlightData::FDKeyTy& fdKey,
152+
mapLTFlightDataTy& fdMap,
153+
const double tsCutOff, const double adsbxTime,
154+
const positionTy& viewPos);
155+
/// Process v1 data
156+
void ProcessV1 (JSON_Object* pJAc, LTFlightData::FDKeyTy& fdKey,
157+
mapLTFlightDataTy& fdMap,
158+
const double tsCutOff, const double adsbxTime,
159+
const positionTy& viewPos);
160+
122161
// make list of HTTP header fields
123162
static struct curl_slist* MakeCurlSList (keyTypeE keyTy, const std::string theKey);
124163
// read header and parse for request limit/remaining

0 commit comments

Comments
 (0)