Skip to content
openair-parser / 1.14.4

openair-parser 1.14.4

Install from the command line:
Learn more about npm packages
$ npm install @openaip/openair-parser@1.14.4
Install via package.json:
"@openaip/openair-parser": "1.14.4"

About this version

OpenAIR Format Parser

A highly configurable OpenAIR parser for Node. The parser can also be configured to validate and fix defined geometries. The parser supports the original and the extended OpenAIR format.

Reads original OpenAIR airspace definitions with extendedFormat: false:

AC R
AN ED-R10B Todendorf-Putlos MON-SAT+
AH 40000ft MSL
AL GND
DP 54:25:00 N 010:40:00 E
DP 54:25:00 N 010:50:00 E
DP 54:26:00 N 010:53:00 E
DP 54:19:30 N 010:53:00 E
DP 54:15:00 N 010:41:00 E
DP 54:15:19 N 010:40:00 E
DP 54:20:00 N 010:40:00 E
DP 54:25:00 N 010:40:00 E

Outputs GeoJSON FeatureCollection:

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "properties": {
                "name": "ED-R10B Todendorf-Putlos MON-SAT+",
                "class": "R",
                "upperCeiling": {
                    "value": 40000,
                    "unit": "FT",
                    "referenceDatum": "MSL"
                },
                "lowerCeiling": {
                    "value": 0,
                    "unit": "FT",
                    "referenceDatum": "GND"
                }
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [10.666666666666666, 54.416666666666664],
                        [10.833333333333334, 54.416666666666664],
                        [10.883333333333333, 54.43333333333333],
                        [10.883333333333333, 54.325],
                        [10.683333333333334, 54.25],
                        [10.666666666666666, 54.25527777777778],
                        [10.666666666666666, 54.333333333333336],
                        [10.666666666666666, 54.416666666666664]
                    ]
                ]
            }
        }
    ]
}

Reads extended OpenAIR airspace definitions with extendedFormat: true:

AC D
AY TMA
AN TMA Todendorf-Putlos
AI b3836bab-6bc3-48c1-b918-01c2559e26fa
AF 123.505
AG Todendorf Information
AH 40000ft MSL
AL GND
DP 54:25:00 N 010:40:00 E
DP 54:25:00 N 010:50:00 E
DP 54:26:00 N 010:53:00 E
DP 54:19:30 N 010:53:00 E
DP 54:15:00 N 010:41:00 E
DP 54:15:19 N 010:40:00 E
DP 54:20:00 N 010:40:00 E
DP 54:25:00 N 010:40:00 E

Outputs GeoJSON FeatureCollection:

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "properties": {
                "id": "b3836bab-6bc3-48c1-b918-01c2559e26fa",
                "name": "TMA Todendorf-Putlos",
                "class": "D",
                "type": "TMA",
                "frequency": {
                    "value": "123.505",
                    "name": "Todendorf Information"
                },
                "upperCeiling": {
                    "value": 40000,
                    "unit": "FT",
                    "referenceDatum": "MSL"
                },
                "lowerCeiling": {
                    "value": 0,
                    "unit": "FT",
                    "referenceDatum": "GND"
                }
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            10.666666666666666,
                            54.416666666666664
                        ],
                        [
                            10.833333333333334,
                            54.416666666666664
                        ],
                        [
                            10.883333333333333,
                            54.43333333333333
                        ],
                        [
                            10.883333333333333,
                            54.325
                        ],
                        [
                            10.683333333333334,
                            54.25
                        ],
                        [
                            10.666666666666666,
                            54.25527777777778
                        ],
                        [
                            10.666666666666666,
                            54.333333333333336
                        ],
                        [
                            10.666666666666666,
                            54.416666666666664
                        ]
                    ]
                ]
            }
        }
    ]
}

Install

npm install -g @openaip/openair-parser

Node

const Parser = require('@openaip/openair-parser');

/*
 The default parser configuration for reference.
 */
