V2 Airport .apt file format

Moderators: Uros, OXO

Post Reply
efoertsch
Posts: 10
Joined: Mon Apr 09, 2007 10:16 pm

V2 Airport .apt file format

Post by efoertsch » Mon Apr 20, 2020 9:05 pm

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
Eric
LS-4a - "QW"

vnks
Posts: 41
Joined: Wed Mar 27, 2019 5:12 pm

Re: V2 Airport .apt file format

Post by vnks » Mon Apr 20, 2020 9:27 pm

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)

efoertsch
Posts: 10
Joined: Mon Apr 09, 2007 10:16 pm

Re: V2 Airport .apt file format

Post by efoertsch » Mon Apr 20, 2020 10:14 pm

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
Eric
LS-4a - "QW"

vnks
Posts: 41
Joined: Wed Mar 27, 2019 5:12 pm

Re: V2 Airport .apt file format

Post by vnks » Mon Apr 20, 2020 10:24 pm

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.

efoertsch
Posts: 10
Joined: Mon Apr 09, 2007 10:16 pm

Re: V2 Airport .apt file format

Post by efoertsch » Mon Apr 20, 2020 11:35 pm

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
Eric
LS-4a - "QW"

efoertsch
Posts: 10
Joined: Mon Apr 09, 2007 10:16 pm

Re: V2 Airport .apt file format

Post by efoertsch » Mon Apr 20, 2020 11:35 pm

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
Eric
LS-4a - "QW"

vnks
Posts: 41
Joined: Wed Mar 27, 2019 5:12 pm

Re: V2 Airport .apt file format

Post by vnks » Mon Apr 20, 2020 11:43 pm

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.

User avatar
BOD1
Posts: 2142
Joined: Mon Aug 07, 2006 2:45 pm
Location: Brittany, France
Contact:

Re: V2 Airport .apt file format

Post by BOD1 » Tue Apr 21, 2020 12:59 am

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
Image
Please use this button to send me a PM, Forum messaging is too limited.
Image

efoertsch
Posts: 10
Joined: Mon Apr 09, 2007 10:16 pm

Re: V2 Airport .apt file format

Post by efoertsch » Tue Apr 21, 2020 1:44 am

Thank you BOD1!
Eric
LS-4a - "QW"

User avatar
Bre901
Posts: 1790
Joined: Tue Nov 22, 2016 8:57 pm
Location: Annecy (France)
Contact:

Re: V2 Airport .apt file format

Post by Bre901 » Tue Apr 21, 2020 6:14 am

Altitude is not used by Condor anymore (uses terrain data), but must be present.
CN: MPT — CondorUTill webpage: https://condorutill.fr/

Post Reply