A320 Destination Airport Elevation?

Is there a variable for the destination airport elevation?
thanks

I’m trying some a random but not making any progress.
thanks

Do you know the location of the airport (coordinates)? If so, you could (temporarily) spawn an AI aircraft at that location and get the ground altitude, as suggested here:

Apparently this technique has already been used in FSX days :wink:

Another question: how do you get the destination (and source) airport (I am interested in the ICAO code)? Do you subscribe to the airport list, or is there a way to get source and destination from the flight plan (if defined), in a generic (for all aircraft) way?

1 Like

returns “KLAX” for example

simconnect.AddToDataDefinition(DEFINITIONS.WaypointListStruct, “ATC RUNWAY AIRPORT NAME”, null, SIMCONNECT_DATATYPE.STRING256, 0.0f, SimConnect.SIMCONNECT_UNUSED);

void SimConnect_OnRecvSimobjectData(SimConnect sender, SIMCONNECT_RECV_SIMOBJECT_DATA data)

case DATA_REQUESTS.WaypointListRequest:
WaypointListStruct wpStruct = (WaypointListStruct)data.dwData[0];
ExtractAirportId(wpStruct.atc_runway_airport_name_txt);

extract the Airport name
private string ExtractAirportId(string airportTitle)
{
int p1 = airportTitle.IndexOf(".");
int p2 = airportTitle.IndexOf(".", p1 + 1);
int len = p2 - p1 -1;
if (p2 > 0)
{
return airportTitle.Substring(p1 + 1, len);
}
return “”;
}

[StructLayout(LayoutKind.Sequential, Pack = 1)] //Waypoint
public struct WaypointListStruct
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x100)]
public string nextWp;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x100)]
public string prevWp;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x100)]
public string title;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x100)]
public string atc_runway_airport_name_txt;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x100)]
public string runway_name;
}

1 Like

Ah, ATC RUNWAY AIRPORT NAME, of course :slight_smile: I think I considered this at some point as well, but since I got a “translatable string” back I somehow abandoned this idea (in the hope that there was a “cleaner” way to get to the ICAO code).

But of course, parsing the “translatable string” (which if I remember correctly is prefixed with a “T” or so) and simply extracting the ICAO code does work (unless of course the format or message changes ;)).

I looked at the code of Little Navmap at the time, and it seems that an actual lookup into some “translation database” is made; which has been previously extracted from the FS2020 installation? Or directly accessed in the FS2020 installation folder (somehow)? I did not go into the implementation details here, as “translating FS2020 strings” is not something that I intend to do.

Anyway, the next best thing that came to mind was

  • to subscribe to the facilities list (at the very beginning of the flight)
  • the closest (*) airport is presumably the start airport
  • at the end of the flight the closest airport (*) is presumably the destination airport
  • the SIMCONNECT_DATA_FACILITY_AIRPORT contains the ICAO code
  • Oh! @ZenMusic2 : and I just realised that besides the longitude/latitude it also contains the altitude you’ve asked about :slight_smile:

Of course I say “presumably” because depending on the distance to (and the size of) the airport it might be that the player only flew to (or started from) the vicinity of the airport, but did not actually land (or take-off). But a simple distance check with some threshold (large enough to cover the “largest expected airport”) might be sufficiently precise, for all practical applications…

(*) the facilities list probably needs to be sorted each time (according to distance from the player, using longitude/latitude as reference), as new entries are simply appended each time - or so I understand

1 Like

Oh and for those who haven’t noticed it just yet: the SimvarWatcher example application in the latest MSFS SDK (version 0.12) does support “string variables”: there is an additional “Is String” checkbox, which should allow to actually observe simulation variables such as the previously discussed ATC RUNWAY AIRPORT NAME variable.

Unfortunatelly this little new feature apparently brought other issues, one of which can be worked around quite easily (simply add “False” to the stored file entries), the other requires an actual “parser fix” in the C# code (seems like the parser “swallows” the variable index like :1, :2 etc when loading a *.simvars file):

(I have submitted this to ZenDesk already)

1 Like