aewx-metar-parser 1.0.0 → 2.0.1
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 +4 -3
- package/.prettierignore +4 -0
- package/CHANGELOG.md +25 -15
- package/CONTRIBUTING.md +12 -16
- package/README.md +97 -84
- package/dist/convert.js +32 -0
- package/dist/convert.test.js +40 -0
- package/dist/metar-parser.js +269 -0
- package/dist/metar-parser.test.js +295 -0
- package/eslint.config.js +11 -0
- package/package.json +20 -11
- package/{test/convert.js → src/convert.test.ts} +12 -21
- package/src/convert.ts +40 -0
- package/src/metar-parser.test.ts +328 -0
- package/src/metar-parser.ts +359 -0
- package/tsconfig.json +19 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/types/convert.d.ts +15 -0
- package/types/convert.d.ts.map +1 -0
- package/types/convert.test.d.ts +2 -0
- package/types/convert.test.d.ts.map +1 -0
- package/types/metar-parser.d.ts +69 -0
- package/types/metar-parser.d.ts.map +1 -0
- package/types/metar-parser.test.d.ts +2 -0
- package/types/metar-parser.test.d.ts.map +1 -0
- package/.eslintrc.js +0 -26
- package/.husky/pre-commit +0 -4
- package/lib/convert.js +0 -44
- package/lib/metar-parser.js +0 -263
- package/test/metar-parser.js +0 -304
package/.editorconfig
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
#
|
|
1
|
+
# EditorConfig is awesome: http://EditorConfig.org
|
|
2
2
|
|
|
3
3
|
root = true
|
|
4
4
|
|
|
5
5
|
[*]
|
|
6
|
-
|
|
6
|
+
end_of_line = lf
|
|
7
7
|
insert_final_newline = true
|
|
8
8
|
trim_trailing_whitespace = true
|
|
9
|
-
|
|
9
|
+
charset = utf-8
|
|
10
10
|
indent_style = space
|
|
11
11
|
indent_size = 2
|
|
12
|
+
max_line_length = 120
|
package/.prettierignore
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -1,23 +1,33 @@
|
|
|
1
|
-
Change log
|
|
2
|
-
==========
|
|
1
|
+
# Change log
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## [Unreleased]
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
## [2.0.1]
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
- Changed testing to standard Node.js testing suite
|
|
8
|
+
- Fixed `types` in `package.json`
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
* 🎁 Add property `flight_category`
|
|
13
|
-
* 💊 If no visibility is given, assume 10 SM
|
|
10
|
+
## 2.0.0
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
- Changed to TypeScript
|
|
13
|
+
- Set `null` instead of `0` on missing information
|
|
14
|
+
- Fixed `ceiling` property
|
|
15
|
+
- Changed data structure to adhere to https://www.checkwxapi.com/metar
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
## 1.0.0
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
-----
|
|
19
|
+
- Fix METAR interpretation if wind is missing
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
## 0.10.0
|
|
22
|
+
|
|
23
|
+
- Changed object properties to closer match CheckWX properties. This changes `conditions`, `ceiling`, `visibility`
|
|
24
|
+
- Add property `flight_category`
|
|
25
|
+
- If no visibility is given, assume 10 SM
|
|
26
|
+
|
|
27
|
+
## 0.9.3
|
|
28
|
+
|
|
29
|
+
- Improve handling of `VRB`
|
|
30
|
+
|
|
31
|
+
## 0.9.0
|
|
32
|
+
|
|
33
|
+
- 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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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://
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
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
|
-
```
|
|
32
|
+
```json
|
|
35
33
|
{
|
|
36
|
-
raw_text:
|
|
37
|
-
raw_parts: [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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:
|
|
56
|
-
observed:
|
|
57
|
-
wind: {
|
|
58
|
-
degrees: 190,
|
|
59
|
-
speed_kts: 23,
|
|
60
|
-
speed_mps: 11.832222176208026,
|
|
61
|
-
gust_kts:
|
|
62
|
-
gust_mps:
|
|
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:
|
|
66
|
-
|
|
67
|
-
meters:
|
|
68
|
-
|
|
64
|
+
"visibility": {
|
|
65
|
+
"miles": 1.5,
|
|
66
|
+
"miles_text": "1.5",
|
|
67
|
+
"meters": 2414.016,
|
|
68
|
+
"meters_text": "2500"
|
|
69
69
|
},
|
|
70
|
-
conditions: [
|
|
71
|
-
{
|
|
72
|
-
|
|
70
|
+
"conditions": [
|
|
71
|
+
{
|
|
72
|
+
"code": "-"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"code": "RA"
|
|
76
|
+
}
|
|
73
77
|
],
|
|
74
|
-
clouds: [
|
|
75
|
-
{
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
95
|
+
"ceiling": {
|
|
96
|
+
"feet": 400,
|
|
97
|
+
"meters": 121.92
|
|
98
|
+
},
|
|
99
|
+
"temperature": {
|
|
100
|
+
"celsius": 15,
|
|
101
|
+
"fahrenheit": 59
|
|
83
102
|
},
|
|
84
|
-
|
|
85
|
-
celsius:
|
|
86
|
-
fahrenheit:
|
|
103
|
+
"dewpoint": {
|
|
104
|
+
"celsius": 12,
|
|
105
|
+
"fahrenheit": 53.6
|
|
87
106
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
fahrenheit: 53.6
|
|
107
|
+
"humidity": {
|
|
108
|
+
"percent": 82.26135295757305
|
|
91
109
|
},
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
mb: 1005.7572661390855
|
|
110
|
+
"barometer": {
|
|
111
|
+
"hg": 29.7,
|
|
112
|
+
"kpa": 100.57572661390854,
|
|
113
|
+
"mb": 1005.7572661390855
|
|
97
114
|
},
|
|
98
|
-
flight_category:
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
[](https://badge.fury.io/js/aewx-metar-parser)
|
|
119
133
|
[](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
|
|
package/dist/convert.js
ADDED
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { strict as assert } from "node:assert";
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import { convert } from "./convert.js";
|
|
4
|
+
describe("Conversion Tests", () => {
|
|
5
|
+
it("should convert temperature units correctly", () => {
|
|
6
|
+
const fahrenheit = convert.celsiusToFahrenheit(1);
|
|
7
|
+
assert.ok(fahrenheit > 33.75);
|
|
8
|
+
assert.ok(fahrenheit < 33.85);
|
|
9
|
+
});
|
|
10
|
+
it("should convert pressure units correctly", () => {
|
|
11
|
+
const hgin = convert.kpaToInhg(1);
|
|
12
|
+
assert.ok(hgin > 0.29);
|
|
13
|
+
assert.ok(hgin < 0.3);
|
|
14
|
+
});
|
|
15
|
+
it("should convert pressure units correctly", () => {
|
|
16
|
+
const kpa = convert.inhgToKpa(1);
|
|
17
|
+
assert.ok(kpa > 3.38);
|
|
18
|
+
assert.ok(kpa < 3.39);
|
|
19
|
+
});
|
|
20
|
+
it("should convert distance units correctly", () => {
|
|
21
|
+
const meters = convert.milesToMeters(1);
|
|
22
|
+
assert.ok(meters > 1609);
|
|
23
|
+
assert.ok(meters < 1610);
|
|
24
|
+
});
|
|
25
|
+
it("should convert speed units correctly", () => {
|
|
26
|
+
const mps = convert.kphToMps(1);
|
|
27
|
+
assert.ok(mps > 0.277);
|
|
28
|
+
assert.ok(mps < 0.278);
|
|
29
|
+
});
|
|
30
|
+
it("should convert nautical speed units correctly", () => {
|
|
31
|
+
const kts = convert.mpsToKts(1);
|
|
32
|
+
assert.ok(kts > 1.94);
|
|
33
|
+
assert.ok(kts < 1.95);
|
|
34
|
+
});
|
|
35
|
+
it("should convert back nautical speed units correctly", () => {
|
|
36
|
+
const mps = convert.ktsToMps(1);
|
|
37
|
+
assert.ok(mps > 0.51);
|
|
38
|
+
assert.ok(mps < 0.52);
|
|
39
|
+
});
|
|
40
|
+
});
|