Page 1 of 1

V2 Airport .apt file format

Posted: Mon Apr 20, 2020 9:05 pm
by efoertsch
Condor scenery newbie here.

I see that airports are defined in the .apt file but the I can't decipher the file format. Is there a document that gives the format or can someone provide it? I would like to create a little utility to take a .cup file, extract the airports and create the .apt file. The utility would also spit out a separate file just with turnpoints.

Also is the elevation, length and width all in meters? Is the second entry field under direction for a 2nd runway?

Thanks!

Eric

Re: V2 Airport .apt file format

Posted: Mon Apr 20, 2020 9:27 pm
by vnks
Hey, here's some very dirty Python code to read the .apt file, hopefully it helps. Everything is in meters:

Code: Select all

with open("airport.apt", "rb") as afile:
    while True:
        len = struct.unpack("B", afile.read(1))[0]
        name = afile.read(len)
        print(name)
        padding = afile.read(0x23 - len)
        lat, lon, alt, direction, length, width, d1, d2, d3 = struct.unpack("<fffllllll", afile.read(36))
        if (direction > 365):
            direction = (direction - 100000) / 100 + ((direction % 100) / 100.0)
        print(lat, lon, alt, direction, length, width, d1, d2, d3)

Re: V2 Airport .apt file format

Posted: Mon Apr 20, 2020 10:14 pm
by efoertsch
Thanks for speedy response.

I am a Java guy, not Python, but thought I would give it a try and perhaps reverse engineer a Java solution. But am getting the following error.

len = struct.unpack("B", afile.read(1))[0]
NameError: name 'struct' is not defined

Thoughts?

Eric

Re: V2 Airport .apt file format

Posted: Mon Apr 20, 2020 10:24 pm
by vnks
Sorry, you'll need an "import struct" at the top of the file, and maybe a few more? It's a fragment from a larger script, here's all of them from there:

Code: Select all

import io
import sys
import re
import struct
import csv
import math
struct.unpack calls describe the binary format - https://docs.python.org/3/library/struc ... characters.

Re: V2 Airport .apt file format

Posted: Mon Apr 20, 2020 11:35 pm
by efoertsch
Thanks again. Added above imports and running now. Now need to look at code vs output to figure out what's what. File format in plain English (or any language) would still be good! :D

Re: V2 Airport .apt file format

Posted: Mon Apr 20, 2020 11:35 pm
by efoertsch
Thanks again. Added above imports and running now. Now need to look at code vs output to figure out what's what. File format in plain English (or any language) would still be good! :D

Re: V2 Airport .apt file format

Posted: Mon Apr 20, 2020 11:43 pm
by vnks
It's basically a 36-character string for name, with length in the leading byte, followed by 3 floats and 6 longs, 4 bytes each, little-endian.

Re: V2 Airport .apt file format

Posted: Tue Apr 21, 2020 12:59 am
by BOD1
May not be updated with latest update (when orientation>365°, the orientation must be divided by 100 to obtain a precise value):

.apt format 72 bytes per airport, file size/72=nb of airport
1 byte: length of the name
35 bytes: name of the airport
float : latitude (in °)
float: longitude (in °)
float : altitude (in m.)
int : orientation (in °)
int : length of the runway
int : runway width
int = 1=asphalt
float: frequency
boolean (1 byte): track info flag (1=primary dir reversed)
boolean (1 byte) : track info flag (1=tow primary dir left side)
boolean (1 byte) : track info flag (1=tow secondary dir left side)
1 empty byte

Re: V2 Airport .apt file format

Posted: Tue Apr 21, 2020 1:44 am
by efoertsch
Thank you BOD1!

Re: V2 Airport .apt file format

Posted: Tue Apr 21, 2020 6:14 am
by Bre901
Altitude is not used by Condor anymore (uses terrain data), but must be present.