Skip to content

Commit

Permalink
license + cosmetics
Browse files Browse the repository at this point in the history
Signed-off-by: Stephan Besser <[email protected]>
  • Loading branch information
reskume committed Jun 15, 2021
1 parent 7f822b0 commit f260b68
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 114,258 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules/
secrets/
.npmrc
nohup.out
var/
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

A configurable [OpenAIR](http://www.winpilot.com/usersguide/userairspace.asp) format parser for Node.

#Node
Node
=

```javascript
const Parser = require('@openaip/openair-parser');
Expand Down Expand Up @@ -90,7 +91,8 @@ Parser result is a GeoJSON FeatureCollection:
}
```

#CLI
CLI
=

```bash
node cli.js -h
Expand Down
7 changes: 7 additions & 0 deletions license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2021 OpenAIP

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"main": "index.js",
"license": "mit",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/openAIP/openaip-openair-parser.git"
Expand Down
4 changes: 2 additions & 2 deletions src/airspace-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ const {
const Airspace = require('./airspace');

/**
* @typedef typedefs.openaipOpenairParser.AirspaceFactoryConfig
* @typedef typedefs.openaip.OpenairParser.AirspaceFactoryConfig
* @type Object
* @property {number} [geometryDetail] - Defines the steps that are used to calculate arcs and circles. Defaults to 50. Higher values mean smoother circles but a higher number of polygon points.
*/

class AirspaceFactory {
/**
* @param {typedefs.openaipOpenairParser.AirspaceFactoryConfig} config
* @param {typedefs.openaip.OpenairParser.AirspaceFactoryConfig} config
*/
constructor(config) {
const { geometryDetail } = config;
Expand Down
2 changes: 1 addition & 1 deletion src/default-parser-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Default parser configuration.
*
* @type {typedefs.openaipOpenairParser.ParserConfig}
* @type {typedefs.openaip.OpenairParser.ParserConfig}
*/
module.exports = {
// defines allowed airspace classes used with the AC token
Expand Down
8 changes: 4 additions & 4 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const PARSER_STATE = {
};

/**
* @typedef typedefs.openaipOpenairParser.ParserConfig
* @typedef typedefs.openaip.OpenairParser.ParserConfig
* @type Object
* @property {string[]} [airspaceClasses] - A list of allowed AC classes. If AC class found in AC definition is not found in this list, the parser will throw an error.
* @property {number} [unlimited] - Defines the flight level that is used instead of an airspace ceiling that is defined as "unlimited". Defaults to 999;
Expand All @@ -31,7 +31,7 @@ const PARSER_STATE = {
*/

/**
* @typedef typedefs.openaipOpenairParser.ParserResult
* @typedef typedefs.openaip.OpenairParser.ParserResult
* @type Object
* @property {boolean} success - If true, parsing was successful, false if not.
* @property {FeatureCollection} - [geojson] - On success, contains a GeoJson FeatureCollection representation of the parsed openAIR file.
Expand All @@ -45,7 +45,7 @@ const PARSER_STATE = {
*/
class Parser {
/**
* @param {typedefs.openaipOpenairParser.ParserConfig} [config] - The parser configuration
* @param {typedefs.openaip.OpenairParser.ParserConfig} [config] - The parser configuration
*/
constructor(config) {
const configuration = Object.assign(defaultConfig, config);
Expand Down Expand Up @@ -153,7 +153,7 @@ class Parser {
}

/**
* @return {typedefs.openaipOpenairParser.ParserResult}
* @return {typedefs.openaip.OpenairParser.ParserResult}
*/
toGeojson() {
const geojsonFeatures = this._airspaces.map((value) => {
Expand Down
12 changes: 6 additions & 6 deletions src/tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ParserError = require('./parser-error');
* List of token types required for "isAllowedNextToken" type checks. Mainly to avoid directly requiring tokens in a token
* and creating circular dependencies.
*
* @typedef typedefs.openaipOpenairParser.TokenTypes
* @typedef typedefs.openaip.OpenairParser.TokenTypes
* @type {Object}
* @property {string} COMMENT_TOKEN
* @property {string} BLANK_TOKEN
Expand Down Expand Up @@ -50,7 +50,7 @@ const TOKEN_TYPES = {
};

/**
* @typedef typedefs.openaipOpenairParser.TokenizerConfig
* @typedef typedefs.openaip.OpenairParser.TokenizerConfig
* @type Object
* @property {string[]} [airspaceClasses] - A list of allowed AC classes. If AC class found in AC definition is not found in this list, the parser will throw an error.
* @property {number} [unlimited] - Defines the flight level that is used instead of an airspace ceiling that is defined as "unlimited". Defaults to 999;
Expand All @@ -64,15 +64,15 @@ const TOKEN_TYPES = {
*/
class Tokenizer {
/**
* @param {typedefs.openaipOpenairParser.TokenizerConfig} config
* @param {typedefs.openaip.OpenairParser.TokenizerConfig} config
*/
constructor(config) {
const { airspaceClasses, unlimited } = config;
checkTypes.assert.array.of.nonEmptyString(airspaceClasses);
checkTypes.assert.integer(unlimited);

this._config = config;
/** @type {typedefs.openaipOpenairParser.Token[]} */
/** @type {typedefs.openaip.OpenairParser.Token[]} */
this._tokenizers = [
new CommentToken({ tokenTypes: TOKEN_TYPES }),
new BlankToken({ tokenTypes: TOKEN_TYPES }),
Expand All @@ -86,7 +86,7 @@ class Tokenizer {
new DcToken({ tokenTypes: TOKEN_TYPES }),
new DbToken({ tokenTypes: TOKEN_TYPES }),
];
/** @type {typedefs.openaipOpenairParser.Token[]} */
/** @type {typedefs.openaip.OpenairParser.Token[]} */
this._tokens = [];
// previous processed token, used to validate correct token order
/** @type {BaseLineToken} */
Expand All @@ -100,7 +100,7 @@ class Tokenizer {
* Tokenizes the openAIR file at given path and returns the list of created tokens.
*
* @param filepath
* @return {typedefs.openaipOpenairParser.Token[]}
* @return {typedefs.openaip.OpenairParser.Token[]}
*/
tokenize(filepath) {
this._reset();
Expand Down
6 changes: 3 additions & 3 deletions src/tokens/ac-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const BaseLineToken = require('./base-line-token');
const checkTypes = require('check-types');

/**
* @typedef typedefs.openaipOpenairParser.AcTokenConfig
* @typedef typedefs.openaip.OpenairParser.AcTokenConfig
* @type Object
* @property {string[]} [airspaceClasses] - A list of allowed AC classes. If AC class found in AC definition is not found in this list, the parser will throw an error.
* @property {typedefs.openaipOpenairParser.TokenTypes} tokenTypes - List of all known token types. Required to do "isAllowedNextToken" type checks.
* @property {typedefs.openaip.OpenairParser.TokenTypes} tokenTypes - List of all known token types. Required to do "isAllowedNextToken" type checks.
*/

/**
Expand All @@ -15,7 +15,7 @@ class AcToken extends BaseLineToken {
static type = 'AC';

/**
* @param {typedefs.openaipOpenairParser.AcTokenConfig} config
* @param {typedefs.openaip.OpenairParser.AcTokenConfig} config
*/
constructor(config) {
const { airspaceClasses, tokenTypes } = config;
Expand Down
18 changes: 9 additions & 9 deletions src/tokens/base-altitude-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const BaseLineToken = require('./base-line-token');
const checkTypes = require('check-types');

/**
* @typedef typedefs.openaipOpenairParser.BaseAltitudeTokenConfig
* @typedef typedefs.openaip.OpenairParser.BaseAltitudeTokenConfig
* @type Object
* @property {BaseLineToken} tokenTypes - List of all known token types. Required to do "isAllowedNextToken" type checks.
* @property {number} [unlimited] - Defines the flight level to set if an airspace ceiling is defined with "unlimited". Defaults to 999;
*/

/**
* @typedef typedefs.openaipOpenairParser.AltitudeReader
* @typedef typedefs.openaip.OpenairParser.AltitudeReader
* @type Object
* @function canHandle
* @function read
Expand All @@ -18,7 +18,7 @@ const checkTypes = require('check-types');
/**
* Reads a default airspace ceiling definition, e.g. "2700ft MSL".
*
* @type {typedefs.openaipOpenairParser.AltitudeReader}
* @type {typedefs.openaip.OpenairParser.AltitudeReader}
*/
class AltitudeDefaultReader {
constructor() {
Expand Down Expand Up @@ -97,7 +97,7 @@ class AltitudeDefaultReader {
/**
* Reads a flight level airspace ceiling definition, e.g. FL80.
*
* @type {typedefs.openaipOpenairParser.AltitudeReader}
* @type {typedefs.openaip.OpenairParser.AltitudeReader}
*/
class AltitudeFlightLevelReader {
constructor() {
Expand Down Expand Up @@ -132,7 +132,7 @@ class AltitudeFlightLevelReader {
/**
* Reads a surface airspace ceiling definition, e.g. GND.
*
* @type {typedefs.openaipOpenairParser.AltitudeReader}
* @type {typedefs.openaip.OpenairParser.AltitudeReader}
*/
class AltitudeSurfaceReader {
constructor() {
Expand Down Expand Up @@ -168,7 +168,7 @@ class AltitudeSurfaceReader {
/**
* Reads unlimited ceiling airspace definitions.
*
* @type {typedefs.openaipOpenairParser.AltitudeReader}
* @type {typedefs.openaip.OpenairParser.AltitudeReader}
*/
class AltitudeUnlimitedReader {
/**
Expand Down Expand Up @@ -203,11 +203,11 @@ class AltitudeUnlimitedReader {
/**
* Tokenizes "AH/AL" airspace ceiling definitions.
*
* @type {typedefs.openaipOpenairParser.AltitudeReader}
* @type {typedefs.openaip.OpenairParser.AltitudeReader}
*/
class BaseAltitudeToken extends BaseLineToken {
/**
* @param {typedefs.openaipOpenairParser.BaseAltitudeTokenConfig} config
* @param {typedefs.openaip.OpenairParser.BaseAltitudeTokenConfig} config
*/
constructor(config) {
const { unlimited, tokenTypes } = config;
Expand All @@ -216,7 +216,7 @@ class BaseAltitudeToken extends BaseLineToken {

this._unlimited = unlimited;

/** @type {typedefs.openaipOpenairParser.AltitudeReader[]} */
/** @type {typedefs.openaip.OpenairParser.AltitudeReader[]} */
this._readers = [
new AltitudeDefaultReader(),
new AltitudeFlightLevelReader(),
Expand Down
6 changes: 3 additions & 3 deletions src/tokens/base-line-token.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const checkTypes = require('check-types');

/**
* @typedef typedefs.openaipOpenairParser.TokenConfig
* @typedef typedefs.openaip.OpenairParser.TokenConfig
* @type Object
* @property {typedefs.openaipOpenairParser.TokenTypes} tokenTypes - List of all known token types. Required to do "isAllowedNextToken" type checks.
* @property {typedefs.openaip.OpenairParser.TokenTypes} tokenTypes - List of all known token types. Required to do "isAllowedNextToken" type checks.
*/

class BaseLineToken {
static type = '';

/**
* @param {typedefs.openaipOpenairParser.TokenConfig} config
* @param {typedefs.openaip.OpenairParser.TokenConfig} config
*/
constructor(config) {
const { tokenTypes } = config;
Expand Down
6 changes: 3 additions & 3 deletions src/tokens/eof-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const BaseLineToken = require('./base-line-token');
const checkTypes = require('check-types');

/**
* @typedef typedefs.openaipOpenairParser.EofTokenConfig
* @typedef typedefs.openaip.OpenairParser.EofTokenConfig
* @type Object
* @property {number} lastLineNumber - Last line number of file.
* @property {typedefs.openaipOpenairParser.TokenTypes} tokenTypes - List of all known token types. Required to do "isAllowedNextToken" type checks.
* @property {typedefs.openaip.OpenairParser.TokenTypes} tokenTypes - List of all known token types. Required to do "isAllowedNextToken" type checks.
*/

Expand All @@ -17,7 +17,7 @@ class EofToken extends BaseLineToken {
static type = 'EOF';

/**
* @param {typedefs.openaipOpenairParser.EofTokenConfig} config
* @param {typedefs.openaip.OpenairParser.EofTokenConfig} config
*/
constructor(config) {
const { tokenTypes, lastLineNumber } = config;
Expand Down
Loading

0 comments on commit f260b68

Please sign in to comment.