const config = {
    // Defines allowed airspace classes used with the AC token. This configuration option only applies if the
    // standard "non-extended" format is used, i.e. with the config parameter "extendedFormat: false".
    airspaceClasses: [
        // default ICAO classes
        'A',
        'B',
        'C',
        'D',
        'E',
        'F',
        'G',
        // classes commonly found in openair files
        'R',
        'Q',
        'P',
        'GP',
        'WAVE',
        'W',
        'GLIDING',
        'RMZ',
        'TMZ',
        'CTR',
    ],
    // If "true" the parser will try to parse the extended OpenAIR-Format that contains additional tags
    // "AY", "AF", "AG" and "AI". If true, config parameters "allowedClassValues" and "allowedTypeValues" are
    // mandatory.
    extendedFormat: false,
    // defines a set of allowed values if the extended format is used -  default ICAO classes.
    extendedFormatClasses: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'UNCLASSIFIED'],
    // Defines a set of allowed "AY" values if the extended format is used. Otherwise, allows all used types.
    extendedFormatTypes: [],
    // flight level value to set for upper ceilings defined as "UNLIMITED"
    unlimited: 999,
    // defines the level of detail (smoothness) of arc/circular geometries
    geometryDetail: 100,
    // if true, validates each built airspace geometry to be valid/simple geometry - also checks for self intersections
    validateGeometry: true,
    // if true, uses "convexHull" to fix an invalid geometry - note that this may change the original airspace geometry!
    fixGeometry: false,
    // Sets the output geometry. Can be either "POLYGON" or "LINESTRING". Defaults to "POLYGON". "LINESTRING" can be used
    // to visualize invalid geometry definitions. Note that "validateGeometry" and "fixGeometry" has NO effect on "LINESTRING" geometry output!
    outputGeometry: 'POLYGON',    
    // If true, the GeoJSON output will contain the original OpenAIR airspace definition block for each airspace. Note that this will considerably increase JSON object size!
    includeOpenair: false,
    // By default, parser uses 'ft' (feet) as the default unit if not explicitly defined in AL/AH definitions. Allowed units are: 'ft' and 'm'.
    defaultAltUnit: 'ft',
    // Defines the target unit to convert to.  Allowed units are: 'ft' and 'm'.
    targetAltUnit: 'ft',
    // round altitude values
    roundAltValues: false,
};

const parser = new Parser(config);
await parser.parse('./path/to/openair-file.txt');
const geojson = parser.toGeoJson();

Extended OpenAIR Format

The original OpenAIR format specification has multiple shortcomings to meet today's demand to reflect the various types of existing airspaces and provide additional metadata. To overcome these shortcomings, an extended OpenAIR format is introduced that has several new tags.

Extended Format Tags:

AI

A required unique identifier string for each airspace, e.g. a UUID v4. The AI value must stay the same for each airspace throughout different versions if the file. The AI tag must be placed either before or directly after the AN tag. Placing the AI tag before the AN tag is preferred

AY

The optional AY tag specifies the airspace type, e.g. "TMA", "CTR" or "TMZ". Unlike in the original format, the AC tag must now only be used to specify the airspace ICAO class. If airspace has no type, i.e. is only ICAO class, the AY tag can be omitted. The AY tag must be placed directly after the AC tag.

AF

An optional tag that specifies the frequency of a ground station that provides information on the defined airspace. The AF must be placed directly after either the AI tag or the AG tag. If placed after the AG tag, the AG tag must directly be placed after the AI tag. The proposed best order is AF, then AG.

AG

If AF is present, defines the ground station name. May not be used without the AF tag. The AG must be placed directly after either the AF tag or the AF tag. If placed after the AG tag, the AF tag must directly be placed after the AI tag. The proposed best order is AF, then AG.

Original To Extended Format Conversion

To easily convert original OpenAIR to the extended format you can use our OpenAIR Fixer Tool. The tool will inject the required AI token for each airspace definition block that does not have it already. Additionally the tools takes care of tag order.

CLI

node cli.js -h

Usage: cli [options]

Options:
  -f, --input-filepath <inFilepath>    The input file path to the openAIR file.
  -o, --output-filepath <outFilepath>  The output filename of the generated geojson file.
  -V, --validate                       If set to true, validates geometries. Defaults to true.
  -F, --fix-geometry                   If set to true, tries to fix geometries. Note that this may change the original airspace geometry! Defaults to false.
  -E, --extended-format                If set to true, parser expects the extended OpenAIR format. Defaults to false.
  -h, --help                           Output usage information.

Simple command line usage:

node cli.js -f ./tests/fixtures/full-airspaces.txt -o test.json

Details


Assets

  • openair-parser-1.14.4.tgz

Download activity

  • Total downloads 117
  • Last 30 days 0
  • Last week 0
  • Today 0