npm package: @openscope-project/euroscope-sector-reader
Description: npm package to handle sector files for euroscope, transfrom them into object.
Author: Ericple Garrison
Latest version: 1.0.7

# Euroscope Sector Reader

## Updates
- 04/24/2023
  - Add chinese gbk decoding support

- 04/22/2023
  - Add symbReader

- 04/21/2023
  - Fixed error when reading sectors from VATSIM UK DIVISION
  - Add rwyReader

## Available Readers

### sctReader

- FUNCTION: sctReader(path, options);

- PARAMS
  - path: path to the sct file you want to read.
  - options: convert option.

- OPTIONS:
  - preProcessCoord
  
    | value |               description               |
    | :---: | :-------------------------------------: |
    | true  | Will preprocess coordinate into number  |
    | false | Won't preprocess coordinate into number |

  - coordPreProcessType

    |        value         |                                           description                                            |
    | :------------------: | :----------------------------------------------------------------------------------------------: |
    |       default        |                                      Just convert to number                                      |
    |       mercator       |                                Convert to number, and mercatorize                                |
    |        custom        |                             Convert coordinate using custom function                             |
    |    mercatorcustom    |              Convert to number, and mercatorize, then convert using custom function              |
    |    nativemercator    |                   Convert to number, and mercatorize using native c++ function                   |
    |    nativedefault     |                      Just convert to number, but using native c++ function                       |
    | nativemercatorcustom | Convert to number, and mercatorize using native c++ function, then convert using custom function |

  - preProcessDefinition

    | value |           description            |
    | :---: | :------------------------------: |
    | true  |       Will preprocess data       |
    | false | Won't preprocess definition data |

  - definitionPreProcessType

    |  value  |                   description                    |
    | :-----: | :----------------------------------------------: |
    | default |      preprocess data into 16bit color value      |
    | custom  | preprocess definition data using custom function |

- EXAMPLE

```js
import {sctReader} from '@openscope-project/euroscope-sector-reader';
const fPath = "some/existing/path/to/sctFile.sct";
sctReader(fPath, {
    preProcessCoord: true,
    coordPreProcessType: 'default'
}).then(sctObject => {
    // Your operation to the object
    console.log(Object.entries(sctObject));
});
```

### eseReader

- FUNCTION: eseReader(path, options);

- PARAMS
  - path: path to the ese file you want to read.
  - options: convert option.

- OPTIONS:
  - preProcessCoord
  
    | value |               description               |
    | :---: | :-------------------------------------: |
    | true  | Will preprocess coordinate into number  |
    | false | Won't preprocess coordinate into number |

  - coordPreProcessType

    |        value         |                                           description                                            |
    | :------------------: | :----------------------------------------------------------------------------------------------: |
    |       default        |                                      Just convert to number                                      |
    |       mercator       |                                Convert to number, and mercatorize                                |
    |        custom        |                             Convert coordinate using custom function                             |
    |    mercatorcustom    |              Convert to number, and mercatorize, then convert using custom function              |
    |    nativemercator    |                   Convert to number, and mercatorize using native c++ function                   |
    |    nativedefault     |                      Just convert to number, but using native c++ function                       |
    | nativemercatorcustom | Convert to number, and mercatorize using native c++ function, then convert using custom function |

- EXAMPLE

```js
import {eseReader} from '@openscope-project/euroscope-sector-reader';
const fPath = "some/existing/path/to/eseFile.ese";
eseReader(fPath, {
    preProcessCoord: true,
    coordPreProcessType: 'default'
}).then(eseObject => {
    // Your operation to the object
    console.log(Object.entries(eseObject));
});
```

### prfReader

- FUNCTION: prfReader(path);

- PARAMS
  - path: path to the prf file you want to read.

- EXAMPLE

```js
prfReader('path/to/something').then(value=>{console.log(value)});
```

### asrReader

- FUNCTION: asrReader(path);

- PARAMS
  - path: path to the asr file you want to read.

- EXAMPLE

```js
asrReader('path/to/something').then(value=>{console.log(value)});
```

### rwyReader

- FUNCTION: rwyReader(path);

- PARAMS
  - path: path to the asr file you want to read.

- EXAMPLE

```js
rwyReader(path.join(__dirname, 'path/to/something)')).then(value=>{
    console.log(value);
});
```

### symbReader

- FUNCTION: symbReader(path, options);

- PARAMS
  - path: path to the sct file you want to read.
  - options: convert option.

- OPTIONS:
  - preProcessColor

    | value |         description         |
    | :---: | :-------------------------: |
    | true  |    Will preprocess data     |
    | false | Won't preprocess color data |

  - colorPreProcessType

    |  value  |                   description                    |
    | :-----: | :----------------------------------------------: |
    | default |      preprocess data into 16bit color value      |
    | custom  | preprocess definition data using custom function |

- EXAMPLE

```js
import {symbReader} from '@openscope-project/euroscope-sector-reader';
const fPath = "some/existing/path/to/symbolFile.txt";
sctReader(fPath, {
    preProcessColor: true,
    coordPreProcessType: 'custom',
    customColorPreProcessCallback: (input) =>{
      return '0';
    }
}).then(obj => {
    // Your operation to the object
    console.log(Object.entries(obj));
});
```