aewx-metar-parser 0.10.1 → 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 +4 -3
- package/.prettierignore +4 -0
- package/CHANGELOG.md +18 -15
- package/CONTRIBUTING.md +12 -21
- package/README.md +98 -86
- package/dist/convert.js +32 -0
- package/dist/convert.test.js +44 -0
- package/dist/metar-parser.js +269 -0
- package/dist/metar-parser.test.js +311 -0
- package/eslint.config.js +11 -0
- package/package.json +17 -17
- package/src/convert.test.ts +53 -0
- package/src/convert.ts +40 -0
- package/src/metar-parser.test.ts +349 -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.yaml +0 -61
- package/.travis.yml +0 -9
- package/gulpfile.js +0 -62
- package/lib/convert.js +0 -44
- package/lib/metar-parser.js +0 -259
- package/test/convert.js +0 -57
- package/test/metar-parser.js +0 -292
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,26 @@
|
|
|
1
|
-
Change log
|
|
2
|
-
==========
|
|
1
|
+
# Change log
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## 2.0.0
|
|
5
4
|
|
|
6
|
-
|
|
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.
|
|
9
|
-
------
|
|
10
|
+
## 1.0.0
|
|
10
11
|
|
|
11
|
-
|
|
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.
|
|
16
|
-
-----
|
|
14
|
+
## 0.10.0
|
|
17
15
|
|
|
18
|
-
|
|
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.
|
|
21
|
-
-----
|
|
20
|
+
## 0.9.3
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
- Improve handling of `VRB`
|
|
23
|
+
|
|
24
|
+
## 0.9.0
|
|
25
|
+
|
|
26
|
+
- Initial commit
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,43 +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
|
-
3. [Gulp](https://gulpjs.com/) installed globally
|
|
20
|
-
4. [ESLint](https://eslint.org/) installed globally
|
|
21
|
-
5. [Nodeunit](https://github.com/caolan/nodeunit) installed globally
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Making changes
|
|
26
|
-
--------------
|
|
17
|
+
## Making changes
|
|
27
18
|
|
|
28
19
|
1. [Fork the repository on GitHub](https://help.github.com/articles/fork-a-repo/)
|
|
29
20
|
2. Checkout your new repository and run `npm install`.
|
|
30
21
|
3. Create a new feature branch from `master` branch, like `feature/my-cool-feature`.
|
|
31
22
|
4. Start the Gulp watcher via `gulp watch` and start developing. Coding guidelines will be enforced by Gulp.
|
|
32
23
|
5. If you are really nice you will supply a test for the stuff you coded.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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/).
|
|
37
28
|
|
|
38
29
|
### Emojis for `CHANGELOG.md`
|
|
39
30
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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,127 +1,139 @@
|
|
|
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
|
-
[](https://travis-ci.org/fboes/metar-parser)
|
|
120
133
|
[](https://david-dm.org/fboes/metar-parser?type=dev)
|
|
121
134
|
|
|
122
|
-
Legal stuff
|
|
123
|
-
-----------
|
|
135
|
+
## Legal stuff
|
|
124
136
|
|
|
125
|
-
Author: [Frank Boës](
|
|
137
|
+
Author: [Frank Boës](https://3960.org)
|
|
126
138
|
|
|
127
139
|
Copyright & license: See [LICENSE.txt](LICENSE.txt)
|
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,44 @@
|
|
|
1
|
+
import { strict as assert } from "node:assert";
|
|
2
|
+
import { convert } from "./convert.js";
|
|
3
|
+
{
|
|
4
|
+
const fahrenheit = convert.celsiusToFahrenheit(1);
|
|
5
|
+
// console.log(fahrenheit);
|
|
6
|
+
assert.ok(fahrenheit > 33.75);
|
|
7
|
+
assert.ok(fahrenheit < 33.85);
|
|
8
|
+
}
|
|
9
|
+
{
|
|
10
|
+
const hgin = convert.kpaToInhg(1);
|
|
11
|
+
// console.log(hgin);
|
|
12
|
+
assert.ok(hgin > 0.29);
|
|
13
|
+
assert.ok(hgin < 0.3);
|
|
14
|
+
}
|
|
15
|
+
{
|
|
16
|
+
const kpa = convert.inhgToKpa(1);
|
|
17
|
+
// console.log(kpa);
|
|
18
|
+
assert.ok(kpa > 3.38);
|
|
19
|
+
assert.ok(kpa < 3.39);
|
|
20
|
+
}
|
|
21
|
+
{
|
|
22
|
+
const meters = convert.milesToMeters(1);
|
|
23
|
+
// console.log(meters);
|
|
24
|
+
assert.ok(meters > 1609);
|
|
25
|
+
assert.ok(meters < 1610);
|
|
26
|
+
}
|
|
27
|
+
{
|
|
28
|
+
const mps = convert.kphToMps(1);
|
|
29
|
+
// console.log(mps);
|
|
30
|
+
assert.ok(mps > 0.277);
|
|
31
|
+
assert.ok(mps < 0.278);
|
|
32
|
+
}
|
|
33
|
+
{
|
|
34
|
+
const kts = convert.mpsToKts(1);
|
|
35
|
+
// console.log(kts);
|
|
36
|
+
assert.ok(kts > 1.94);
|
|
37
|
+
assert.ok(kts < 1.95);
|
|
38
|
+
}
|
|
39
|
+
{
|
|
40
|
+
const mps = convert.ktsToMps(1);
|
|
41
|
+
// console.log(mps);
|
|
42
|
+
assert.ok(mps > 0.51);
|
|
43
|
+
assert.ok(mps < 0.52);
|
|
44
|
+
}
|