I am trying to get the start and destination airport ICAO code, as sampled at the very beginning and end of the flight.
So far I did experiments (with the SimvarWatcher) with the simulation variables NAV IDENT, ADF IDENT, NAV NAME and the like. However I was only able to actually get some value at all with the GPS APPROACH AIRPORT ID, but only once I enabled “Approach” in the given aircraft’s autopilot system - but I need a (more or less) reliable way to get the (closest) airport without the pilot having to do any interactions with either ATC and/or the autopilot / navigation systems.
So I have SimConnect_RequestFacilitiesList a try. But I get the felling that I am either doing something wrong, or the functionality is simply not correctly implemented within FS2020:
When I do a request like
::SimConnect_RequestFacilitiesList(d->simConnectHandle, ::SIMCONNECT_FACILITY_LIST_TYPE_AIRPORT, StartAirportList);
I do get data back in my “dispatcher” (callback) function. It seems that with each reply you get back information (ICAO, lat/lon/alt) for exactly one airport (only), as the rgData “array” in SIMCONNECT_RECV_AIRPORT_LIST is a “fixed size array” with exactly one (1) element:
Where the element of the array rgData is of type: SIMCONNECT_DATA_FACILITY_AIRPORT
That’s fine for me, because the inherited struct SIMCONNECT_RECV_FACILITIES_LIST contains additional members, which basically tell you that you are “receiving the i-th element out of total N elements”:
dwREntry // the i-th entry dwOutOf // total number of fascilities
When stepping through my code with the debugger my dispatcher is indeed called 30 times, and the dwOutOf member indicates exactly this:
Now here is the problem:
I get 30 times the same airport (ICAO “HTSE”), with the same coordinates:
SIMCONNECT_RECV_ID_AIRPORT_LIST: array size: 1243 item: 0 out of: 30 ICAO: HTSE
SIMCONNECT_RECV_ID_AIRPORT_LIST: array size: 1243 item: 1 out of: 30 ICAO: HTSE
SIMCONNECT_RECV_ID_AIRPORT_LIST: array size: 1243 item: 2 out of: 30 ICAO: HTSE
SIMCONNECT_RECV_ID_AIRPORT_LIST: array size: 1243 item: 3 out of: 30 ICAO: HTSE
SIMCONNECT_RECV_ID_AIRPORT_LIST: array size: 1117 item: 29 out of: 30 ICAO: HTSE
And what’s more: that airport is not anywhere near the airport where my aircraft is sitting at the moment I do those requests: I am sitting at Zurich airport (LSZH - in Switzerland) with lattitude / longitude 47° 27’ 38" N / 8° 33’ 0" E, which is far, far away from the given latitude / longitude -4.05 / 37.79 - which places HTSE into Africa (somewhere “near” the Kilimanjaro mountain)!
So why am I getting 30 times the same airport information of an airport which is not even on the same continent (Africa) than the one my aircraft is sitting on the runway (Europe)?
Or does anyone spot some stupid mistake I am making in my brain here?
→ Did anyone successfully retrieve the “list of fascilities” (airports, navigation points, …) near and around the user aircraft?