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.
@@ -1,263 +0,0 @@
1
- 'use strict';
2
-
3
- const convert = require('./convert');
4
-
5
- /**
6
- * Convert METAR string into structured object.
7
- * @see https://api.checkwx.com/#31-single
8
- * @see https://www.skybrary.aero/index.php/Meteorological_Terminal_Air_Report_(METAR)
9
- * @param {String} metarString raw
10
- * @returns {Object} with structured information. The object resembles the API
11
- * reponse of the data property of https://api.checkwx.com/#31-single
12
- */
13
- const metarParser = function (metarString) {
14
- const metarArray = metarString
15
- .trim()
16
- .replace(/^METAR\S*?\s/, '')
17
- .replace(/(\s)(\d)\s(\d)\/(\d)(SM)/, function (all, a, b, c, d, e) {
18
- // convert visbility range like `1 1/2 SM`
19
- return a + (Number(b) * Number(d) + Number(c)) + '/' + d + e;
20
- })
21
- .split(' ')
22
- ;
23
- if (metarArray.length < 3) {
24
- throw new Error('Not enough METAR information found');
25
- }
26
-
27
- const metarObject = {
28
- raw_text: metarString,
29
- raw_parts: metarArray
30
- };
31
-
32
- const _private = {};
33
-
34
- /**
35
- * @see http://andrew.rsmas.miami.edu/bmcnoldy/Humidity.html
36
- * @param {Number} temp in celsius
37
- * @param {Number} dew in celsius
38
- * @returns {Number} humidity in 1/100
39
- */
40
- _private.calcHumidity = function (temp, dew) {
41
- return Math.exp(
42
- (17.625 * dew) / (243.04 + dew)
43
- ) / Math.exp(
44
- (17.625 * temp) / (243.04 + temp)
45
- );
46
- };
47
-
48
- /**
49
- * @param {Number} value dito
50
- * @param {Number} toNext round to next full xxxx
51
- * @returns {Number} rounded value
52
- */
53
- _private.round = function (value, toNext = 500) {
54
- return Math.round(value / toNext) * toNext;
55
- };
56
-
57
- // ---------------------------------------------------------------------------
58
-
59
- let mode = 0;
60
- metarArray.forEach((metarPart) => {
61
- let match;
62
- if (mode < 3 && metarPart.match(/^(\d+)(?:\/(\d+))?(SM)?$/)) {
63
- mode = 3; // no wind reported
64
- }
65
- if (mode < 5 && metarPart.match(/^(FEW|SCT|BKN|OVC)(\d+)?/)) {
66
- mode = 5; // no visibility / conditions reported
67
- }
68
- if (mode < 6 && metarPart.match(/(^M?\d+\/M?\d+$)|(^\/\/\/\/\/)/)) {
69
- mode = 6; // end of clouds
70
- }
71
- switch (mode) {
72
- case 0:
73
- // ICAO Code
74
- metarObject.icao = metarPart;
75
- mode = 1;
76
- break;
77
- case 1:
78
- // Observed Date
79
- match = metarPart.match(/^(\d\d)(\d\d)(\d\d)Z$/);
80
- if (match) {
81
- metarObject.observed = new Date();
82
- metarObject.observed.setUTCDate(Number(match[1]));
83
- metarObject.observed.setUTCHours(Number(match[2]));
84
- metarObject.observed.setUTCMinutes(Number(match[3]));
85
- mode = 2;
86
- }
87
- break;
88
- case 2:
89
- // Wind
90
- match = metarPart.match(/^(\d\d\d|VRB)P?(\d+)(?:G(\d+))?(KT|MPS|KPH)/);
91
- if (match) {
92
- match[2] = Number(match[2]);
93
- match[3] = match[3] ? Number(match[3]) : match[2];
94
- if (match[4] === 'KPH') {
95
- match[2] = convert.kphToMps(match[2]);
96
- match[3] = convert.kphToMps(match[3]);
97
- match[4] = 'MPS';
98
- }
99
-
100
- metarObject.wind = {
101
- degrees: (match[1] === 'VRB') ? 180 : Number(match[1]),
102
- speed_kts: (match[4] === 'MPS') ? convert.mpsToKts(match[2]) : match[2],
103
- speed_mps: (match[4] === 'MPS') ? match[2] : convert.ktsToMps(match[2]),
104
- gust_kts: (match[4] === 'MPS') ? convert.mpsToKts(match[3]) : match[3],
105
- gust_mps: (match[4] === 'MPS') ? match[3] : convert.ktsToMps(match[3])
106
- };
107
- if (match[1] === 'VRB') {
108
- metarObject.wind.degrees_from = 0;
109
- metarObject.wind.degrees_to = 359;
110
- }
111
- mode = 3;
112
- }
113
- break;
114
- case 3:
115
- // Visibility
116
- match = metarPart.match(/^(\d+)(?:\/(\d+))?(SM)?$/);
117
- if (match) {
118
- match[1] = (match[2])
119
- ? Number(match[1]) / Number(match[2])
120
- : Number(match[1])
121
- ;
122
- metarObject.visibility = {
123
- miles: (match[3] && match[3] === 'SM') ? match[1] : convert.metersToMiles(match[1]),
124
- miles_float: (match[3] && match[3] === 'SM') ? match[1] : convert.metersToMiles(match[1]),
125
- meters: (match[3] && match[3] === 'SM') ? convert.milesToMeters(match[1]) : match[1],
126
- meters_float: (match[3] && match[3] === 'SM') ? convert.milesToMeters(match[1]) : match[1]
127
- };
128
-
129
- mode = 4;
130
- } else if (metarPart === 'CAVOK' || metarPart === 'CLR') {
131
- metarObject.visibility = {
132
- miles: 10,
133
- miles_float: 10,
134
- meters: convert.milesToMeters(10),
135
- meters_float: convert.milesToMeters(10)
136
- };
137
- mode = 5; // no clouds & conditions reported
138
- } else if (metarObject.wind) {
139
- // Variable wind direction
140
- match = metarPart.match(/^(\d+)V(\d+)$/);
141
- if (match) {
142
- metarObject.wind.degrees_from = Number(match[1]);
143
- metarObject.wind.degrees_to = Number(match[2]);
144
- }
145
- }
146
- break;
147
- case 4:
148
- // Conditions
149
- match = metarPart.match(/^(\+|-|VC|RE)?([A-Z][A-Z])([A-Z][A-Z])?([A-Z][A-Z])?$/);
150
- if (match) {
151
- if (!metarObject.conditions) {
152
- metarObject.conditions = [];
153
- }
154
- match
155
- .filter((m, index) => {
156
- return (index !== 0 && m);
157
- })
158
- .forEach((m) => {
159
- metarObject.conditions.push({ code: m });
160
- })
161
- ;
162
- // may occur multiple times
163
- }
164
- break;
165
- case 5:
166
- // Clouds
167
- match = metarPart.match(/^(FEW|SCT|BKN|OVC)(\d+)/);
168
- if (match) {
169
- if (!metarObject.clouds) {
170
- metarObject.clouds = [];
171
- }
172
- match[2] = Number(match[2]) * 100;
173
- const cloud = {
174
- code: match[1],
175
- base_feet_agl: match[2],
176
- base_meters_agl: convert.feetToMeters(match[2])
177
- };
178
- metarObject.clouds.push(cloud);
179
- }
180
- break;
181
- case 6:
182
- // Temperature
183
- match = metarPart.match(/^(M?\d+)\/(M?\d+)$/);
184
- if (match === null && metarPart.match(/^\/\/\/\/\/$/)) {
185
- mode = 7;
186
- break;
187
- }
188
- if (match) {
189
- match[1] = Number(match[1].replace('M', '-'));
190
- match[2] = Number(match[2].replace('M', '-'));
191
- metarObject.temperature = {
192
- celsius: match[1],
193
- fahrenheit: convert.celsiusToFahrenheit(match[1])
194
- };
195
- metarObject.dewpoint = {
196
- celsius: match[2],
197
- fahrenheit: convert.celsiusToFahrenheit(match[2])
198
- };
199
- metarObject.humidity_percent = _private.calcHumidity(match[1], match[2]) * 100;
200
- mode = 7;
201
- }
202
- break;
203
- case 7:
204
- // Pressure
205
- match = metarPart.match(/^(Q|A)(\d+)/);
206
- if (match) {
207
- match[2] = Number(match[2]);
208
- match[2] /= (match[1] === 'Q') ? 10 : 100;
209
- metarObject.barometer = {
210
- hg: (match[1] === 'Q') ? convert.kpaToInhg(match[2]) : match[2],
211
- kpa: (match[1] === 'Q') ? match[2] : convert.inhgToKpa(match[2]),
212
- mb: (match[1] === 'Q') ? match[2] * 10 : convert.inhgToKpa(match[2] * 10)
213
- };
214
- mode = 8;
215
- }
216
- break;
217
- }
218
- });
219
-
220
- if (!metarObject.visibility) {
221
- metarObject.visibility = {
222
- miles: 10,
223
- miles_float: 10,
224
- meters: convert.milesToMeters(10),
225
- meters_float: convert.milesToMeters(10)
226
- };
227
- }
228
-
229
- // Finishing touches
230
-
231
- metarObject.visibility.miles = String(_private.round(metarObject.visibility.miles, 0.5));
232
- metarObject.visibility.meters = String(_private.round(metarObject.visibility.meters));
233
-
234
- if (metarObject.clouds) {
235
- const highestCloud = metarObject.clouds[metarObject.clouds.length - 1];
236
- metarObject.ceiling = {
237
- code: highestCloud.code,
238
- feet_agl: highestCloud.base_feet_agl,
239
- meters_agl: highestCloud.base_meters_agl
240
- };
241
- }
242
-
243
- metarObject.flight_category = '';
244
- if (metarObject.visibility.miles_float > 5 &&
245
- (!metarObject.ceiling || metarObject.ceiling.feet_agl > 3000)
246
- ) {
247
- metarObject.flight_category = 'VFR';
248
- } else if (metarObject.visibility.miles_float >= 3 &&
249
- (!metarObject.ceiling || metarObject.ceiling.feet_agl >= 1000)
250
- ) {
251
- metarObject.flight_category = 'MVFR';
252
- } else if (metarObject.visibility.miles_float >= 1 &&
253
- (!metarObject.ceiling || metarObject.ceiling.feet_agl >= 500)
254
- ) {
255
- metarObject.flight_category = 'IFR';
256
- } else {
257
- metarObject.flight_category = 'LIFR';
258
- }
259
-
260
- return metarObject;
261
- };
262
-
263
- module.exports = metarParser;
@@ -1,304 +0,0 @@
1
- 'use strict';
2
-
3
- const assert = require('assert');
4
-
5
- const metarParser = require('../lib/metar-parser');
6
- const convert = require('../lib/convert');
7
-
8
- describe('metarParser', function () {
9
- const metarTestcases = [
10
- {
11
- source: 'https://aviationweather.gov/metar#1',
12
- metarCode: 'KEYW 041053Z AUTO 13005KT 10SM CLR 24/22 A3000 RMK AO2 SLP159 T02440222',
13
- expectedValues: [
14
- ['icao', 'KEYW'],
15
- ['wind', { degrees: 130, speed_kts: 5, gust_kts: 5 }],
16
- ['visibility', { meters: '16000', meters_float: convert.milesToMeters(10) }],
17
- ['temperature', { celsius: 24, fahrenheit: 75.2 }],
18
- ['barometer', { kpa: 3000 / 10 / 2.9529988 }],
19
- ['flight_category', 'VFR']
20
- ],
21
- output: false
22
- },
23
- {
24
- source: 'https://aviationweather.gov/metar#2',
25
- metarCode: 'KACV 041053Z AUTO 07003KT 10SM CLR 04/04 A3001 RMK AO2 SLP169 T00440039',
26
- expectedValues: [
27
- ['icao', 'KACV'],
28
- ['wind', { degrees: 70, speed_kts: 3, gust_kts: 3 }],
29
- ['visibility', { meters: '16000', meters_float: convert.milesToMeters(10) }],
30
- ['temperature', { celsius: 4, fahrenheit: 39.2 }],
31
- ['barometer', { hg: 30.01, kpa: convert.inhgToKpa(30.01) }],
32
- ['flight_category', 'VFR']
33
- ],
34
- output: false
35
- },
36
- {
37
- source: 'https://api.checkwx.com/#1',
38
- metarCode: 'KPIE 260853Z AUTO 02013G17KT 10SM CLR 17/07 A2998 RMK AO2 SLP153 T01720072 57000',
39
- expectedValues: [
40
- ['icao', 'KPIE'],
41
- ['wind', { degrees: 20, speed_kts: 13, gust_kts: 17 }],
42
- ['visibility', { meters: '16000', meters_float: convert.milesToMeters(10) }],
43
- ['temperature', { celsius: 17, fahrenheit: 62.6 }],
44
- ['barometer', { hg: 29.98, kpa: convert.inhgToKpa(29.98) }],
45
- ['flight_category', 'VFR']
46
- ],
47
- output: false
48
- },
49
- {
50
- source: 'https://api.checkwx.com/#2',
51
- metarCode: 'KSPG 260853Z AUTO 05012KT 10SM CLR 18/09 A2997 RMK AO2 SLP148 T01830094 53001',
52
- expectedValues: [
53
- ['icao', 'KSPG'],
54
- ['wind', { degrees: 50, speed_kts: 12, gust_kts: 12 }],
55
- ['visibility', { meters: '16000', meters_float: convert.milesToMeters(10) }],
56
- ['temperature', { celsius: 18, fahrenheit: 64.4 }],
57
- ['barometer', { kpa: 2997 / 10 / 2.9529988 }],
58
- ['flight_category', 'VFR']
59
- ],
60
- output: false
61
- },
62
- {
63
- source: 'https://de.wikipedia.org/wiki/METAR',
64
- metarCode: 'EDDS 081620Z 29010KT 9999 FEW040TCU 09/M03 Q1012 NOSIG',
65
- expectedValues: [
66
- ['icao', 'EDDS'],
67
- ['wind', {
68
- degrees: 290,
69
- speed_kts: 10,
70
- speed_mps: convert.ktsToMps(10),
71
- gust_kts: 10,
72
- gust_mps: convert.ktsToMps(10)
73
- }],
74
- ['visibility', { meters: '10000', meters_float: 9999 }],
75
- ['clouds', [{ base_feet_agl: 4000, code: 'FEW' }]],
76
- ['temperature', { celsius: 9, fahrenheit: 48.2 }],
77
- ['barometer', { kpa: 101.2 }],
78
- ['flight_category', 'VFR']
79
- ],
80
- output: false
81
- },
82
- {
83
- source: 'https://en.wikipedia.org/wiki/METAR#1',
84
- metarCode: 'METAR LBBG 041600Z 12012MPS 090V150 1400 R04/P1500N R22/P1500U +SN BKN022 OVC050 M04/M07 Q1020 NOSIG 8849//91=',
85
- expectedValues: [
86
- ['icao', 'LBBG'],
87
- ['wind', {
88
- degrees: 120,
89
- speed_kts: convert.mpsToKts(12),
90
- speed_mps: 12,
91
- gust_kts: convert.mpsToKts(12),
92
- gust_mps: 12
93
- }],
94
- ['visibility', { meters: '1500', meters_float: 1400 }],
95
- ['conditions', [{ code: '+' }, { code: 'SN' }]],
96
- ['clouds', [{ base_feet_agl: 2200, code: 'BKN' }, { base_feet_agl: 5000, code: 'OVC' }]],
97
- ['temperature', { celsius: -4, fahrenheit: 24.8 }],
98
- ['barometer', { kpa: 102.0 }],
99
- ['flight_category', 'LIFR']
100
- ],
101
-
102
- output: false
103
- },
104
- {
105
- source: 'https://en.wikipedia.org/wiki/METAR#2',
106
- metarCode: 'METAR KTTN 051853Z 04011KT 1/2SM VCTS SN FZFG BKN003 OVC010 M02/M02 A3006 RMK AO2 TSB40 SLP176 P0002 T10171017=',
107
- expectedValues: [
108
- ['icao', 'KTTN'],
109
- ['wind', { degrees: 40, speed_kts: 11, gust_kts: 11 }],
110
- ['visibility', { meters: '1000', meters_float: convert.milesToMeters(0.5) }],
111
- ['conditions', [{ code: 'VC' }, { code: 'TS' }, { code: 'SN' }, { code: 'FZ' }, { code: 'FG' }]],
112
- ['clouds', [{ base_feet_agl: 300, code: 'BKN' }, { base_feet_agl: 1000, code: 'OVC' }]],
113
- ['temperature', { celsius: -2, fahrenheit: 28.4 }],
114
- ['barometer', { kpa: convert.inhgToKpa(30.06) }],
115
- ['flight_category', 'LIFR']
116
- ],
117
- output: false
118
- },
119
- {
120
- source: 'https://en.allmetsat.com/metar-taf/#1',
121
- metarCode: 'KEYW 041053Z AUTO 13005KT 10SM CLR 24/22 A3000 RMK AO2 SLP159 T02440222',
122
- expectedValues: [
123
- ['icao', 'KEYW'],
124
- ['wind', { degrees: 130, speed_kts: 5, gust_kts: 5 }],
125
- ['visibility', { meters: '16000', meters_float: convert.milesToMeters(10) }],
126
- ['temperature', { celsius: 24 }],
127
- ['barometer', { kpa: 3000 / 10 / 2.9529988 }],
128
- ['flight_category', 'VFR']
129
- ],
130
- output: false
131
- },
132
- {
133
- source: 'https://en.allmetsat.com/metar-taf/#2',
134
- metarCode: 'EDDH 041050Z 29013KT 6000 SCT006 BKN009 04/03 Q1028 TEMPO BKN012',
135
- expectedValues: [
136
- ['icao', 'EDDH'],
137
- ['wind', { degrees: 290, speed_kts: 13, gust_kts: 13 }],
138
- ['visibility', { meters: '6000', meters_float: 6000 }],
139
- ['clouds', [{ base_feet_agl: 600, code: 'SCT' }, { base_feet_agl: 900, code: 'BKN' }]],
140
- ['temperature', { celsius: 4, fahrenheit: 39.2 }],
141
- ['barometer', { kpa: 102.8 }],
142
- ['flight_category', 'IFR']
143
- ],
144
- output: false
145
- },
146
- {
147
- source: 'https://en.allmetsat.com/metar-taf/#3',
148
- metarCode: 'ETEB 041056Z AUTO 26010KT 9999 SCT090 00/M01 A3052 RMK AO2 SLP378 T10031013',
149
- expectedValues: [
150
- ['icao', 'ETEB'],
151
- ['wind', { degrees: 260, speed_kts: 10, gust_kts: 10 }],
152
- ['visibility', { meters: '10000', meters_float: 9999 }],
153
- ['clouds', [{ base_feet_agl: 9000, code: 'SCT' }]],
154
- ['temperature', { celsius: 0, fahrenheit: 32 }],
155
- ['barometer', { kpa: 3052 / 10 / 2.9529988 }],
156
- ['flight_category', 'VFR']
157
- ],
158
- output: false
159
- },
160
- {
161
- source: 'https://aviationweather.gov/metar/#3',
162
- metarCode: 'KEYW 050653Z AUTO 19006KT FEW024 BKN039 26/23 A3000 RMK AO2 LTG DSNT W SLP159 T02610228',
163
- expectedValues: [
164
- ['icao', 'KEYW'],
165
- ['wind', { degrees: 190, speed_kts: 6, gust_kts: 6 }],
166
- ['clouds', [{ base_feet_agl: 2400, code: 'FEW' }, { base_feet_agl: 3900, code: 'BKN' }]],
167
- ['temperature', { celsius: 26 }],
168
- ['barometer', { kpa: 3000 / 10 / 2.9529988 }],
169
- ['flight_category', 'VFR']
170
- ],
171
- output: false
172
- },
173
- {
174
- source: 'https://api.checkwx.com/#2019-01-07',
175
- metarCode: 'KSFO 070121Z 19023KT 1 1/2SM R28R/6000VP6000FT -RA BKN004 BKN013 OVC035 15/12 A2970 RMK AO2 T01500122 PNO $',
176
- expectedValues: [
177
- ['icao', 'KSFO'],
178
- ['conditions', [{ code: '-' }, { code: 'RA' }]],
179
- ['visibility', { meters: '2500', meters_float: convert.milesToMeters(1.5) }],
180
- ['temperature', { celsius: 15, fahrenheit: 59 }],
181
- ['dewpoint', { celsius: 12, fahrenheit: 53.6 }],
182
- ['barometer', { kpa: 2970 / 10 / 2.9529988, mb: 2970 / 2.9529988 }],
183
- ['flight_category', 'IFR']
184
- ],
185
- output: false
186
- },
187
- {
188
- source: 'EHAM with CAVOK',
189
- metarCode: 'EHAM 100125Z 33004KT CAVOK M00/M01 Q1026 NOSIG',
190
- expectedValues: [
191
- ['visibility', { miles_float: 10, meters: '16000', meters_float: convert.milesToMeters(10) }],
192
- ['temperature', { celsius: -0, fahrenheit: 32 }],
193
- ['dewpoint', { celsius: -1, fahrenheit: 30.2 }],
194
- ['barometer', { hg: 102.6, kpa: 102.6, mb: 10.26 }],
195
- ['flight_category', 'VFR']
196
- ],
197
- output: false
198
- },
199
- {
200
- source: 'Without VIS because it is CLR',
201
- metarCode: 'KEYW 291553Z VRB03KT CLR 17/09 A3009 RMK AO2 SLP189 T01670089 $',
202
- expectedValues: [
203
- ['visibility', { miles_float: 10, meters: '16000', meters_float: convert.milesToMeters(10) }],
204
- ['wind', { degrees: 180, speed_kts: 3, gust_kts: 3 }],
205
- ['temperature', { celsius: 17 }],
206
- ['dewpoint', { celsius: 9 }],
207
- ['flight_category', 'VFR']
208
- ],
209
- output: false
210
- },
211
- {
212
- source: 'AUTO does stuff?',
213
- metarCode: 'KDVO 022335Z AUTO 4SM BR BKN007 BKN013 12/12 A2988 RMK AO2',
214
- expectedValues: [
215
- ['visibility', { miles_float: 4, meters: '6500', meters_float: convert.milesToMeters(4) }]
216
- ],
217
- output: false
218
- }
219
- ];
220
-
221
- metarTestcases.forEach(function (test) {
222
- it('must convert METAR string from ' + test.source, function () {
223
- const metarData = metarParser(test.metarCode);
224
- if (test.output) {
225
- console.log(metarData);
226
- }
227
- assert.ok(metarData);
228
- assert.ok(metarData.raw_text);
229
- assert.ok(metarData.raw_parts);
230
- assert.ok(metarData.raw_parts.length > 2);
231
- if (metarData.visibility) {
232
- assert.ok(metarData.visibility.miles);
233
- assert.ok(metarData.visibility.meters);
234
- }
235
- if (metarData.clouds && metarData.clouds[0]) {
236
- assert.ok(metarData.clouds[0].code);
237
- assert.ok(metarData.clouds[0].base_feet_agl);
238
- assert.ok(metarData.clouds[0].base_meters_agl);
239
- }
240
- if (metarData.ceiling) {
241
- assert.ok(metarData.ceiling.code);
242
- assert.ok(metarData.ceiling.feet_agl);
243
- assert.ok(metarData.ceiling.meters_agl);
244
- }
245
-
246
- test.expectedValues.forEach((valueTest) => {
247
- assert.ok(metarData[valueTest[0]], 'Key present: ' + valueTest[0]);
248
-
249
- // Add missing values for tests
250
- switch (valueTest[0]) {
251
- case 'clouds':
252
- valueTest[1] = valueTest[1].map((cloud) => {
253
- if (!cloud.base_meters_agl) {
254
- cloud.base_meters_agl = convert.feetToMeters(cloud.base_feet_agl);
255
- }
256
- return cloud;
257
- });
258
- break;
259
- }
260
-
261
- // Actual testing
262
- switch (valueTest[0]) {
263
- case 'temperature':
264
- case 'dewpoint':
265
- assert.deepStrictEqual(metarData[valueTest[0]].celsius, valueTest[1].celsius, 'celsius match');
266
- break;
267
- case 'barometer':
268
- assert.deepStrictEqual(metarData[valueTest[0]].kpa, valueTest[1].kpa, 'kpa match');
269
- break;
270
- case 'wind':
271
- assert.deepStrictEqual(metarData[valueTest[0]].degrees, valueTest[1].degrees, 'degrees match');
272
- assert.deepStrictEqual(metarData[valueTest[0]].speed_kts, valueTest[1].speed_kts, 'speed_kts match');
273
- assert.deepStrictEqual(metarData[valueTest[0]].gust_kts, valueTest[1].gust_kts, 'gust_kts match');
274
- if (valueTest[1].speed_mps) {
275
- assert.deepStrictEqual(metarData[valueTest[0]].speed_mps, valueTest[1].speed_mps, 'speed_mps match');
276
- }
277
- if (valueTest[1].gust_mps) {
278
- assert.deepStrictEqual(metarData[valueTest[0]].gust_mps, valueTest[1].gust_mps, 'gust_mps match');
279
- }
280
- break;
281
- case 'visibility':
282
- assert.deepStrictEqual(metarData[valueTest[0]].meters, valueTest[1].meters, 'meters match');
283
- break;
284
- default:
285
- assert.deepStrictEqual(metarData[valueTest[0]], valueTest[1], 'Exact value match: ' + valueTest[0]);
286
- break;
287
- }
288
- });
289
- });
290
- });
291
-
292
- it('should LFMK 151400Z AUTO 06007KT 030V100 CAVOK ///// Q1017 NOSIG= have QNH = 1017', () => {
293
- const metar = 'LFMK 151400Z AUTO 06007KT 030V100 CAVOK ///// Q1017 NOSIG=';
294
- const resultat = metarParser(metar);
295
- console.log(resultat);
296
- assert.deepStrictEqual(resultat.barometer.mb, 1017);
297
- });
298
-
299
- it('should LFMK 211130Z AUTO 29005KT 260V320 9999 OVC034 24/20 Q1011= have QNH = 1011', () => {
300
- const metar = 'LLFMK 211130Z AUTO 29005KT 260V320 9999 OVC034 24/20 Q1011=';
301
- const resultat = metarParser(metar);
302
- assert.deepStrictEqual(resultat.barometer.mb, 1011);
303
- });
304
- });