aewx-metar-parser 4.0.0 → 4.1.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/CHANGELOG.md +7 -1
- package/README.md +3 -3
- package/dist/metar-parser-helpers.js +25 -6
- package/dist/metar-parser.js +45 -55
- package/dist/metar-parser.test.js +29 -19
- package/docs/KEYW.json +57 -0
- package/docs/KFSO.json +87 -0
- package/package.json +1 -1
- package/src/metar-parser-helpers.ts +33 -7
- package/src/metar-parser.test.ts +32 -19
- package/src/metar-parser.ts +66 -64
- package/src/metar-parser.type.ts +9 -9
- package/types/metar-parser-helpers.d.ts +8 -2
- package/types/metar-parser-helpers.d.ts.map +1 -1
- package/types/metar-parser.d.ts.map +1 -1
- package/types/metar-parser.type.d.ts +9 -9
- package/types/metar-parser.type.d.ts.map +1 -1
- package/tsconfig.tsbuildinfo +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleaed]
|
|
4
4
|
|
|
5
|
-
## [4.
|
|
5
|
+
## [4.1.0] - 2026-11-24
|
|
6
|
+
|
|
7
|
+
- Humidity may not be provided, returning `null`
|
|
8
|
+
- Pressure may not be provided, returning `null`
|
|
9
|
+
- Fixed date parser
|
|
10
|
+
|
|
11
|
+
## [4.0.0] - 2026-11-23
|
|
6
12
|
|
|
7
13
|
- Updated ESLint
|
|
8
14
|
- Visbility may not be provided, returning `null`
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ This METAR parser returns the following parts of a METAR string:
|
|
|
19
19
|
|
|
20
20
|
It also provides TypeScript type definitions.
|
|
21
21
|
|
|
22
|
-
Please be aware that some values may
|
|
22
|
+
Please be aware that some values may become `null`, caused by missing information in the original METAR information. This behavior is intentional and needs to be handled by your implementation.
|
|
23
23
|
|
|
24
24
|
## Code example
|
|
25
25
|
|
|
@@ -133,8 +133,8 @@ These sites make METAR information publicly available:
|
|
|
133
133
|
|
|
134
134
|
## Status
|
|
135
135
|
|
|
136
|
-
[](https://www.npmjs.com/package/aewx-metar-parser)
|
|
137
|
+

|
|
138
138
|
|
|
139
139
|
## Legal stuff
|
|
140
140
|
|
|
@@ -36,13 +36,14 @@ export function metarTemperature(temperatureString) {
|
|
|
36
36
|
/**
|
|
37
37
|
* @see http://andrew.rsmas.miami.edu/bmcnoldy/Humidity.html
|
|
38
38
|
*/
|
|
39
|
-
export function
|
|
39
|
+
export function relativeHumidity(temp, dew) {
|
|
40
40
|
if (dew === null || temp === null) {
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
const percent = (Math.exp((17.625 * dew.celsius) / (243.04 + dew.celsius)) /
|
|
44
44
|
Math.exp((17.625 * temp.celsius) / (243.04 + temp.celsius))) *
|
|
45
|
-
100
|
|
45
|
+
100;
|
|
46
|
+
return { percent };
|
|
46
47
|
}
|
|
47
48
|
export function flightCategoryUs(visibility, ceiling) {
|
|
48
49
|
if (visibility === null) {
|
|
@@ -66,14 +67,19 @@ export function flightCategoryIcao(visibility, ceiling) {
|
|
|
66
67
|
return visibility.meters >= 5000 && (ceiling === null || ceiling.feet >= 1500) ? "VFR" : "IFR";
|
|
67
68
|
}
|
|
68
69
|
/**
|
|
69
|
-
* @returns the lowest cloud layer reporting `BKN` or `
|
|
70
|
-
* not such cloud layer was found.
|
|
70
|
+
* @returns the lowest cloud layer reporting `BKN`, `OVC` or `VV`,
|
|
71
|
+
* or undefined if not such cloud layer was found.
|
|
71
72
|
*/
|
|
72
73
|
function findCeiling(clouds) {
|
|
73
74
|
return clouds.find((c) => {
|
|
74
|
-
return c.code === "BKN" || c.code === "OVC";
|
|
75
|
+
return c.code === "BKN" || c.code === "OVC" || c.code === "VV";
|
|
75
76
|
});
|
|
76
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* @see findCeiling
|
|
80
|
+
* @returns the ceiling by looking for the lowest cloud layer reporting `BKN`
|
|
81
|
+
* or `OVC`.
|
|
82
|
+
*/
|
|
77
83
|
export function metarCeiling(clouds) {
|
|
78
84
|
const ceilingCloud = findCeiling(clouds);
|
|
79
85
|
if (!ceilingCloud) {
|
|
@@ -98,3 +104,16 @@ export function metarSplit(metarString) {
|
|
|
98
104
|
.replace(/\n/, " \\n ")
|
|
99
105
|
.split(/\s+/);
|
|
100
106
|
}
|
|
107
|
+
export function date(date, hours, minutes) {
|
|
108
|
+
const now = new Date();
|
|
109
|
+
const d = new Date(0);
|
|
110
|
+
d.setUTCDate(date);
|
|
111
|
+
d.setUTCMonth(now.getUTCMonth());
|
|
112
|
+
d.setUTCFullYear(now.getUTCFullYear());
|
|
113
|
+
d.setUTCHours(hours);
|
|
114
|
+
d.setUTCMinutes(minutes);
|
|
115
|
+
if (d.getTime() > now.getTime()) {
|
|
116
|
+
d.setUTCMonth(d.getUTCMonth() - 1);
|
|
117
|
+
}
|
|
118
|
+
return d;
|
|
119
|
+
}
|
package/dist/metar-parser.js
CHANGED
|
@@ -13,7 +13,6 @@ export const metarParser = (metarString) => {
|
|
|
13
13
|
let mode = 0;
|
|
14
14
|
let isTAF = false;
|
|
15
15
|
metarObject.raw_parts.forEach((metarPart) => {
|
|
16
|
-
let match;
|
|
17
16
|
if (mode === 0 && metarPart.match(/^(METAR|TAF)$/)) {
|
|
18
17
|
isTAF = metarPart === "TAF";
|
|
19
18
|
return;
|
|
@@ -36,44 +35,25 @@ export const metarParser = (metarString) => {
|
|
|
36
35
|
mode = 1;
|
|
37
36
|
break;
|
|
38
37
|
case 1:
|
|
39
|
-
|
|
40
|
-
match = metarPart.match(/^(\d\d)(\d\d)(\d\d)Z$/);
|
|
41
|
-
if (match) {
|
|
42
|
-
metarObject.observed = new Date();
|
|
43
|
-
metarObject.observed.setUTCDate(Number(match[1]));
|
|
44
|
-
metarObject.observed.setUTCHours(Number(match[2]));
|
|
45
|
-
metarObject.observed.setUTCMinutes(Number(match[3]));
|
|
46
|
-
mode = 2;
|
|
47
|
-
}
|
|
38
|
+
mode = parseObservedDate(metarPart, metarObject, mode);
|
|
48
39
|
break;
|
|
49
40
|
case 2:
|
|
50
41
|
mode = parseWind(metarPart, metarObject, mode);
|
|
51
42
|
if (mode === 2) {
|
|
52
43
|
parseForecastDate(metarPart, metarObject);
|
|
44
|
+
// stays in mode
|
|
53
45
|
}
|
|
54
46
|
break;
|
|
55
47
|
case 3:
|
|
56
48
|
mode = parseVisibility(metarPart, metarObject, mode);
|
|
57
49
|
if (mode === 3) {
|
|
58
50
|
parseVariableWind(metarPart, metarObject);
|
|
51
|
+
// stays in mode
|
|
59
52
|
}
|
|
60
53
|
break;
|
|
61
54
|
case 4:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (match) {
|
|
65
|
-
if (!metarObject.conditions) {
|
|
66
|
-
metarObject.conditions = [];
|
|
67
|
-
}
|
|
68
|
-
match
|
|
69
|
-
.filter((m, index) => {
|
|
70
|
-
return index !== 0 && m;
|
|
71
|
-
})
|
|
72
|
-
.forEach((m) => {
|
|
73
|
-
metarObject.conditions.push({ code: m });
|
|
74
|
-
});
|
|
75
|
-
// may occur multiple times
|
|
76
|
-
}
|
|
55
|
+
parseCondition(metarPart, metarObject);
|
|
56
|
+
// may occur multiple times
|
|
77
57
|
break;
|
|
78
58
|
case 5:
|
|
79
59
|
parseClouds(metarPart, metarObject);
|
|
@@ -93,6 +73,14 @@ export const metarParser = (metarString) => {
|
|
|
93
73
|
return metarObject;
|
|
94
74
|
};
|
|
95
75
|
// -----------------------------------------------------------------------------
|
|
76
|
+
function parseObservedDate(metarPart, metarObject, mode) {
|
|
77
|
+
const match = metarPart.match(/^(\d\d)(\d\d)(\d\d)Z$/);
|
|
78
|
+
if (!match) {
|
|
79
|
+
return mode;
|
|
80
|
+
}
|
|
81
|
+
metarObject.observed = MetarParserHelpers.date(Number(match[1]), Number(match[2]), Number(match[3]));
|
|
82
|
+
return 2;
|
|
83
|
+
}
|
|
96
84
|
function parseWind(metarPart, metarObject, mode) {
|
|
97
85
|
// Case: Unkonw wind
|
|
98
86
|
if (metarPart.match(/^\/+(KT|MPS|KPH)$/)) {
|
|
@@ -126,18 +114,12 @@ function parseWind(metarPart, metarObject, mode) {
|
|
|
126
114
|
return 3;
|
|
127
115
|
}
|
|
128
116
|
function parseForecastDate(metarPart, metarObject) {
|
|
129
|
-
const
|
|
130
|
-
if (!
|
|
117
|
+
const [, fromDate, fromHours, toDate, toHours] = metarPart.match(/^(\d\d)(\d\d)\/(\d\d)(\d\d)$/) || [];
|
|
118
|
+
if (!fromDate) {
|
|
131
119
|
return;
|
|
132
120
|
}
|
|
133
|
-
metarObject.forecastFrom =
|
|
134
|
-
metarObject.
|
|
135
|
-
metarObject.forecastFrom.setUTCHours(Number(match[2]));
|
|
136
|
-
metarObject.forecastFrom.setUTCMinutes(0);
|
|
137
|
-
metarObject.forecastTo = new Date();
|
|
138
|
-
metarObject.forecastTo.setUTCDate(Number(match[3]));
|
|
139
|
-
metarObject.forecastTo.setUTCHours(Number(match[4]));
|
|
140
|
-
metarObject.forecastTo.setUTCMinutes(0);
|
|
121
|
+
metarObject.forecastFrom = MetarParserHelpers.date(Number(fromDate), Number(fromHours), 0);
|
|
122
|
+
metarObject.forecastTo = MetarParserHelpers.date(Number(toDate), Number(toHours), 0);
|
|
141
123
|
}
|
|
142
124
|
function parseVisibility(metarPart, metarObject, mode) {
|
|
143
125
|
// Case: No clouds & conditions reported
|
|
@@ -162,10 +144,25 @@ function parseVariableWind(metarPart, metarObject) {
|
|
|
162
144
|
if (!metarObject.wind) {
|
|
163
145
|
return;
|
|
164
146
|
}
|
|
165
|
-
const
|
|
147
|
+
const [, degreesFrom, degreesTo] = metarPart.match(/^(\d+)V(\d+)$/) || [];
|
|
148
|
+
if (degreesFrom || degreesTo) {
|
|
149
|
+
metarObject.wind.degrees_from = Number(degreesFrom);
|
|
150
|
+
metarObject.wind.degrees_to = Number(degreesTo);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function parseCondition(metarPart, metarObject) {
|
|
154
|
+
const match = metarPart.match(/^(\+|-|VC|RE)?([A-Z][A-Z])([A-Z][A-Z])?([A-Z][A-Z])?$/);
|
|
166
155
|
if (match) {
|
|
167
|
-
metarObject.
|
|
168
|
-
|
|
156
|
+
if (!metarObject.conditions) {
|
|
157
|
+
metarObject.conditions = [];
|
|
158
|
+
}
|
|
159
|
+
match
|
|
160
|
+
.filter((m, index) => {
|
|
161
|
+
return index !== 0 && m;
|
|
162
|
+
})
|
|
163
|
+
.forEach((m) => {
|
|
164
|
+
metarObject.conditions.push({ code: m });
|
|
165
|
+
});
|
|
169
166
|
}
|
|
170
167
|
}
|
|
171
168
|
function parseClouds(metarPart, metarObject) {
|
|
@@ -179,22 +176,21 @@ function parseTemperature(metarPart, metarObject, mode) {
|
|
|
179
176
|
if (temp) {
|
|
180
177
|
metarObject.temperature = MetarParserHelpers.metarTemperature(temp ?? "//");
|
|
181
178
|
metarObject.dewpoint = MetarParserHelpers.metarTemperature(dewpoint ?? "//");
|
|
182
|
-
metarObject.humidity
|
|
179
|
+
metarObject.humidity = MetarParserHelpers.relativeHumidity(metarObject.temperature, metarObject.dewpoint);
|
|
183
180
|
return 7;
|
|
184
181
|
}
|
|
185
182
|
return mode;
|
|
186
183
|
}
|
|
187
184
|
function parsePressure(metarPart, metarObject, mode) {
|
|
188
|
-
const
|
|
189
|
-
if (!
|
|
185
|
+
const [, unit, value] = metarPart.match(/^(Q|A)(\d+)/) || [];
|
|
186
|
+
if (!unit || !value) {
|
|
190
187
|
return mode;
|
|
191
188
|
}
|
|
192
|
-
|
|
193
|
-
hg /= match[1] === "Q" ? 10 : 100;
|
|
189
|
+
const hg = Number(value) / (unit === "Q" ? 10 : 100);
|
|
194
190
|
metarObject.barometer = {
|
|
195
|
-
hg:
|
|
196
|
-
kpa:
|
|
197
|
-
mb:
|
|
191
|
+
hg: unit === "Q" ? convert.kpaToInhg(hg) : hg,
|
|
192
|
+
kpa: unit === "Q" ? hg : convert.inhgToKpa(hg),
|
|
193
|
+
mb: unit === "Q" ? hg * 10 : convert.inhgToKpa(hg * 10),
|
|
198
194
|
};
|
|
199
195
|
return 8;
|
|
200
196
|
}
|
|
@@ -204,7 +200,7 @@ function initializeMetarObject(metarString) {
|
|
|
204
200
|
raw_text: metarString,
|
|
205
201
|
raw_parts: MetarParserHelpers.metarSplit(metarString),
|
|
206
202
|
icao: "",
|
|
207
|
-
observed: new Date(),
|
|
203
|
+
observed: new Date(0),
|
|
208
204
|
forecastFrom: null,
|
|
209
205
|
forecastTo: null,
|
|
210
206
|
wind: {
|
|
@@ -222,14 +218,8 @@ function initializeMetarObject(metarString) {
|
|
|
222
218
|
ceiling: null,
|
|
223
219
|
temperature: null,
|
|
224
220
|
dewpoint: null,
|
|
225
|
-
humidity:
|
|
226
|
-
|
|
227
|
-
},
|
|
228
|
-
barometer: {
|
|
229
|
-
hg: null,
|
|
230
|
-
kpa: null,
|
|
231
|
-
mb: null,
|
|
232
|
-
},
|
|
221
|
+
humidity: null,
|
|
222
|
+
barometer: null,
|
|
233
223
|
flight_category: null,
|
|
234
224
|
icao_flight_category: null,
|
|
235
225
|
};
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { strict as assert } from "node:assert/strict";
|
|
2
2
|
import { describe, it } from "node:test";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
3
5
|
import { metarParser } from "./metar-parser.js";
|
|
4
6
|
import * as convert from "./convert.js";
|
|
7
|
+
function writeArtifact(filename, result) {
|
|
8
|
+
if (!process.env.WRITE_ARTIFACTS) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
fs.writeFileSync(path.join(import.meta.dirname, "..", "docs", filename), JSON.stringify(result, null, 2), "utf-8");
|
|
12
|
+
}
|
|
5
13
|
describe("METAR Parsing Tests", () => {
|
|
6
14
|
it("KEYW 041053Z AUTO 13005KT 10SM CLR 24/22 A3000 RMK AO2 SLP159 T02440222", (c) => {
|
|
7
15
|
// https://aviationweather.gov/metar#1
|
|
@@ -12,8 +20,9 @@ describe("METAR Parsing Tests", () => {
|
|
|
12
20
|
assert.deepStrictEqual(result.wind.speed_kts, 5);
|
|
13
21
|
assert.deepStrictEqual(result.wind.gust_kts, null);
|
|
14
22
|
assert.deepStrictEqual(result.visibility?.meters_text, "16000");
|
|
15
|
-
assert.deepStrictEqual(result.barometer
|
|
23
|
+
assert.deepStrictEqual(result.barometer?.kpa, 3000 / 10 / 2.9529988);
|
|
16
24
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
25
|
+
writeArtifact("KEYW.json", result);
|
|
17
26
|
});
|
|
18
27
|
it("KACV 041053Z AUTO 07003KT 10SM CLR 04/04 A3001 RMK AO2 SLP169 T00440039", (c) => {
|
|
19
28
|
// https://aviationweather.gov/metar#2
|
|
@@ -35,8 +44,8 @@ describe("METAR Parsing Tests", () => {
|
|
|
35
44
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 39.2);
|
|
36
45
|
assert.deepStrictEqual(result.dewpoint?.celsius, 4);
|
|
37
46
|
assert.deepStrictEqual(result.dewpoint?.fahrenheit, 39.2);
|
|
38
|
-
assert.deepStrictEqual(result.humidity
|
|
39
|
-
assert.deepStrictEqual(result.barometer
|
|
47
|
+
assert.deepStrictEqual(result.humidity?.percent, 100);
|
|
48
|
+
assert.deepStrictEqual(result.barometer?.hg, 30.01);
|
|
40
49
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
41
50
|
assert.deepStrictEqual(result.icao_flight_category, "VFR");
|
|
42
51
|
});
|
|
@@ -55,7 +64,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
55
64
|
assert.deepStrictEqual(result.visibility?.miles_text, "10", "result.visibility?.miles");
|
|
56
65
|
assert.deepStrictEqual(result.temperature?.celsius, 17);
|
|
57
66
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 62.6);
|
|
58
|
-
assert.deepStrictEqual(result.barometer
|
|
67
|
+
assert.deepStrictEqual(result.barometer?.hg, 29.98);
|
|
59
68
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
60
69
|
});
|
|
61
70
|
it("KSPG 260853Z AUTO 05012KT 10SM CLR 18/09 A2997 RMK AO2 SLP148 T01830094 53001", (c) => {
|
|
@@ -70,7 +79,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
70
79
|
assert.deepStrictEqual(result.visibility?.miles_text, "10");
|
|
71
80
|
assert.deepStrictEqual(result.temperature?.celsius, 18);
|
|
72
81
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 64.4);
|
|
73
|
-
assert.deepStrictEqual(result.barometer
|
|
82
|
+
assert.deepStrictEqual(result.barometer?.kpa, 2997 / 10 / 2.9529988);
|
|
74
83
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
75
84
|
});
|
|
76
85
|
it("EDDS 081620Z 29010KT 9999 FEW040TCU 09/M03 Q1012 NOSIG", (c) => {
|
|
@@ -91,7 +100,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
91
100
|
assert.deepStrictEqual(result.ceiling?.feet, undefined);
|
|
92
101
|
assert.deepStrictEqual(result.temperature?.celsius, 9);
|
|
93
102
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 48.2);
|
|
94
|
-
assert.deepStrictEqual(result.barometer
|
|
103
|
+
assert.deepStrictEqual(result.barometer?.kpa, 101.2);
|
|
95
104
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
96
105
|
});
|
|
97
106
|
it("METAR LBBG 041600Z 12012MPS 090V150 1400 R04/P1500N R22/P1500U +SN BKN022 OVC050 M04/M07 Q1020 NOSIG 8849//91=", (c) => {
|
|
@@ -116,7 +125,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
116
125
|
assert.deepStrictEqual(result.clouds[0]?.meters, result.ceiling?.meters);
|
|
117
126
|
assert.deepStrictEqual(result.temperature?.celsius, -4);
|
|
118
127
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 24.8);
|
|
119
|
-
assert.deepStrictEqual(result.barometer
|
|
128
|
+
assert.deepStrictEqual(result.barometer?.kpa, 102.0);
|
|
120
129
|
assert.deepStrictEqual(result.flight_category, "LIFR");
|
|
121
130
|
assert.deepStrictEqual(result.icao_flight_category, "IFR");
|
|
122
131
|
});
|
|
@@ -140,7 +149,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
140
149
|
// ],
|
|
141
150
|
assert.deepStrictEqual(result.temperature?.celsius, -2);
|
|
142
151
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 28.4);
|
|
143
|
-
assert.deepStrictEqual(result.barometer
|
|
152
|
+
assert.deepStrictEqual(result.barometer?.hg, 30.06);
|
|
144
153
|
assert.deepStrictEqual(result.flight_category, "LIFR");
|
|
145
154
|
});
|
|
146
155
|
it("KEYW 041053Z AUTO 13005KT 10SM CLR 24/22 A3000 RMK AO2 SLP159 T02440222", (c) => {
|
|
@@ -154,7 +163,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
154
163
|
assert.deepStrictEqual(result.visibility?.meters_text, "16000");
|
|
155
164
|
assert.deepStrictEqual(result.visibility?.miles_text, "10");
|
|
156
165
|
assert.deepStrictEqual(result.temperature?.celsius, 24);
|
|
157
|
-
assert.deepStrictEqual(result.barometer
|
|
166
|
+
assert.deepStrictEqual(result.barometer?.kpa, 3000 / 10 / 2.9529988);
|
|
158
167
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
159
168
|
});
|
|
160
169
|
it("EDDH 041050Z 29013KT 6000 SCT006 BKN009 04/03 Q1028 TEMPO BKN012", (c) => {
|
|
@@ -176,7 +185,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
176
185
|
// ],
|
|
177
186
|
assert.deepStrictEqual(result.temperature?.celsius, 4);
|
|
178
187
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 39.2);
|
|
179
|
-
assert.deepStrictEqual(result.barometer
|
|
188
|
+
assert.deepStrictEqual(result.barometer?.kpa, 102.8);
|
|
180
189
|
assert.deepStrictEqual(result.flight_category, "IFR");
|
|
181
190
|
assert.deepStrictEqual(result.icao_flight_category, "IFR");
|
|
182
191
|
});
|
|
@@ -193,7 +202,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
193
202
|
// ["clouds", [{ base_feet_agl: 9000, code: "SCT" }]],
|
|
194
203
|
assert.deepStrictEqual(result.temperature?.celsius, 0);
|
|
195
204
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 32);
|
|
196
|
-
assert.deepStrictEqual(result.barometer
|
|
205
|
+
assert.deepStrictEqual(result.barometer?.kpa, 3052 / 10 / 2.9529988);
|
|
197
206
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
198
207
|
});
|
|
199
208
|
it("KEYW 050653Z AUTO 19006KT FEW024 BKN039 26/23 A3000 RMK AO2 LTG DSNT W SLP159 T02610228", (c) => {
|
|
@@ -212,7 +221,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
212
221
|
// ],
|
|
213
222
|
// ],
|
|
214
223
|
assert.deepStrictEqual(result.temperature?.celsius, 26);
|
|
215
|
-
assert.deepStrictEqual(result.barometer
|
|
224
|
+
assert.deepStrictEqual(result.barometer?.kpa, 3000 / 10 / 2.9529988);
|
|
216
225
|
assert.deepStrictEqual(result.flight_category, null, "No visibility was given, so no fight category can be determined");
|
|
217
226
|
});
|
|
218
227
|
it("KSFO 070121Z 19023KT 1 1/2SM R28R/6000VP6000FT -RA BKN004 BKN013 OVC035 15/12 A2970 RMK AO2 T01500122 PNO $", (c) => {
|
|
@@ -226,9 +235,10 @@ describe("METAR Parsing Tests", () => {
|
|
|
226
235
|
assert.deepStrictEqual(result.temperature?.celsius, 15);
|
|
227
236
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 59);
|
|
228
237
|
// ["dewpoint", { celsius: 12assert.deepStrictEqual(result.temperature?.fahrenheit, 53.6 ],
|
|
229
|
-
assert.deepStrictEqual(result.barometer
|
|
230
|
-
assert.deepStrictEqual(result.barometer
|
|
238
|
+
assert.deepStrictEqual(result.barometer?.kpa, 2970 / 10 / 2.9529988);
|
|
239
|
+
assert.deepStrictEqual(result.barometer?.mb, 2970 / 2.9529988);
|
|
231
240
|
assert.deepStrictEqual(result.flight_category, "LIFR");
|
|
241
|
+
writeArtifact("KFSO.json", result);
|
|
232
242
|
});
|
|
233
243
|
it("EHAM 100125Z 33004KT CAVOK M00/M01 Q1026 NOSIG", (c) => {
|
|
234
244
|
// EHAM with CAVOK
|
|
@@ -241,7 +251,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
241
251
|
assert.deepStrictEqual(result.temperature?.celsius, -0);
|
|
242
252
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 32);
|
|
243
253
|
// ["dewpoint", { celsius: -1assert.deepStrictEqual(result.temperature?.fahrenheit, 30.2 ],
|
|
244
|
-
assert.deepStrictEqual(result.barometer
|
|
254
|
+
assert.deepStrictEqual(result.barometer?.kpa, 102.6);
|
|
245
255
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
246
256
|
});
|
|
247
257
|
it("KEYW 291553Z VRB03KT CLR 17/09 A3009 RMK AO2 SLP189 T01670089 $", (c) => {
|
|
@@ -276,14 +286,14 @@ describe("METAR Parsing Tests", () => {
|
|
|
276
286
|
assert.deepStrictEqual(result.clouds.length, 0);
|
|
277
287
|
assert.deepStrictEqual(result.temperature?.celsius, undefined);
|
|
278
288
|
assert.deepStrictEqual(result.dewpoint?.celsius, undefined);
|
|
279
|
-
assert.deepStrictEqual(result.humidity
|
|
280
|
-
assert.deepStrictEqual(result.barometer
|
|
289
|
+
assert.deepStrictEqual(result.humidity?.percent, undefined);
|
|
290
|
+
assert.deepStrictEqual(result.barometer?.mb, 1017);
|
|
281
291
|
});
|
|
282
292
|
it("LFMK 211130Z AUTO 29005KT 260V320 9999 OVC034 24/20 Q1011=", (c) => {
|
|
283
293
|
const metar = c.name;
|
|
284
294
|
const result = metarParser(metar);
|
|
285
295
|
assert.deepStrictEqual(result.icao, "LFMK");
|
|
286
|
-
assert.deepStrictEqual(result.barometer
|
|
296
|
+
assert.deepStrictEqual(result.barometer?.mb, 1011);
|
|
287
297
|
assert.deepStrictEqual(result.wind.degrees_from, 260);
|
|
288
298
|
assert.deepStrictEqual(result.wind.degrees_to, 320);
|
|
289
299
|
});
|
|
@@ -412,7 +422,7 @@ TEMPO 1916/1918 1200 +DZ BKN001`, (c) => {
|
|
|
412
422
|
assert.strictEqual(metar.visibility?.miles, t.visibilitySm);
|
|
413
423
|
assert.strictEqual(metar.ceiling?.feet, t.ceilingFeet);
|
|
414
424
|
assert.strictEqual(metar.temperature?.celsius, t.temperatureCelsius);
|
|
415
|
-
assert.strictEqual(metar.barometer
|
|
425
|
+
assert.strictEqual(metar.barometer?.mb, t.barometerMb);
|
|
416
426
|
assert.strictEqual(metar.flight_category, t.flight_category);
|
|
417
427
|
});
|
|
418
428
|
});
|
package/docs/KEYW.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"raw_text": "KEYW 041053Z AUTO 13005KT 10SM CLR 24/22 A3000 RMK AO2 SLP159 T02440222",
|
|
3
|
+
"raw_parts": [
|
|
4
|
+
"KEYW",
|
|
5
|
+
"041053Z",
|
|
6
|
+
"AUTO",
|
|
7
|
+
"13005KT",
|
|
8
|
+
"10SM",
|
|
9
|
+
"CLR",
|
|
10
|
+
"24/22",
|
|
11
|
+
"A3000",
|
|
12
|
+
"RMK",
|
|
13
|
+
"AO2",
|
|
14
|
+
"SLP159",
|
|
15
|
+
"T02440222"
|
|
16
|
+
],
|
|
17
|
+
"icao": "KEYW",
|
|
18
|
+
"observed": "2026-11-04T10:53:00.000Z",
|
|
19
|
+
"forecastFrom": null,
|
|
20
|
+
"forecastTo": null,
|
|
21
|
+
"wind": {
|
|
22
|
+
"degrees": 130,
|
|
23
|
+
"speed_kts": 5,
|
|
24
|
+
"speed_mps": 2.572222212219136,
|
|
25
|
+
"gust_kts": null,
|
|
26
|
+
"gust_mps": null,
|
|
27
|
+
"degrees_from": null,
|
|
28
|
+
"degrees_to": null
|
|
29
|
+
},
|
|
30
|
+
"visibility": {
|
|
31
|
+
"miles": 10,
|
|
32
|
+
"miles_text": "10",
|
|
33
|
+
"meters": 16093.44,
|
|
34
|
+
"meters_text": "16000"
|
|
35
|
+
},
|
|
36
|
+
"conditions": [],
|
|
37
|
+
"clouds": [],
|
|
38
|
+
"ceiling": null,
|
|
39
|
+
"temperature": {
|
|
40
|
+
"celsius": 24,
|
|
41
|
+
"fahrenheit": 75.2
|
|
42
|
+
},
|
|
43
|
+
"dewpoint": {
|
|
44
|
+
"celsius": 22,
|
|
45
|
+
"fahrenheit": 71.6
|
|
46
|
+
},
|
|
47
|
+
"humidity": {
|
|
48
|
+
"percent": 88.59935257199315
|
|
49
|
+
},
|
|
50
|
+
"barometer": {
|
|
51
|
+
"hg": 30,
|
|
52
|
+
"kpa": 101.59164304435207,
|
|
53
|
+
"mb": 1015.9164304435207
|
|
54
|
+
},
|
|
55
|
+
"flight_category": "VFR",
|
|
56
|
+
"icao_flight_category": "VFR"
|
|
57
|
+
}
|
package/docs/KFSO.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"raw_text": "KSFO 070121Z 19023KT 1 1/2SM R28R/6000VP6000FT -RA BKN004 BKN013 OVC035 15/12 A2970 RMK AO2 T01500122 PNO $",
|
|
3
|
+
"raw_parts": [
|
|
4
|
+
"KSFO",
|
|
5
|
+
"070121Z",
|
|
6
|
+
"19023KT",
|
|
7
|
+
"3/2SM",
|
|
8
|
+
"R28R/6000VP6000FT",
|
|
9
|
+
"-RA",
|
|
10
|
+
"BKN004",
|
|
11
|
+
"BKN013",
|
|
12
|
+
"OVC035",
|
|
13
|
+
"15/12",
|
|
14
|
+
"A2970",
|
|
15
|
+
"RMK",
|
|
16
|
+
"AO2",
|
|
17
|
+
"T01500122",
|
|
18
|
+
"PNO",
|
|
19
|
+
"$"
|
|
20
|
+
],
|
|
21
|
+
"icao": "KSFO",
|
|
22
|
+
"observed": "2026-11-07T01:21:00.000Z",
|
|
23
|
+
"forecastFrom": null,
|
|
24
|
+
"forecastTo": null,
|
|
25
|
+
"wind": {
|
|
26
|
+
"degrees": 190,
|
|
27
|
+
"speed_kts": 23,
|
|
28
|
+
"speed_mps": 11.832222176208026,
|
|
29
|
+
"gust_kts": null,
|
|
30
|
+
"gust_mps": null,
|
|
31
|
+
"degrees_from": null,
|
|
32
|
+
"degrees_to": null
|
|
33
|
+
},
|
|
34
|
+
"visibility": {
|
|
35
|
+
"miles": 1.5,
|
|
36
|
+
"miles_text": "1.5",
|
|
37
|
+
"meters": 2414.016,
|
|
38
|
+
"meters_text": "2500"
|
|
39
|
+
},
|
|
40
|
+
"conditions": [
|
|
41
|
+
{
|
|
42
|
+
"code": "-"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"code": "RA"
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"clouds": [
|
|
49
|
+
{
|
|
50
|
+
"code": "BKN",
|
|
51
|
+
"feet": 400,
|
|
52
|
+
"meters": 121.92
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"code": "BKN",
|
|
56
|
+
"feet": 1300,
|
|
57
|
+
"meters": 396.24
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"code": "OVC",
|
|
61
|
+
"feet": 3500,
|
|
62
|
+
"meters": 1066.8
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"ceiling": {
|
|
66
|
+
"feet": 400,
|
|
67
|
+
"meters": 121.92
|
|
68
|
+
},
|
|
69
|
+
"temperature": {
|
|
70
|
+
"celsius": 15,
|
|
71
|
+
"fahrenheit": 59
|
|
72
|
+
},
|
|
73
|
+
"dewpoint": {
|
|
74
|
+
"celsius": 12,
|
|
75
|
+
"fahrenheit": 53.6
|
|
76
|
+
},
|
|
77
|
+
"humidity": {
|
|
78
|
+
"percent": 82.26135295757305
|
|
79
|
+
},
|
|
80
|
+
"barometer": {
|
|
81
|
+
"hg": 29.7,
|
|
82
|
+
"kpa": 100.57572661390854,
|
|
83
|
+
"mb": 1005.7572661390855
|
|
84
|
+
},
|
|
85
|
+
"flight_category": "LIFR",
|
|
86
|
+
"icao_flight_category": "IFR"
|
|
87
|
+
}
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
MetarCeiling,
|
|
8
8
|
MetarFlightCategory as MetarUsFlightCategory,
|
|
9
9
|
MetarIcaoFlightCategory,
|
|
10
|
+
MetarHumidity,
|
|
10
11
|
} from "./metar-parser.type.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -50,15 +51,17 @@ export function metarTemperature(temperatureString: string): MetarTemperature |
|
|
|
50
51
|
/**
|
|
51
52
|
* @see http://andrew.rsmas.miami.edu/bmcnoldy/Humidity.html
|
|
52
53
|
*/
|
|
53
|
-
export function
|
|
54
|
+
export function relativeHumidity(temp: MetarTemperature | null, dew: MetarTemperature | null): MetarHumidity | null {
|
|
54
55
|
if (dew === null || temp === null) {
|
|
55
56
|
return null;
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
+
|
|
59
|
+
const percent =
|
|
58
60
|
(Math.exp((17.625 * dew.celsius) / (243.04 + dew.celsius)) /
|
|
59
61
|
Math.exp((17.625 * temp.celsius) / (243.04 + temp.celsius))) *
|
|
60
|
-
100
|
|
61
|
-
|
|
62
|
+
100;
|
|
63
|
+
|
|
64
|
+
return { percent };
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
export function flightCategoryUs(
|
|
@@ -91,15 +94,20 @@ export function flightCategoryIcao(
|
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
/**
|
|
94
|
-
* @returns the lowest cloud layer reporting `BKN` or `
|
|
95
|
-
* not such cloud layer was found.
|
|
97
|
+
* @returns the lowest cloud layer reporting `BKN`, `OVC` or `VV`,
|
|
98
|
+
* or undefined if not such cloud layer was found.
|
|
96
99
|
*/
|
|
97
100
|
function findCeiling(clouds: MetarCloud[]): MetarCloud | undefined {
|
|
98
101
|
return clouds.find((c) => {
|
|
99
|
-
return c.code === "BKN" || c.code === "OVC";
|
|
102
|
+
return c.code === "BKN" || c.code === "OVC" || c.code === "VV";
|
|
100
103
|
});
|
|
101
104
|
}
|
|
102
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @see findCeiling
|
|
108
|
+
* @returns the ceiling by looking for the lowest cloud layer reporting `BKN`
|
|
109
|
+
* or `OVC`.
|
|
110
|
+
*/
|
|
103
111
|
export function metarCeiling(clouds: MetarCloud[]): MetarCeiling | null {
|
|
104
112
|
const ceilingCloud = findCeiling(clouds);
|
|
105
113
|
|
|
@@ -127,3 +135,21 @@ export function metarSplit(metarString: string): string[] {
|
|
|
127
135
|
.replace(/\n/, " \\n ")
|
|
128
136
|
.split(/\s+/);
|
|
129
137
|
}
|
|
138
|
+
|
|
139
|
+
export function date(date: number, hours: number, minutes: number): Date {
|
|
140
|
+
const now = new Date();
|
|
141
|
+
|
|
142
|
+
const d = new Date(0);
|
|
143
|
+
d.setUTCDate(date);
|
|
144
|
+
d.setUTCMonth(now.getUTCMonth());
|
|
145
|
+
d.setUTCFullYear(now.getUTCFullYear());
|
|
146
|
+
|
|
147
|
+
d.setUTCHours(hours);
|
|
148
|
+
d.setUTCMinutes(minutes);
|
|
149
|
+
|
|
150
|
+
if (d.getTime() > now.getTime()) {
|
|
151
|
+
d.setUTCMonth(d.getUTCMonth() - 1);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return d;
|
|
155
|
+
}
|
package/src/metar-parser.test.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { strict as assert } from "node:assert/strict";
|
|
2
2
|
import { describe, it } from "node:test";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
3
5
|
import { metarParser } from "./metar-parser.js";
|
|
4
6
|
import * as convert from "./convert.js";
|
|
7
|
+
import type { Metar } from "./metar-parser.type.js";
|
|
8
|
+
|
|
9
|
+
function writeArtifact(filename: string, result: Metar) {
|
|
10
|
+
if (!process.env.WRITE_ARTIFACTS) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
fs.writeFileSync(path.join(import.meta.dirname, "..", "docs", filename), JSON.stringify(result, null, 2), "utf-8");
|
|
14
|
+
}
|
|
5
15
|
|
|
6
16
|
describe("METAR Parsing Tests", () => {
|
|
7
17
|
it("KEYW 041053Z AUTO 13005KT 10SM CLR 24/22 A3000 RMK AO2 SLP159 T02440222", (c) => {
|
|
@@ -14,8 +24,9 @@ describe("METAR Parsing Tests", () => {
|
|
|
14
24
|
assert.deepStrictEqual(result.wind.speed_kts, 5);
|
|
15
25
|
assert.deepStrictEqual(result.wind.gust_kts, null);
|
|
16
26
|
assert.deepStrictEqual(result.visibility?.meters_text, "16000");
|
|
17
|
-
assert.deepStrictEqual(result.barometer
|
|
27
|
+
assert.deepStrictEqual(result.barometer?.kpa, 3000 / 10 / 2.9529988);
|
|
18
28
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
29
|
+
writeArtifact("KEYW.json", result);
|
|
19
30
|
});
|
|
20
31
|
|
|
21
32
|
it("KACV 041053Z AUTO 07003KT 10SM CLR 04/04 A3001 RMK AO2 SLP169 T00440039", (c) => {
|
|
@@ -39,8 +50,8 @@ describe("METAR Parsing Tests", () => {
|
|
|
39
50
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 39.2);
|
|
40
51
|
assert.deepStrictEqual(result.dewpoint?.celsius, 4);
|
|
41
52
|
assert.deepStrictEqual(result.dewpoint?.fahrenheit, 39.2);
|
|
42
|
-
assert.deepStrictEqual(result.humidity
|
|
43
|
-
assert.deepStrictEqual(result.barometer
|
|
53
|
+
assert.deepStrictEqual(result.humidity?.percent, 100);
|
|
54
|
+
assert.deepStrictEqual(result.barometer?.hg, 30.01);
|
|
44
55
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
45
56
|
assert.deepStrictEqual(result.icao_flight_category, "VFR");
|
|
46
57
|
});
|
|
@@ -61,7 +72,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
61
72
|
assert.deepStrictEqual(result.visibility?.miles_text, "10", "result.visibility?.miles");
|
|
62
73
|
assert.deepStrictEqual(result.temperature?.celsius, 17);
|
|
63
74
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 62.6);
|
|
64
|
-
assert.deepStrictEqual(result.barometer
|
|
75
|
+
assert.deepStrictEqual(result.barometer?.hg, 29.98);
|
|
65
76
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
66
77
|
});
|
|
67
78
|
|
|
@@ -78,7 +89,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
78
89
|
assert.deepStrictEqual(result.visibility?.miles_text, "10");
|
|
79
90
|
assert.deepStrictEqual(result.temperature?.celsius, 18);
|
|
80
91
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 64.4);
|
|
81
|
-
assert.deepStrictEqual(result.barometer
|
|
92
|
+
assert.deepStrictEqual(result.barometer?.kpa, 2997 / 10 / 2.9529988);
|
|
82
93
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
83
94
|
});
|
|
84
95
|
|
|
@@ -101,7 +112,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
101
112
|
assert.deepStrictEqual(result.ceiling?.feet, undefined);
|
|
102
113
|
assert.deepStrictEqual(result.temperature?.celsius, 9);
|
|
103
114
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 48.2);
|
|
104
|
-
assert.deepStrictEqual(result.barometer
|
|
115
|
+
assert.deepStrictEqual(result.barometer?.kpa, 101.2);
|
|
105
116
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
106
117
|
});
|
|
107
118
|
|
|
@@ -128,7 +139,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
128
139
|
assert.deepStrictEqual(result.clouds[0]?.meters, result.ceiling?.meters);
|
|
129
140
|
assert.deepStrictEqual(result.temperature?.celsius, -4);
|
|
130
141
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 24.8);
|
|
131
|
-
assert.deepStrictEqual(result.barometer
|
|
142
|
+
assert.deepStrictEqual(result.barometer?.kpa, 102.0);
|
|
132
143
|
assert.deepStrictEqual(result.flight_category, "LIFR");
|
|
133
144
|
assert.deepStrictEqual(result.icao_flight_category, "IFR");
|
|
134
145
|
});
|
|
@@ -154,7 +165,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
154
165
|
// ],
|
|
155
166
|
assert.deepStrictEqual(result.temperature?.celsius, -2);
|
|
156
167
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 28.4);
|
|
157
|
-
assert.deepStrictEqual(result.barometer
|
|
168
|
+
assert.deepStrictEqual(result.barometer?.hg, 30.06);
|
|
158
169
|
assert.deepStrictEqual(result.flight_category, "LIFR");
|
|
159
170
|
});
|
|
160
171
|
|
|
@@ -170,7 +181,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
170
181
|
assert.deepStrictEqual(result.visibility?.meters_text, "16000");
|
|
171
182
|
assert.deepStrictEqual(result.visibility?.miles_text, "10");
|
|
172
183
|
assert.deepStrictEqual(result.temperature?.celsius, 24);
|
|
173
|
-
assert.deepStrictEqual(result.barometer
|
|
184
|
+
assert.deepStrictEqual(result.barometer?.kpa, 3000 / 10 / 2.9529988);
|
|
174
185
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
175
186
|
});
|
|
176
187
|
|
|
@@ -193,7 +204,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
193
204
|
// ],
|
|
194
205
|
assert.deepStrictEqual(result.temperature?.celsius, 4);
|
|
195
206
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 39.2);
|
|
196
|
-
assert.deepStrictEqual(result.barometer
|
|
207
|
+
assert.deepStrictEqual(result.barometer?.kpa, 102.8);
|
|
197
208
|
assert.deepStrictEqual(result.flight_category, "IFR");
|
|
198
209
|
assert.deepStrictEqual(result.icao_flight_category, "IFR");
|
|
199
210
|
});
|
|
@@ -212,7 +223,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
212
223
|
// ["clouds", [{ base_feet_agl: 9000, code: "SCT" }]],
|
|
213
224
|
assert.deepStrictEqual(result.temperature?.celsius, 0);
|
|
214
225
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 32);
|
|
215
|
-
assert.deepStrictEqual(result.barometer
|
|
226
|
+
assert.deepStrictEqual(result.barometer?.kpa, 3052 / 10 / 2.9529988);
|
|
216
227
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
217
228
|
});
|
|
218
229
|
|
|
@@ -233,7 +244,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
233
244
|
// ],
|
|
234
245
|
// ],
|
|
235
246
|
assert.deepStrictEqual(result.temperature?.celsius, 26);
|
|
236
|
-
assert.deepStrictEqual(result.barometer
|
|
247
|
+
assert.deepStrictEqual(result.barometer?.kpa, 3000 / 10 / 2.9529988);
|
|
237
248
|
assert.deepStrictEqual(
|
|
238
249
|
result.flight_category,
|
|
239
250
|
null,
|
|
@@ -253,9 +264,11 @@ describe("METAR Parsing Tests", () => {
|
|
|
253
264
|
assert.deepStrictEqual(result.temperature?.celsius, 15);
|
|
254
265
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 59);
|
|
255
266
|
// ["dewpoint", { celsius: 12assert.deepStrictEqual(result.temperature?.fahrenheit, 53.6 ],
|
|
256
|
-
assert.deepStrictEqual(result.barometer
|
|
257
|
-
assert.deepStrictEqual(result.barometer
|
|
267
|
+
assert.deepStrictEqual(result.barometer?.kpa, 2970 / 10 / 2.9529988);
|
|
268
|
+
assert.deepStrictEqual(result.barometer?.mb, 2970 / 2.9529988);
|
|
258
269
|
assert.deepStrictEqual(result.flight_category, "LIFR");
|
|
270
|
+
|
|
271
|
+
writeArtifact("KFSO.json", result);
|
|
259
272
|
});
|
|
260
273
|
|
|
261
274
|
it("EHAM 100125Z 33004KT CAVOK M00/M01 Q1026 NOSIG", (c) => {
|
|
@@ -269,7 +282,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
269
282
|
assert.deepStrictEqual(result.temperature?.celsius, -0);
|
|
270
283
|
assert.deepStrictEqual(result.temperature?.fahrenheit, 32);
|
|
271
284
|
// ["dewpoint", { celsius: -1assert.deepStrictEqual(result.temperature?.fahrenheit, 30.2 ],
|
|
272
|
-
assert.deepStrictEqual(result.barometer
|
|
285
|
+
assert.deepStrictEqual(result.barometer?.kpa, 102.6);
|
|
273
286
|
assert.deepStrictEqual(result.flight_category, "VFR");
|
|
274
287
|
});
|
|
275
288
|
|
|
@@ -310,8 +323,8 @@ describe("METAR Parsing Tests", () => {
|
|
|
310
323
|
assert.deepStrictEqual(result.clouds.length, 0);
|
|
311
324
|
assert.deepStrictEqual(result.temperature?.celsius, undefined);
|
|
312
325
|
assert.deepStrictEqual(result.dewpoint?.celsius, undefined);
|
|
313
|
-
assert.deepStrictEqual(result.humidity
|
|
314
|
-
assert.deepStrictEqual(result.barometer
|
|
326
|
+
assert.deepStrictEqual(result.humidity?.percent, undefined);
|
|
327
|
+
assert.deepStrictEqual(result.barometer?.mb, 1017);
|
|
315
328
|
});
|
|
316
329
|
|
|
317
330
|
it("LFMK 211130Z AUTO 29005KT 260V320 9999 OVC034 24/20 Q1011=", (c) => {
|
|
@@ -319,7 +332,7 @@ describe("METAR Parsing Tests", () => {
|
|
|
319
332
|
const result = metarParser(metar);
|
|
320
333
|
|
|
321
334
|
assert.deepStrictEqual(result.icao, "LFMK");
|
|
322
|
-
assert.deepStrictEqual(result.barometer
|
|
335
|
+
assert.deepStrictEqual(result.barometer?.mb, 1011);
|
|
323
336
|
assert.deepStrictEqual(result.wind.degrees_from, 260);
|
|
324
337
|
assert.deepStrictEqual(result.wind.degrees_to, 320);
|
|
325
338
|
});
|
|
@@ -469,7 +482,7 @@ TEMPO 1916/1918 1200 +DZ BKN001`, (c) => {
|
|
|
469
482
|
assert.strictEqual(metar.visibility?.miles, t.visibilitySm);
|
|
470
483
|
assert.strictEqual(metar.ceiling?.feet, t.ceilingFeet);
|
|
471
484
|
assert.strictEqual(metar.temperature?.celsius, t.temperatureCelsius);
|
|
472
|
-
assert.strictEqual(metar.barometer
|
|
485
|
+
assert.strictEqual(metar.barometer?.mb, t.barometerMb);
|
|
473
486
|
assert.strictEqual(metar.flight_category, t.flight_category);
|
|
474
487
|
});
|
|
475
488
|
});
|
package/src/metar-parser.ts
CHANGED
|
@@ -2,6 +2,19 @@ import * as convert from "./convert.js";
|
|
|
2
2
|
import * as MetarParserHelpers from "./metar-parser-helpers.js";
|
|
3
3
|
import type { MetarCloudCode, Metar } from "./metar-parser.type.js";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* - 0: Initial state, search for ICAO code
|
|
7
|
+
* - 1: Search for observed date
|
|
8
|
+
* - 2: Search for wind
|
|
9
|
+
* - 3: Searchh for visibility
|
|
10
|
+
* - 4: Search for conditions
|
|
11
|
+
* - 5: Search for clouds
|
|
12
|
+
* - 6: Search for temperature
|
|
13
|
+
* - 7: Search for pressure
|
|
14
|
+
* - 8: Done
|
|
15
|
+
*/
|
|
16
|
+
type ParserMode = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
17
|
+
|
|
5
18
|
/**
|
|
6
19
|
* Convert METAR string into structured object.
|
|
7
20
|
* @see https://api.checkwx.com/#31-single
|
|
@@ -13,10 +26,9 @@ import type { MetarCloudCode, Metar } from "./metar-parser.type.js";
|
|
|
13
26
|
export const metarParser = (metarString: string): Metar => {
|
|
14
27
|
const metarObject = initializeMetarObject(metarString);
|
|
15
28
|
|
|
16
|
-
let mode = 0;
|
|
29
|
+
let mode: ParserMode = 0;
|
|
17
30
|
let isTAF = false;
|
|
18
31
|
metarObject.raw_parts.forEach((metarPart) => {
|
|
19
|
-
let match;
|
|
20
32
|
if (mode === 0 && metarPart.match(/^(METAR|TAF)$/)) {
|
|
21
33
|
isTAF = metarPart === "TAF";
|
|
22
34
|
return;
|
|
@@ -40,44 +52,25 @@ export const metarParser = (metarString: string): Metar => {
|
|
|
40
52
|
mode = 1;
|
|
41
53
|
break;
|
|
42
54
|
case 1:
|
|
43
|
-
|
|
44
|
-
match = metarPart.match(/^(\d\d)(\d\d)(\d\d)Z$/);
|
|
45
|
-
if (match) {
|
|
46
|
-
metarObject.observed = new Date();
|
|
47
|
-
metarObject.observed.setUTCDate(Number(match[1]));
|
|
48
|
-
metarObject.observed.setUTCHours(Number(match[2]));
|
|
49
|
-
metarObject.observed.setUTCMinutes(Number(match[3]));
|
|
50
|
-
mode = 2;
|
|
51
|
-
}
|
|
55
|
+
mode = parseObservedDate(metarPart, metarObject, mode);
|
|
52
56
|
break;
|
|
53
57
|
case 2:
|
|
54
58
|
mode = parseWind(metarPart, metarObject, mode);
|
|
55
59
|
if (mode === 2) {
|
|
56
60
|
parseForecastDate(metarPart, metarObject);
|
|
61
|
+
// stays in mode
|
|
57
62
|
}
|
|
58
63
|
break;
|
|
59
64
|
case 3:
|
|
60
65
|
mode = parseVisibility(metarPart, metarObject, mode);
|
|
61
66
|
if (mode === 3) {
|
|
62
67
|
parseVariableWind(metarPart, metarObject);
|
|
68
|
+
// stays in mode
|
|
63
69
|
}
|
|
64
70
|
break;
|
|
65
71
|
case 4:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (match) {
|
|
69
|
-
if (!metarObject.conditions) {
|
|
70
|
-
metarObject.conditions = [];
|
|
71
|
-
}
|
|
72
|
-
match
|
|
73
|
-
.filter((m, index) => {
|
|
74
|
-
return index !== 0 && m;
|
|
75
|
-
})
|
|
76
|
-
.forEach((m) => {
|
|
77
|
-
metarObject.conditions.push({ code: m });
|
|
78
|
-
});
|
|
79
|
-
// may occur multiple times
|
|
80
|
-
}
|
|
72
|
+
parseCondition(metarPart, metarObject);
|
|
73
|
+
// may occur multiple times
|
|
81
74
|
break;
|
|
82
75
|
case 5:
|
|
83
76
|
parseClouds(metarPart, metarObject);
|
|
@@ -101,7 +94,16 @@ export const metarParser = (metarString: string): Metar => {
|
|
|
101
94
|
|
|
102
95
|
// -----------------------------------------------------------------------------
|
|
103
96
|
|
|
104
|
-
function
|
|
97
|
+
function parseObservedDate(metarPart: string, metarObject: Metar, mode: ParserMode): ParserMode {
|
|
98
|
+
const match = metarPart.match(/^(\d\d)(\d\d)(\d\d)Z$/);
|
|
99
|
+
if (!match) {
|
|
100
|
+
return mode;
|
|
101
|
+
}
|
|
102
|
+
metarObject.observed = MetarParserHelpers.date(Number(match[1]), Number(match[2]), Number(match[3]));
|
|
103
|
+
return 2;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function parseWind(metarPart: string, metarObject: Metar, mode: ParserMode): ParserMode {
|
|
105
107
|
// Case: Unkonw wind
|
|
106
108
|
if (metarPart.match(/^\/+(KT|MPS|KPH)$/)) {
|
|
107
109
|
return 3;
|
|
@@ -139,22 +141,15 @@ function parseWind(metarPart: string, metarObject: Metar, mode: number): number
|
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
function parseForecastDate(metarPart: string, metarObject: Metar): void {
|
|
142
|
-
const
|
|
143
|
-
if (!
|
|
144
|
+
const [, fromDate, fromHours, toDate, toHours] = metarPart.match(/^(\d\d)(\d\d)\/(\d\d)(\d\d)$/) || [];
|
|
145
|
+
if (!fromDate) {
|
|
144
146
|
return;
|
|
145
147
|
}
|
|
146
|
-
metarObject.forecastFrom =
|
|
147
|
-
metarObject.
|
|
148
|
-
metarObject.forecastFrom.setUTCHours(Number(match[2]));
|
|
149
|
-
metarObject.forecastFrom.setUTCMinutes(0);
|
|
150
|
-
|
|
151
|
-
metarObject.forecastTo = new Date();
|
|
152
|
-
metarObject.forecastTo.setUTCDate(Number(match[3]));
|
|
153
|
-
metarObject.forecastTo.setUTCHours(Number(match[4]));
|
|
154
|
-
metarObject.forecastTo.setUTCMinutes(0);
|
|
148
|
+
metarObject.forecastFrom = MetarParserHelpers.date(Number(fromDate), Number(fromHours), 0);
|
|
149
|
+
metarObject.forecastTo = MetarParserHelpers.date(Number(toDate), Number(toHours), 0);
|
|
155
150
|
}
|
|
156
151
|
|
|
157
|
-
function parseVisibility(metarPart: string, metarObject: Metar, mode:
|
|
152
|
+
function parseVisibility(metarPart: string, metarObject: Metar, mode: ParserMode): ParserMode {
|
|
158
153
|
// Case: No clouds & conditions reported
|
|
159
154
|
if (metarPart === "CAVOK" || metarPart === "CLR") {
|
|
160
155
|
metarObject.visibility = MetarParserHelpers.metarVisibility(10, convert.milesToMeters(10));
|
|
@@ -186,10 +181,26 @@ function parseVariableWind(metarPart: string, metarObject: Metar): void {
|
|
|
186
181
|
return;
|
|
187
182
|
}
|
|
188
183
|
|
|
189
|
-
const
|
|
184
|
+
const [, degreesFrom, degreesTo] = metarPart.match(/^(\d+)V(\d+)$/) || [];
|
|
185
|
+
if (degreesFrom || degreesTo) {
|
|
186
|
+
metarObject.wind.degrees_from = Number(degreesFrom);
|
|
187
|
+
metarObject.wind.degrees_to = Number(degreesTo);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function parseCondition(metarPart: string, metarObject: Metar): void {
|
|
192
|
+
const match = metarPart.match(/^(\+|-|VC|RE)?([A-Z][A-Z])([A-Z][A-Z])?([A-Z][A-Z])?$/);
|
|
190
193
|
if (match) {
|
|
191
|
-
metarObject.
|
|
192
|
-
|
|
194
|
+
if (!metarObject.conditions) {
|
|
195
|
+
metarObject.conditions = [];
|
|
196
|
+
}
|
|
197
|
+
match
|
|
198
|
+
.filter((m, index) => {
|
|
199
|
+
return index !== 0 && m;
|
|
200
|
+
})
|
|
201
|
+
.forEach((m) => {
|
|
202
|
+
metarObject.conditions.push({ code: m });
|
|
203
|
+
});
|
|
193
204
|
}
|
|
194
205
|
}
|
|
195
206
|
|
|
@@ -200,32 +211,29 @@ function parseClouds(metarPart: string, metarObject: Metar) {
|
|
|
200
211
|
}
|
|
201
212
|
}
|
|
202
213
|
|
|
203
|
-
function parseTemperature(metarPart: string, metarObject: Metar, mode:
|
|
214
|
+
function parseTemperature(metarPart: string, metarObject: Metar, mode: ParserMode): ParserMode {
|
|
204
215
|
const [, temp, dewpoint] = metarPart.match(/^(M?\d+|\/\/)\/(M?\d+|\/\/)?$/) || [];
|
|
205
216
|
|
|
206
217
|
if (temp) {
|
|
207
218
|
metarObject.temperature = MetarParserHelpers.metarTemperature(temp ?? "//");
|
|
208
219
|
metarObject.dewpoint = MetarParserHelpers.metarTemperature(dewpoint ?? "//");
|
|
209
|
-
metarObject.humidity
|
|
210
|
-
metarObject.temperature,
|
|
211
|
-
metarObject.dewpoint,
|
|
212
|
-
);
|
|
220
|
+
metarObject.humidity = MetarParserHelpers.relativeHumidity(metarObject.temperature, metarObject.dewpoint);
|
|
213
221
|
return 7;
|
|
214
222
|
}
|
|
215
223
|
return mode;
|
|
216
224
|
}
|
|
217
225
|
|
|
218
|
-
function parsePressure(metarPart: string, metarObject: Metar, mode:
|
|
219
|
-
const
|
|
220
|
-
if (!
|
|
226
|
+
function parsePressure(metarPart: string, metarObject: Metar, mode: ParserMode): ParserMode {
|
|
227
|
+
const [, unit, value] = metarPart.match(/^(Q|A)(\d+)/) || [];
|
|
228
|
+
if (!unit || !value) {
|
|
221
229
|
return mode;
|
|
222
230
|
}
|
|
223
|
-
|
|
224
|
-
hg
|
|
231
|
+
|
|
232
|
+
const hg = Number(value) / (unit === "Q" ? 10 : 100);
|
|
225
233
|
metarObject.barometer = {
|
|
226
|
-
hg:
|
|
227
|
-
kpa:
|
|
228
|
-
mb:
|
|
234
|
+
hg: unit === "Q" ? convert.kpaToInhg(hg) : hg,
|
|
235
|
+
kpa: unit === "Q" ? hg : convert.inhgToKpa(hg),
|
|
236
|
+
mb: unit === "Q" ? hg * 10 : convert.inhgToKpa(hg * 10),
|
|
229
237
|
};
|
|
230
238
|
return 8;
|
|
231
239
|
}
|
|
@@ -237,7 +245,7 @@ function initializeMetarObject(metarString: string): Metar {
|
|
|
237
245
|
raw_text: metarString,
|
|
238
246
|
raw_parts: MetarParserHelpers.metarSplit(metarString),
|
|
239
247
|
icao: "",
|
|
240
|
-
observed: new Date(),
|
|
248
|
+
observed: new Date(0),
|
|
241
249
|
forecastFrom: null,
|
|
242
250
|
forecastTo: null,
|
|
243
251
|
wind: {
|
|
@@ -255,14 +263,8 @@ function initializeMetarObject(metarString: string): Metar {
|
|
|
255
263
|
ceiling: null,
|
|
256
264
|
temperature: null,
|
|
257
265
|
dewpoint: null,
|
|
258
|
-
humidity:
|
|
259
|
-
|
|
260
|
-
},
|
|
261
|
-
barometer: {
|
|
262
|
-
hg: null,
|
|
263
|
-
kpa: null,
|
|
264
|
-
mb: null,
|
|
265
|
-
},
|
|
266
|
+
humidity: null,
|
|
267
|
+
barometer: null,
|
|
266
268
|
flight_category: null,
|
|
267
269
|
icao_flight_category: null,
|
|
268
270
|
};
|
package/src/metar-parser.type.ts
CHANGED
|
@@ -28,17 +28,17 @@ export interface MetarCloud {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Ceiling values of lowest cloud layer reporting `BKN` or `
|
|
31
|
+
* Ceiling values of lowest cloud layer reporting `BKN`, `OVC` or `VV`.
|
|
32
32
|
* Values will be `null` if no such layer was found.
|
|
33
33
|
*/
|
|
34
34
|
export interface MetarCeiling {
|
|
35
35
|
/**
|
|
36
|
-
* Ceiling in feet of lowest cloud layer reporting `BKN` or `
|
|
36
|
+
* Ceiling in feet of lowest cloud layer reporting `BKN`, `OVC` or `VV`.
|
|
37
37
|
* Ceiling in feet will be `null` if no such layer was found.
|
|
38
38
|
*/
|
|
39
39
|
feet: number;
|
|
40
40
|
/**
|
|
41
|
-
* Ceiling in meters of lowest cloud layer reporting `BKN` or `
|
|
41
|
+
* Ceiling in meters of lowest cloud layer reporting `BKN`, `OVC` or `VV`.
|
|
42
42
|
* Ceiling in meters will be `null` if no such layer was found.
|
|
43
43
|
*/
|
|
44
44
|
meters: number;
|
|
@@ -50,13 +50,13 @@ export interface MetarTemperature {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export interface MetarHumidity {
|
|
53
|
-
percent: number
|
|
53
|
+
percent: number;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export interface MetarPressure {
|
|
57
|
-
hg: number
|
|
58
|
-
kpa: number
|
|
59
|
-
mb: number
|
|
57
|
+
hg: number;
|
|
58
|
+
kpa: number;
|
|
59
|
+
mb: number;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
export type MetarIcaoFlightCategory = "VFR" | "IFR";
|
|
@@ -78,8 +78,8 @@ export interface Metar {
|
|
|
78
78
|
ceiling: MetarCeiling | null;
|
|
79
79
|
temperature: MetarTemperature | null;
|
|
80
80
|
dewpoint: MetarTemperature | null;
|
|
81
|
-
humidity: MetarHumidity;
|
|
82
|
-
barometer: MetarPressure;
|
|
81
|
+
humidity: MetarHumidity | null;
|
|
82
|
+
barometer: MetarPressure | null;
|
|
83
83
|
flight_category: MetarFlightCategory | null;
|
|
84
84
|
icao_flight_category: MetarIcaoFlightCategory | null;
|
|
85
85
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MetarVisibility, MetarCloudCode, MetarCloud, MetarTemperature, MetarCeiling, MetarFlightCategory as MetarUsFlightCategory, MetarIcaoFlightCategory } from "./metar-parser.type.js";
|
|
1
|
+
import type { MetarVisibility, MetarCloudCode, MetarCloud, MetarTemperature, MetarCeiling, MetarFlightCategory as MetarUsFlightCategory, MetarIcaoFlightCategory, MetarHumidity } from "./metar-parser.type.js";
|
|
2
2
|
/**
|
|
3
3
|
* @param {Number} value dito
|
|
4
4
|
* @param {Number} toNext round to next full xxxx
|
|
@@ -11,13 +11,19 @@ export declare function metarTemperature(temperatureString: string): MetarTemper
|
|
|
11
11
|
/**
|
|
12
12
|
* @see http://andrew.rsmas.miami.edu/bmcnoldy/Humidity.html
|
|
13
13
|
*/
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function relativeHumidity(temp: MetarTemperature | null, dew: MetarTemperature | null): MetarHumidity | null;
|
|
15
15
|
export declare function flightCategoryUs(visibility: MetarVisibility | null, ceiling: MetarCeiling | null): MetarUsFlightCategory | null;
|
|
16
16
|
export declare function flightCategoryIcao(visibility: MetarVisibility | null, ceiling: MetarCeiling | null): MetarIcaoFlightCategory | null;
|
|
17
|
+
/**
|
|
18
|
+
* @see findCeiling
|
|
19
|
+
* @returns the ceiling by looking for the lowest cloud layer reporting `BKN`
|
|
20
|
+
* or `OVC`.
|
|
21
|
+
*/
|
|
17
22
|
export declare function metarCeiling(clouds: MetarCloud[]): MetarCeiling | null;
|
|
18
23
|
/**
|
|
19
24
|
* @return METAR string split along its white spaces. Will convert fractional
|
|
20
25
|
* visibility values into one concatenated value.
|
|
21
26
|
*/
|
|
22
27
|
export declare function metarSplit(metarString: string): string[];
|
|
28
|
+
export declare function date(date: number, hours: number, minutes: number): Date;
|
|
23
29
|
//# sourceMappingURL=metar-parser-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metar-parser-helpers.d.ts","sourceRoot":"","sources":["../src/metar-parser-helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,IAAI,qBAAqB,EAC5C,uBAAuB,
|
|
1
|
+
{"version":3,"file":"metar-parser-helpers.d.ts","sourceRoot":"","sources":["../src/metar-parser-helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,IAAI,qBAAqB,EAC5C,uBAAuB,EACvB,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,MAAY,GAAG,MAAM,CAEjE;AAED,wBAAgB,eAAe,CAAC,gBAAgB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,eAAe,CAOpG;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,UAAU,CAOhF;AAED,wBAAgB,gBAAgB,CAAC,iBAAiB,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CASnF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,EAAE,GAAG,EAAE,gBAAgB,GAAG,IAAI,GAAG,aAAa,GAAG,IAAI,CAWlH;AAED,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,eAAe,GAAG,IAAI,EAClC,OAAO,EAAE,YAAY,GAAG,IAAI,GAC3B,qBAAqB,GAAG,IAAI,CAa9B;AAED,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,eAAe,GAAG,IAAI,EAClC,OAAO,EAAE,YAAY,GAAG,IAAI,GAC3B,uBAAuB,GAAG,IAAI,CAMhC;AAYD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,YAAY,GAAG,IAAI,CAWtE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CASxD;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAgBvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metar-parser.d.ts","sourceRoot":"","sources":["../src/metar-parser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,KAAK,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"metar-parser.d.ts","sourceRoot":"","sources":["../src/metar-parser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAepE;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,aAAa,MAAM,KAAG,KAmEjD,CAAC"}
|
|
@@ -23,17 +23,17 @@ export interface MetarCloud {
|
|
|
23
23
|
meters: number;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Ceiling values of lowest cloud layer reporting `BKN` or `
|
|
26
|
+
* Ceiling values of lowest cloud layer reporting `BKN`, `OVC` or `VV`.
|
|
27
27
|
* Values will be `null` if no such layer was found.
|
|
28
28
|
*/
|
|
29
29
|
export interface MetarCeiling {
|
|
30
30
|
/**
|
|
31
|
-
* Ceiling in feet of lowest cloud layer reporting `BKN` or `
|
|
31
|
+
* Ceiling in feet of lowest cloud layer reporting `BKN`, `OVC` or `VV`.
|
|
32
32
|
* Ceiling in feet will be `null` if no such layer was found.
|
|
33
33
|
*/
|
|
34
34
|
feet: number;
|
|
35
35
|
/**
|
|
36
|
-
* Ceiling in meters of lowest cloud layer reporting `BKN` or `
|
|
36
|
+
* Ceiling in meters of lowest cloud layer reporting `BKN`, `OVC` or `VV`.
|
|
37
37
|
* Ceiling in meters will be `null` if no such layer was found.
|
|
38
38
|
*/
|
|
39
39
|
meters: number;
|
|
@@ -43,12 +43,12 @@ export interface MetarTemperature {
|
|
|
43
43
|
fahrenheit: number;
|
|
44
44
|
}
|
|
45
45
|
export interface MetarHumidity {
|
|
46
|
-
percent: number
|
|
46
|
+
percent: number;
|
|
47
47
|
}
|
|
48
48
|
export interface MetarPressure {
|
|
49
|
-
hg: number
|
|
50
|
-
kpa: number
|
|
51
|
-
mb: number
|
|
49
|
+
hg: number;
|
|
50
|
+
kpa: number;
|
|
51
|
+
mb: number;
|
|
52
52
|
}
|
|
53
53
|
export type MetarIcaoFlightCategory = "VFR" | "IFR";
|
|
54
54
|
export type MetarFlightCategory = MetarIcaoFlightCategory | "MVFR" | "LIFR";
|
|
@@ -66,8 +66,8 @@ export interface Metar {
|
|
|
66
66
|
ceiling: MetarCeiling | null;
|
|
67
67
|
temperature: MetarTemperature | null;
|
|
68
68
|
dewpoint: MetarTemperature | null;
|
|
69
|
-
humidity: MetarHumidity;
|
|
70
|
-
barometer: MetarPressure;
|
|
69
|
+
humidity: MetarHumidity | null;
|
|
70
|
+
barometer: MetarPressure | null;
|
|
71
71
|
flight_category: MetarFlightCategory | null;
|
|
72
72
|
icao_flight_category: MetarIcaoFlightCategory | null;
|
|
73
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metar-parser.type.d.ts","sourceRoot":"","sources":["../src/metar-parser.type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;AAElE,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"metar-parser.type.d.ts","sourceRoot":"","sources":["../src/metar-parser.type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;AAElE,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,MAAM,uBAAuB,GAAG,KAAK,GAAG,KAAK,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,GAAG,MAAM,GAAG,MAAM,CAAC;AAE5E,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,IAAI,CAAC;IACf,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IAExB,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,eAAe,GAAG,IAAI,CAAC;IACnC,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7B,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACrC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAClC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IAC/B,SAAS,EAAE,aAAa,GAAG,IAAI,CAAC;IAChC,eAAe,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC5C,oBAAoB,EAAE,uBAAuB,GAAG,IAAI,CAAC;CACtD"}
|
package/tsconfig.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["./src/convert.test.ts","./src/convert.ts","./src/metar-parser-helpers.ts","./src/metar-parser.test.ts","./src/metar-parser.ts","./src/metar-parser.type.ts"],"version":"6.0.3"}
|