How to find the airports ICAO

Discuss on the SimConnect SDK can be used by programmers to write add-on components for Prepar3D
Locked
voss1917
Posts: 28
Joined: Sat Sep 23, 2017 10:56 am

How to find the airports ICAO

Post by voss1917 »

Hi,
In an C++ app I am developing, I need to find the airport ICAO of the airport I have my airplane on. The airplane can be placed anywhere withing the airport area. I am using SIMCONNECT_RECV_FACILITIES_LIST to get a list all airports in the area. But, how can I make sure that the correct airport can be identified from this list. It must be 100% correct.
User avatar
ronh991
Posts: 724
Joined: Sat Jan 19, 2013 1:46 am
Location: Ontario, Canada

Re: How to find the airports ICAO

Post by ronh991 »

Can you not use:

SimConnect_RequestFacilitiesList to get a list of SIMCONNECT_RECV_AIRPORT_LIST, which will contain a list of SIMCONNECT_DATA_FACILITY_AIRPORT structures.

Then compare your aircraft lat/lon with the ICAO lat/lon. Pick the one with the smallest difference between the co-ords.
Ron
Locked