npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@openaip/openair-parser

v1.16.1

Published

OpenAIR format parser. Parses openAIR formatted string and outputs it in JSON or GeoJSON.

Downloads

119

Readme

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

An optional tag that specifies a 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

A required tag that 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 should be set to UNCLASSIFIED. 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 should be placed directly before or after the AG tag. The proposed best order is AF, then AG.

AG

An optional tag that specifies the ground station name. May not be used without the AF tag. The AG must be placed directly before or after the AF 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