aewx-metar-parser 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.editorconfig CHANGED
@@ -1,11 +1,12 @@
1
- # editorconfig.org
1
+ # EditorConfig is awesome: http://EditorConfig.org
2
2
 
3
3
  root = true
4
4
 
5
5
  [*]
6
- charset = utf-8
6
+ end_of_line = lf
7
7
  insert_final_newline = true
8
8
  trim_trailing_whitespace = true
9
- end_of_line = lf
9
+ charset = utf-8
10
10
  indent_style = space
11
11
  indent_size = 2
12
+ max_line_length = 120
@@ -0,0 +1,4 @@
1
+ *.json
2
+ .vscode
3
+ dist/
4
+ types/
package/CHANGELOG.md CHANGED
@@ -1,23 +1,26 @@
1
- Change log
2
- ==========
1
+ # Change log
3
2
 
4
- For detailed information check [`metar-parser`'s releases on Github](https://github.com/fboes/metar-parser/releases).
3
+ ## 2.0.0
5
4
 
6
- * 💊 Fix METAR interpretation if wind is missing
5
+ - Changed to TypeScript
6
+ - Set `null` instead of `0` on missing information
7
+ - Fixed `ceiling` property
8
+ - Changed data structure to adhere to https://www.checkwxapi.com/metar
7
9
 
8
- 0.10.0
9
- ------
10
+ ## 1.0.0
10
11
 
11
- * 💣 Changed object properties to closer match CheckWX properties. This changes `conditions`, `ceiling`, `visibility`
12
- * 🎁 Add property `flight_category`
13
- * 💊 If no visibility is given, assume 10 SM
12
+ - Fix METAR interpretation if wind is missing
14
13
 
15
- 0.9.3
16
- -----
14
+ ## 0.10.0
17
15
 
18
- * 💊 Improve handling of `VRB`
16
+ - Changed object properties to closer match CheckWX properties. This changes `conditions`, `ceiling`, `visibility`
17
+ - Add property `flight_category`
18
+ - If no visibility is given, assume 10 SM
19
19
 
20
- 0.9.0
21
- -----
20
+ ## 0.9.3
22
21
 
23
- * 🎁 Initial commit
22
+ - Improve handling of `VRB`
23
+
24
+ ## 0.9.0
25
+
26
+ - Initial commit
package/CONTRIBUTING.md CHANGED
@@ -1,38 +1,34 @@
1
- Contributing
2
- ============
1
+ # Contributing
3
2
 
4
- Submitting issues
5
- -----------------
3
+ ## Submitting issues
6
4
 
7
5
  1. Search in the [Github issues](https://github.com/fboes/metar-parser/issues), if a similar issue has already been filed. If so, please contribute to this issue.
8
6
  2. On [opening a new issue on Github](https://github.com/fboes/metar-parser/issues), add a descriptive title describing in a few words your problem. Think of the terms you would have searched for to find this issue.
9
7
  3. Leave a reproducible list of steps leading to the error.
10
8
  4. If possible add the Node and NPM version you ware using as well as the OS.
11
9
 
12
- Setup for development
13
- ---------------------
10
+ ## Setup for development
14
11
 
15
12
  You will need:
16
13
 
17
14
  1. A [Github account](https://github.com/) and Git
18
15
  2. [NodeJs](https://nodejs.org/) with NPM installed
19
16
 
20
- Making changes
21
- --------------
17
+ ## Making changes
22
18
 
23
19
  1. [Fork the repository on GitHub](https://help.github.com/articles/fork-a-repo/)
24
20
  2. Checkout your new repository and run `npm install`.
25
21
  3. Create a new feature branch from `master` branch, like `feature/my-cool-feature`.
26
22
  4. Start the Gulp watcher via `gulp watch` and start developing. Coding guidelines will be enforced by Gulp.
27
23
  5. If you are really nice you will supply a test for the stuff you coded.
28
- 5. Add a line to the `CHANGELOG.md` to tell people what you did in your feature.
29
- 6. Commit with a meaningful commit message (e.g. the line you put into `CHANGELOG.md`) & push to your repository.
30
- 7. Run `npm test`. Be sure that all tests pass before proceeding any further.
31
- 8. [Submit a pull request](https://help.github.com/articles/about-pull-requests/).
24
+ 6. Add a line to the `CHANGELOG.md` to tell people what you did in your feature.
25
+ 7. Commit with a meaningful commit message (e.g. the line you put into `CHANGELOG.md`) & push to your repository.
26
+ 8. Run `npm test`. Be sure that all tests pass before proceeding any further.
27
+ 9. [Submit a pull request](https://help.github.com/articles/about-pull-requests/).
32
28
 
33
29
  ### Emojis for `CHANGELOG.md`
34
30
 
35
- * :gift: `:gift:` New feature
36
- * :pill: `:pill:` Bugfix, repairing a broken functionality
37
- * :bomb: `:bomb:` Possibly breaking change, needs further explanation
38
- * :wrench: `:wrench:` Internal, technical improvement
31
+ - :gift: `:gift:` New feature
32
+ - :pill: `:pill:` Bugfix, repairing a broken functionality
33
+ - :bomb: `:bomb:` Possibly breaking change, needs further explanation
34
+ - :wrench: `:wrench:` Internal, technical improvement
package/README.md CHANGED
@@ -1,125 +1,138 @@
1
- ✈️ METAR parser
2
- ===============
1
+ # ✈️ METAR parser
3
2
 
4
- Parse METAR information into structured JavaScript object. The structure of the returned object is closely related to the [API response of CheckWX](https://api.checkwx.com/#metar-fields).
3
+ Parse METAR information into structured JavaScript object. The structure of the returned object is closely related to the [API response of CheckWX](https://www.checkwxapi.com/metar).
5
4
 
6
5
  Installation: `npm install aewx-metar-parser --save`
7
6
 
8
- Functionality
9
- -------------
7
+ ## Functionality
10
8
 
11
9
  This METAR parser returns the following parts of a METAR string:
12
10
 
13
- * ICAO code
14
- * Date / time
15
- * Wind speed (in kts, mps) & direction
16
- * Visibility (in meters and miles)
17
- * Weather phenomena
18
- * Clouds
19
- * Temperature (in °C & °F) & humidity
20
- * Barometer pressure (in InHg, kpa & mb)
11
+ - ICAO code
12
+ - Date / time
13
+ - Wind speed (in knots, meters per second) & direction
14
+ - Visibility (in meters and miles)
15
+ - Weather phenomena
16
+ - Clouds
17
+ - Temperature (in °C & °F) & humidity
18
+ - Barometer pressure (in InHg, kpa & mb)
21
19
 
22
- Code example
23
- ------------
20
+ ## Code example
24
21
 
25
22
  ```javascript
26
- 'use strict';
27
- const metarParser = require('aewx-metar-parser');
28
- const metarObject = metarParser('KSFO 070121Z 19023KT 1 1/2SM R28R/6000VP6000FT -RA BKN004 BKN013 OVC035 15/12 A2970 RMK AO2 T01500122 PNO $');
23
+ import { metarParser } from "./metar-parser.js";
29
24
 
25
+ const metarObject = metarParser(
26
+ "KSFO 070121Z 19023KT 1 1/2SM R28R/6000VP6000FT -RA BKN004 BKN013 OVC035 15/12 A2970 RMK AO2 T01500122 PNO $",
27
+ );
30
28
  ```
31
29
 
32
30
  …returns:
33
31
 
34
- ```javascript
32
+ ```json
35
33
  {
36
- raw_text: 'KSFO 070121Z 19023KT 1 1/2SM R28R/6000VP6000FT -RA BKN004 BKN013 OVC035 15/12 A2970 RMK AO2 T01500122 PNO $',
37
- raw_parts: [
38
- 'KSFO',
39
- '070121Z',
40
- '19023KT',
41
- '3/2SM',
42
- 'R28R/6000VP6000FT',
43
- '-RA',
44
- 'BKN004',
45
- 'BKN013',
46
- 'OVC035',
47
- '15/12',
48
- 'A2970',
49
- 'RMK',
50
- 'AO2',
51
- 'T01500122',
52
- 'PNO',
53
- '$'
34
+ "raw_text": "KSFO 070121Z 19023KT 1 1/2SM R28R/6000VP6000FT -RA BKN004 BKN013 OVC035 15/12 A2970 RMK AO2 T01500122 PNO $",
35
+ "raw_parts": [
36
+ "KSFO",
37
+ "070121Z",
38
+ "19023KT",
39
+ "3/2SM",
40
+ "R28R/6000VP6000FT",
41
+ "-RA",
42
+ "BKN004",
43
+ "BKN013",
44
+ "OVC035",
45
+ "15/12",
46
+ "A2970",
47
+ "RMK",
48
+ "AO2",
49
+ "T01500122",
50
+ "PNO",
51
+ "$"
54
52
  ],
55
- icao: 'KSFO',
56
- observed: Date('2019-01-07T01:21:03.232Z'),
57
- wind: {
58
- degrees: 190,
59
- speed_kts: 23,
60
- speed_mps: 11.832222176208026,
61
- gust_kts: 23,
62
- gust_mps: 11.832222176208026
53
+ "icao": "KSFO",
54
+ "observed": "2025-02-07T01:21:49.963Z",
55
+ "wind": {
56
+ "degrees": 190,
57
+ "speed_kts": 23,
58
+ "speed_mps": 11.832222176208026,
59
+ "gust_kts": null,
60
+ "gust_mps": null,
61
+ "degrees_from": null,
62
+ "degrees_to": null
63
63
  },
64
- visibility: {
65
- miles: "1.5",
66
- miles_float: 1.5,
67
- meters: "2500",
68
- meters_float: 2414.016
64
+ "visibility": {
65
+ "miles": 1.5,
66
+ "miles_text": "1.5",
67
+ "meters": 2414.016,
68
+ "meters_text": "2500"
69
69
  },
70
- conditions: [
71
- { code: '-'},
72
- { code: 'RA'}
70
+ "conditions": [
71
+ {
72
+ "code": "-"
73
+ },
74
+ {
75
+ "code": "RA"
76
+ }
73
77
  ],
74
- clouds: [
75
- { code: 'BKN', base_feet_agl: 400, base_meters_agl: 121.92 },
76
- { code: 'BKN', base_feet_agl: 1300, base_meters_agl: 396.24 },
77
- { code: 'OVC', base_feet_agl: 3500, base_meters_agl: 1066.8 }
78
+ "clouds": [
79
+ {
80
+ "code": "BKN",
81
+ "feet": 400,
82
+ "meters": 121.92
83
+ },
84
+ {
85
+ "code": "BKN",
86
+ "feet": 1300,
87
+ "meters": 396.24
88
+ },
89
+ {
90
+ "code": "OVC",
91
+ "feet": 3500,
92
+ "meters": 1066.8
93
+ }
78
94
  ],
79
- ceiling: {
80
- code: 'OVC',
81
- feet_agl: 3500,
82
- meters_agl: 1066.8
95
+ "ceiling": {
96
+ "feet": 400,
97
+ "meters": 121.92
98
+ },
99
+ "temperature": {
100
+ "celsius": 15,
101
+ "fahrenheit": 59
83
102
  },
84
- temperature: {
85
- celsius: 15,
86
- fahrenheit: 59
103
+ "dewpoint": {
104
+ "celsius": 12,
105
+ "fahrenheit": 53.6
87
106
  },
88
- dewpoint: {
89
- celsius: 12,
90
- fahrenheit: 53.6
107
+ "humidity": {
108
+ "percent": 82.26135295757305
91
109
  },
92
- humidity_percent: 82.26135295757305,
93
- barometer: {
94
- hg: 29.7,
95
- kpa: 100.57572661390854,
96
- mb: 1005.7572661390855
110
+ "barometer": {
111
+ "hg": 29.7,
112
+ "kpa": 100.57572661390854,
113
+ "mb": 1005.7572661390855
97
114
  },
98
- flight_category: 'VFR'
115
+ "flight_category": "LIFR",
116
+ "icao_flight_category": "IFR"
99
117
  }
100
118
  ```
101
119
 
102
-
103
-
104
- More information on METAR
105
- --------------------------
120
+ ## More information on METAR
106
121
 
107
122
  Wikipedia has an [article on METAR information](https://en.wikipedia.org/wiki/METAR) explaining the very basics.
108
123
 
109
124
  These sites make METAR information publicly available:
110
125
 
111
- * https://en.allmetsat.com/metar-taf/
112
- * https://aviationweather.gov/metar
113
- * https://metars.com/
126
+ - https://en.allmetsat.com/metar-taf/
127
+ - https://aviationweather.gov/metar
128
+ - https://metars.com/
114
129
 
115
- Status
116
- -------
130
+ ## Status
117
131
 
118
132
  [![npm version](https://badge.fury.io/js/aewx-metar-parser.svg)](https://badge.fury.io/js/aewx-metar-parser)
119
133
  [![devDependency Status](https://david-dm.org/fboes/metar-parser/dev-status.svg)](https://david-dm.org/fboes/metar-parser?type=dev)
120
134
 
121
- Legal stuff
122
- -----------
135
+ ## Legal stuff
123
136
 
124
137
  Author: [Frank Boës](https://3960.org)
125
138
 
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Convert units
3
+ */
4
+ export const convert = {
5
+ celsiusToFahrenheit: function (celsius) {
6
+ return celsius * 1.8 + 32;
7
+ },
8
+ feetToMeters: function (feet) {
9
+ return feet * 0.3048;
10
+ },
11
+ milesToMeters: function (miles) {
12
+ return miles * 1609.344;
13
+ },
14
+ metersToMiles: function (meters) {
15
+ return meters / 1609.344;
16
+ },
17
+ inhgToKpa: function (inHg) {
18
+ return inHg / 0.29529988;
19
+ },
20
+ kpaToInhg: function (kpa) {
21
+ return kpa * 0.29529988;
22
+ },
23
+ kphToMps: function (kph) {
24
+ return (kph / 3600) * 1000;
25
+ },
26
+ mpsToKts: function (mps) {
27
+ return mps * 1.9438445;
28
+ },
29
+ ktsToMps: function (kts) {
30
+ return kts / 1.9438445;
31
+ },
32
+ };
@@ -1,56 +1,44 @@
1
- 'use strict';
2
-
3
- const assert = require('assert');
4
-
5
- const convert = require('../lib/convert');
6
-
7
- describe('convert', function () {
8
- it('must convert celsius in fahrenheit', function () {
1
+ import { strict as assert } from "node:assert";
2
+ import { convert } from "./convert.js";
3
+ {
9
4
  const fahrenheit = convert.celsiusToFahrenheit(1);
10
5
  // console.log(fahrenheit);
11
6
  assert.ok(fahrenheit > 33.75);
12
7
  assert.ok(fahrenheit < 33.85);
13
- });
14
-
15
- it('must convert kpa in hgin', function () {
8
+ }
9
+ {
16
10
  const hgin = convert.kpaToInhg(1);
17
11
  // console.log(hgin);
18
12
  assert.ok(hgin > 0.29);
19
- assert.ok(hgin < 0.30);
20
- });
21
-
22
- it('must convert hgin in kpa', function () {
13
+ assert.ok(hgin < 0.3);
14
+ }
15
+ {
23
16
  const kpa = convert.inhgToKpa(1);
24
17
  // console.log(kpa);
25
18
  assert.ok(kpa > 3.38);
26
19
  assert.ok(kpa < 3.39);
27
- });
28
-
29
- it('must convert miles in meters', function () {
20
+ }
21
+ {
30
22
  const meters = convert.milesToMeters(1);
31
23
  // console.log(meters);
32
24
  assert.ok(meters > 1609);
33
25
  assert.ok(meters < 1610);
34
- });
35
-
36
- it('must convert km/h in m/s', function () {
26
+ }
27
+ {
37
28
  const mps = convert.kphToMps(1);
38
29
  // console.log(mps);
39
30
  assert.ok(mps > 0.277);
40
31
  assert.ok(mps < 0.278);
41
- });
42
-
43
- it('must convert m/s to kts', function () {
32
+ }
33
+ {
44
34
  const kts = convert.mpsToKts(1);
45
35
  // console.log(kts);
46
36
  assert.ok(kts > 1.94);
47
37
  assert.ok(kts < 1.95);
48
- });
49
-
50
- it('must convert kts to m/s', function () {
38
+ }
39
+ {
51
40
  const mps = convert.ktsToMps(1);
52
41
  // console.log(mps);
53
42
  assert.ok(mps > 0.51);
54
43
  assert.ok(mps < 0.52);
55
- });
56
- });
44
+ }