aewx-metar-parser 0.10.1 → 1.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/.eslintrc.js ADDED
@@ -0,0 +1,26 @@
1
+ module.exports = {
2
+ env: {
3
+ browser: true,
4
+ commonjs: true,
5
+ es2021: true
6
+ },
7
+ extends: [
8
+ 'standard'
9
+ ],
10
+ parserOptions: {
11
+ ecmaVersion: 'latest'
12
+ },
13
+ rules: {
14
+ semi: ['error', 'always']
15
+ },
16
+ overrides: [
17
+ {
18
+ files: [
19
+ "test/*.js"
20
+ ],
21
+ env: {
22
+ mocha: true
23
+ }
24
+ }
25
+ ]
26
+ }
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npm test
package/CONTRIBUTING.md CHANGED
@@ -16,11 +16,6 @@ You will need:
16
16
 
17
17
  1. A [Github account](https://github.com/) and Git
18
18
  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
-
23
- For Gulp, ESLint and Nodeunit call `npm install -g gulp-cli eslint nodeunit` from command line.
24
19
 
25
20
  Making changes
26
21
  --------------
package/README.md CHANGED
@@ -116,12 +116,11 @@ Status
116
116
  -------
117
117
 
118
118
  [![npm version](https://badge.fury.io/js/aewx-metar-parser.svg)](https://badge.fury.io/js/aewx-metar-parser)
119
- [![Build Status](https://travis-ci.org/fboes/metar-parser.svg?branch=master)](https://travis-ci.org/fboes/metar-parser)
120
119
  [![devDependency Status](https://david-dm.org/fboes/metar-parser/dev-status.svg)](https://david-dm.org/fboes/metar-parser?type=dev)
121
120
 
122
121
  Legal stuff
123
122
  -----------
124
123
 
125
- Author: [Frank Boës](http://3960.org)
124
+ Author: [Frank Boës](https://3960.org)
126
125
 
127
126
  Copyright & license: See [LICENSE.txt](LICENSE.txt)
package/lib/convert.js CHANGED
@@ -4,39 +4,39 @@
4
4
  * Convert units
5
5
  */
6
6
  const convert = {
7
- celsiusToFahrenheit: function(celsius) {
7
+ celsiusToFahrenheit: function (celsius) {
8
8
  return celsius * 1.8 + 32;
9
9
  },
10
10
 
11
- feetToMeters: function(feet) {
11
+ feetToMeters: function (feet) {
12
12
  return feet * 0.3048;
13
13
  },
14
14
 
15
- milesToMeters: function(miles) {
15
+ milesToMeters: function (miles) {
16
16
  return miles * 1609.344;
17
17
  },
18
18
 
19
- metersToMiles: function(meters) {
19
+ metersToMiles: function (meters) {
20
20
  return meters / 1609.344;
21
21
  },
22
22
 
23
- inhgToKpa: function(inHg) {
23
+ inhgToKpa: function (inHg) {
24
24
  return inHg / 0.29529988;
25
25
  },
26
26
 
27
- kpaToInhg: function(kpa) {
27
+ kpaToInhg: function (kpa) {
28
28
  return kpa * 0.29529988;
29
29
  },
30
30
 
31
- kphToMps: function(kph) {
31
+ kphToMps: function (kph) {
32
32
  return kph / 3600 * 1000;
33
33
  },
34
34
 
35
- mpsToKts: function(mps) {
35
+ mpsToKts: function (mps) {
36
36
  return mps * 1.9438445;
37
37
  },
38
38
 
39
- ktsToMps: function(kts) {
39
+ ktsToMps: function (kts) {
40
40
  return kts / 1.9438445;
41
41
  }
42
42
  };
@@ -10,13 +10,13 @@ const convert = require('./convert');
10
10
  * @returns {Object} with structured information. The object resembles the API
11
11
  * reponse of the data property of https://api.checkwx.com/#31-single
12
12
  */
13
- const metarParser = function(metarString) {
14
- let metarArray = metarString
13
+ const metarParser = function (metarString) {
14
+ const metarArray = metarString
15
15
  .trim()
16
16
  .replace(/^METAR\S*?\s/, '')
17
- .replace(/(\s)(\d)\s(\d)\/(\d)(SM)/, function(all, a, b, c, d, e) {
17
+ .replace(/(\s)(\d)\s(\d)\/(\d)(SM)/, function (all, a, b, c, d, e) {
18
18
  // convert visbility range like `1 1/2 SM`
19
- return a + (Number(b) * Number(d) + Number(c)) + '/' + d + e;
19
+ return a + (Number(b) * Number(d) + Number(c)) + '/' + d + e;
20
20
  })
21
21
  .split(' ')
22
22
  ;
@@ -24,7 +24,7 @@ const metarParser = function(metarString) {
24
24
  throw new Error('Not enough METAR information found');
25
25
  }
26
26
 
27
- let metarObject = {
27
+ const metarObject = {
28
28
  raw_text: metarString,
29
29
  raw_parts: metarArray
30
30
  };
@@ -37,7 +37,7 @@ const metarParser = function(metarString) {
37
37
  * @param {Number} dew in celsius
38
38
  * @returns {Number} humidity in 1/100
39
39
  */
40
- _private.calcHumidity = function(temp, dew) {
40
+ _private.calcHumidity = function (temp, dew) {
41
41
  return Math.exp(
42
42
  (17.625 * dew) / (243.04 + dew)
43
43
  ) / Math.exp(
@@ -50,7 +50,7 @@ const metarParser = function(metarString) {
50
50
  * @param {Number} toNext round to next full xxxx
51
51
  * @returns {Number} rounded value
52
52
  */
53
- _private.round = function(value, toNext = 500) {
53
+ _private.round = function (value, toNext = 500) {
54
54
  return Math.round(value / toNext) * toNext;
55
55
  };
56
56
 
@@ -65,7 +65,7 @@ const metarParser = function(metarString) {
65
65
  if (mode < 5 && metarPart.match(/^(FEW|SCT|BKN|OVC)(\d+)?/)) {
66
66
  mode = 5; // no visibility / conditions reported
67
67
  }
68
- if (mode < 6 && metarPart.match(/^M?\d+\/M?\d+$/)) {
68
+ if (mode < 6 && metarPart.match(/(^M?\d+\/M?\d+$)|(^\/\/\/\/\/)/)) {
69
69
  mode = 6; // end of clouds
70
70
  }
71
71
  switch (mode) {
@@ -98,15 +98,15 @@ const metarParser = function(metarString) {
98
98
  }
99
99
 
100
100
  metarObject.wind = {
101
- degrees: (match[1] === 'VRB') ? 180 : Number(match[1]),
101
+ degrees: (match[1] === 'VRB') ? 180 : Number(match[1]),
102
102
  speed_kts: (match[4] === 'MPS') ? convert.mpsToKts(match[2]) : match[2],
103
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])
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
106
  };
107
107
  if (match[1] === 'VRB') {
108
108
  metarObject.wind.degrees_from = 0;
109
- metarObject.wind.degrees_to = 359;
109
+ metarObject.wind.degrees_to = 359;
110
110
  }
111
111
  mode = 3;
112
112
  }
@@ -120,18 +120,18 @@ const metarParser = function(metarString) {
120
120
  : Number(match[1])
121
121
  ;
122
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],
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
126
  meters_float: (match[3] && match[3] === 'SM') ? convert.milesToMeters(match[1]) : match[1]
127
127
  };
128
128
 
129
129
  mode = 4;
130
130
  } else if (metarPart === 'CAVOK' || metarPart === 'CLR') {
131
131
  metarObject.visibility = {
132
- miles: 10,
133
- miles_float: 10,
134
- meters: convert.milesToMeters(10),
132
+ miles: 10,
133
+ miles_float: 10,
134
+ meters: convert.milesToMeters(10),
135
135
  meters_float: convert.milesToMeters(10)
136
136
  };
137
137
  mode = 5; // no clouds & conditions reported
@@ -170,9 +170,9 @@ const metarParser = function(metarString) {
170
170
  metarObject.clouds = [];
171
171
  }
172
172
  match[2] = Number(match[2]) * 100;
173
- let cloud = {
173
+ const cloud = {
174
174
  code: match[1],
175
- base_feet_agl: match[2],
175
+ base_feet_agl: match[2],
176
176
  base_meters_agl: convert.feetToMeters(match[2])
177
177
  };
178
178
  metarObject.clouds.push(cloud);
@@ -181,6 +181,10 @@ const metarParser = function(metarString) {
181
181
  case 6:
182
182
  // Temperature
183
183
  match = metarPart.match(/^(M?\d+)\/(M?\d+)$/);
184
+ if (match === null && metarPart.match(/^\/\/\/\/\/$/)) {
185
+ mode = 7;
186
+ break;
187
+ }
184
188
  if (match) {
185
189
  match[1] = Number(match[1].replace('M', '-'));
186
190
  match[2] = Number(match[2].replace('M', '-'));
@@ -203,9 +207,9 @@ const metarParser = function(metarString) {
203
207
  match[2] = Number(match[2]);
204
208
  match[2] /= (match[1] === 'Q') ? 10 : 100;
205
209
  metarObject.barometer = {
206
- hg: (match[1] === 'Q') ? convert.kpaToInhg(match[2]) : match[2],
207
- kpa: (match[1] === 'Q') ? match[2] : convert.inhgToKpa(match[2]),
208
- mb: (match[1] === 'Q') ? match[2] * 10 : convert.inhgToKpa(match[2] * 10)
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)
209
213
  };
210
214
  mode = 8;
211
215
  }
@@ -215,9 +219,9 @@ const metarParser = function(metarString) {
215
219
 
216
220
  if (!metarObject.visibility) {
217
221
  metarObject.visibility = {
218
- miles: 10,
219
- miles_float: 10,
220
- meters: convert.milesToMeters(10),
222
+ miles: 10,
223
+ miles_float: 10,
224
+ meters: convert.milesToMeters(10),
221
225
  meters_float: convert.milesToMeters(10)
222
226
  };
223
227
  }
@@ -231,22 +235,22 @@ const metarParser = function(metarString) {
231
235
  const highestCloud = metarObject.clouds[metarObject.clouds.length - 1];
232
236
  metarObject.ceiling = {
233
237
  code: highestCloud.code,
234
- feet_agl: highestCloud.base_feet_agl,
238
+ feet_agl: highestCloud.base_feet_agl,
235
239
  meters_agl: highestCloud.base_meters_agl
236
240
  };
237
241
  }
238
242
 
239
243
  metarObject.flight_category = '';
240
- if (metarObject.visibility.miles_float > 5
241
- && (!metarObject.ceiling || metarObject.ceiling.feet_agl > 3000)
244
+ if (metarObject.visibility.miles_float > 5 &&
245
+ (!metarObject.ceiling || metarObject.ceiling.feet_agl > 3000)
242
246
  ) {
243
247
  metarObject.flight_category = 'VFR';
244
- } else if (metarObject.visibility.miles_float >= 3
245
- && (!metarObject.ceiling || metarObject.ceiling.feet_agl >= 1000)
248
+ } else if (metarObject.visibility.miles_float >= 3 &&
249
+ (!metarObject.ceiling || metarObject.ceiling.feet_agl >= 1000)
246
250
  ) {
247
251
  metarObject.flight_category = 'MVFR';
248
- } else if (metarObject.visibility.miles_float >= 1
249
- && (!metarObject.ceiling || metarObject.ceiling.feet_agl >= 500)
252
+ } else if (metarObject.visibility.miles_float >= 1 &&
253
+ (!metarObject.ceiling || metarObject.ceiling.feet_agl >= 500)
250
254
  ) {
251
255
  metarObject.flight_category = 'IFR';
252
256
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aewx-metar-parser",
3
- "version": "0.10.1",
3
+ "version": "1.0.0",
4
4
  "description": "Parse METAR information into structured JavaScript object",
5
5
  "directories": {
6
6
  "test": "test",
@@ -9,20 +9,18 @@
9
9
  "main": "lib/metar-parser.js",
10
10
  "scripts": {
11
11
  "precommit": "npm test",
12
- "test": "eslint *.js lib/**/*.js test/**/*.js && mocha && npm outdated"
12
+ "test": "npx eslint lib/**/*.js test/**/*.js && npx mocha && npm outdated",
13
+ "prepare": "husky install"
13
14
  },
14
15
  "repository": {
15
16
  "type": "git",
16
17
  "url": "git+ssh://git@github.com/fboes/metar-parser.git"
17
18
  },
18
19
  "devDependencies": {
19
- "beeper": "^1.1.1",
20
- "gulp": "^4.0.0",
21
- "gulp-eslint": "^5.0.0",
22
- "gulp-mocha": "^6.0.0",
23
- "gulp-plumber": "^1.2.1",
24
- "husky": "^1.3.1",
25
- "mocha": "^6.0.1"
20
+ "eslint": "^8.18.0",
21
+ "eslint-config-standard": "^17.0.0",
22
+ "husky": "^8.0.0",
23
+ "mocha": "^10.0.0"
26
24
  },
27
25
  "keywords": [
28
26
  "flight",
@@ -35,10 +33,5 @@
35
33
  "bugs": {
36
34
  "url": "https://github.com/fboes/metar-parser/issues"
37
35
  },
38
- "homepage": "https://github.com/fboes/metar-parser#readme",
39
- "husky": {
40
- "hooks": {
41
- "pre-commit": "npm run precommit"
42
- }
43
- }
36
+ "homepage": "https://github.com/fboes/metar-parser#readme"
44
37
  }
package/test/convert.js CHANGED
@@ -1,56 +1,55 @@
1
1
  'use strict';
2
2
 
3
- const assert = require('assert');
3
+ const assert = require('assert');
4
4
 
5
5
  const convert = require('../lib/convert');
6
6
 
7
- describe('convert', function() {
8
-
9
- it('must convert celsius in fahrenheit', function() {
7
+ describe('convert', function () {
8
+ it('must convert celsius in fahrenheit', function () {
10
9
  const fahrenheit = convert.celsiusToFahrenheit(1);
11
- //console.log(fahrenheit);
10
+ // console.log(fahrenheit);
12
11
  assert.ok(fahrenheit > 33.75);
13
12
  assert.ok(fahrenheit < 33.85);
14
13
  });
15
14
 
16
- it('must convert kpa in hgin', function() {
15
+ it('must convert kpa in hgin', function () {
17
16
  const hgin = convert.kpaToInhg(1);
18
17
  // console.log(hgin);
19
18
  assert.ok(hgin > 0.29);
20
19
  assert.ok(hgin < 0.30);
21
20
  });
22
21
 
23
- it('must convert hgin in kpa', function() {
22
+ it('must convert hgin in kpa', function () {
24
23
  const kpa = convert.inhgToKpa(1);
25
- //console.log(kpa);
24
+ // console.log(kpa);
26
25
  assert.ok(kpa > 3.38);
27
26
  assert.ok(kpa < 3.39);
28
27
  });
29
28
 
30
- it('must convert miles in meters', function() {
29
+ it('must convert miles in meters', function () {
31
30
  const meters = convert.milesToMeters(1);
32
- //console.log(meters);
31
+ // console.log(meters);
33
32
  assert.ok(meters > 1609);
34
33
  assert.ok(meters < 1610);
35
34
  });
36
35
 
37
- it('must convert km/h in m/s', function() {
36
+ it('must convert km/h in m/s', function () {
38
37
  const mps = convert.kphToMps(1);
39
- //console.log(mps);
38
+ // console.log(mps);
40
39
  assert.ok(mps > 0.277);
41
40
  assert.ok(mps < 0.278);
42
41
  });
43
42
 
44
- it('must convert m/s to kts', function() {
43
+ it('must convert m/s to kts', function () {
45
44
  const kts = convert.mpsToKts(1);
46
- //console.log(kts);
45
+ // console.log(kts);
47
46
  assert.ok(kts > 1.94);
48
47
  assert.ok(kts < 1.95);
49
48
  });
50
49
 
51
- it('must convert kts to m/s', function() {
50
+ it('must convert kts to m/s', function () {
52
51
  const mps = convert.ktsToMps(1);
53
- //console.log(mps);
52
+ // console.log(mps);
54
53
  assert.ok(mps > 0.51);
55
54
  assert.ok(mps < 0.52);
56
55
  });
@@ -1,33 +1,32 @@
1
1
  'use strict';
2
2
 
3
- const assert = require('assert');
3
+ const assert = require('assert');
4
4
 
5
5
  const metarParser = require('../lib/metar-parser');
6
6
  const convert = require('../lib/convert');
7
7
 
8
- describe('metarParser', function() {
9
-
8
+ describe('metarParser', function () {
10
9
  const metarTestcases = [
11
10
  {
12
11
  source: 'https://aviationweather.gov/metar#1',
13
- metarCode: "KEYW 041053Z AUTO 13005KT 10SM CLR 24/22 A3000 RMK AO2 SLP159 T02440222",
12
+ metarCode: 'KEYW 041053Z AUTO 13005KT 10SM CLR 24/22 A3000 RMK AO2 SLP159 T02440222',
14
13
  expectedValues: [
15
14
  ['icao', 'KEYW'],
16
- ['wind', {degrees: 130, speed_kts: 5, gust_kts: 5}],
17
- ['visibility', { meters: "16000", meters_float: convert.milesToMeters(10) }],
15
+ ['wind', { degrees: 130, speed_kts: 5, gust_kts: 5 }],
16
+ ['visibility', { meters: '16000', meters_float: convert.milesToMeters(10) }],
18
17
  ['temperature', { celsius: 24, fahrenheit: 75.2 }],
19
- ['barometer', {kpa: 3000 / 10 / 2.9529988 }],
18
+ ['barometer', { kpa: 3000 / 10 / 2.9529988 }],
20
19
  ['flight_category', 'VFR']
21
20
  ],
22
21
  output: false
23
22
  },
24
23
  {
25
24
  source: 'https://aviationweather.gov/metar#2',
26
- metarCode: "KACV 041053Z AUTO 07003KT 10SM CLR 04/04 A3001 RMK AO2 SLP169 T00440039",
25
+ metarCode: 'KACV 041053Z AUTO 07003KT 10SM CLR 04/04 A3001 RMK AO2 SLP169 T00440039',
27
26
  expectedValues: [
28
27
  ['icao', 'KACV'],
29
- ['wind', {degrees: 70, speed_kts: 3, gust_kts: 3}],
30
- ['visibility', { meters: "16000", meters_float: convert.milesToMeters(10) }],
28
+ ['wind', { degrees: 70, speed_kts: 3, gust_kts: 3 }],
29
+ ['visibility', { meters: '16000', meters_float: convert.milesToMeters(10) }],
31
30
  ['temperature', { celsius: 4, fahrenheit: 39.2 }],
32
31
  ['barometer', { hg: 30.01, kpa: convert.inhgToKpa(30.01) }],
33
32
  ['flight_category', 'VFR']
@@ -36,11 +35,11 @@ describe('metarParser', function() {
36
35
  },
37
36
  {
38
37
  source: 'https://api.checkwx.com/#1',
39
- metarCode: "KPIE 260853Z AUTO 02013G17KT 10SM CLR 17/07 A2998 RMK AO2 SLP153 T01720072 57000",
38
+ metarCode: 'KPIE 260853Z AUTO 02013G17KT 10SM CLR 17/07 A2998 RMK AO2 SLP153 T01720072 57000',
40
39
  expectedValues: [
41
40
  ['icao', 'KPIE'],
42
- ['wind', {degrees: 20, speed_kts: 13, gust_kts: 17}],
43
- ['visibility', { meters: "16000", meters_float: convert.milesToMeters(10) }],
41
+ ['wind', { degrees: 20, speed_kts: 13, gust_kts: 17 }],
42
+ ['visibility', { meters: '16000', meters_float: convert.milesToMeters(10) }],
44
43
  ['temperature', { celsius: 17, fahrenheit: 62.6 }],
45
44
  ['barometer', { hg: 29.98, kpa: convert.inhgToKpa(29.98) }],
46
45
  ['flight_category', 'VFR']
@@ -49,54 +48,54 @@ describe('metarParser', function() {
49
48
  },
50
49
  {
51
50
  source: 'https://api.checkwx.com/#2',
52
- metarCode: "KSPG 260853Z AUTO 05012KT 10SM CLR 18/09 A2997 RMK AO2 SLP148 T01830094 53001",
51
+ metarCode: 'KSPG 260853Z AUTO 05012KT 10SM CLR 18/09 A2997 RMK AO2 SLP148 T01830094 53001',
53
52
  expectedValues: [
54
53
  ['icao', 'KSPG'],
55
- ['wind', {degrees: 50, speed_kts: 12, gust_kts: 12}],
56
- ['visibility', { meters: "16000", meters_float: convert.milesToMeters(10) }],
54
+ ['wind', { degrees: 50, speed_kts: 12, gust_kts: 12 }],
55
+ ['visibility', { meters: '16000', meters_float: convert.milesToMeters(10) }],
57
56
  ['temperature', { celsius: 18, fahrenheit: 64.4 }],
58
- ['barometer', {kpa: 2997 / 10 / 2.9529988 }],
57
+ ['barometer', { kpa: 2997 / 10 / 2.9529988 }],
59
58
  ['flight_category', 'VFR']
60
59
  ],
61
60
  output: false
62
61
  },
63
62
  {
64
63
  source: 'https://de.wikipedia.org/wiki/METAR',
65
- metarCode: "EDDS 081620Z 29010KT 9999 FEW040TCU 09/M03 Q1012 NOSIG",
64
+ metarCode: 'EDDS 081620Z 29010KT 9999 FEW040TCU 09/M03 Q1012 NOSIG',
66
65
  expectedValues: [
67
66
  ['icao', 'EDDS'],
68
67
  ['wind', {
69
68
  degrees: 290,
70
69
  speed_kts: 10,
71
70
  speed_mps: convert.ktsToMps(10),
72
- gust_kts: 10,
73
- gust_mps: convert.ktsToMps(10)
71
+ gust_kts: 10,
72
+ gust_mps: convert.ktsToMps(10)
74
73
  }],
75
- ['visibility', { meters: "10000", meters_float: 9999 }],
76
- ['clouds', [{base_feet_agl: 4000, code: 'FEW'}]],
74
+ ['visibility', { meters: '10000', meters_float: 9999 }],
75
+ ['clouds', [{ base_feet_agl: 4000, code: 'FEW' }]],
77
76
  ['temperature', { celsius: 9, fahrenheit: 48.2 }],
78
- ['barometer', {kpa: 101.2 }],
77
+ ['barometer', { kpa: 101.2 }],
79
78
  ['flight_category', 'VFR']
80
79
  ],
81
80
  output: false
82
81
  },
83
82
  {
84
83
  source: 'https://en.wikipedia.org/wiki/METAR#1',
85
- metarCode: "METAR LBBG 041600Z 12012MPS 090V150 1400 R04/P1500N R22/P1500U +SN BKN022 OVC050 M04/M07 Q1020 NOSIG 8849//91=",
84
+ metarCode: 'METAR LBBG 041600Z 12012MPS 090V150 1400 R04/P1500N R22/P1500U +SN BKN022 OVC050 M04/M07 Q1020 NOSIG 8849//91=',
86
85
  expectedValues: [
87
86
  ['icao', 'LBBG'],
88
87
  ['wind', {
89
88
  degrees: 120,
90
89
  speed_kts: convert.mpsToKts(12),
91
90
  speed_mps: 12,
92
- gust_kts: convert.mpsToKts(12),
93
- gust_mps: 12
91
+ gust_kts: convert.mpsToKts(12),
92
+ gust_mps: 12
94
93
  }],
95
- ['visibility', { meters: "1500", meters_float: 1400 }],
96
- ['conditions', [ {code: '+'}, {code: 'SN'} ]],
97
- ['clouds', [{base_feet_agl: 2200, code: 'BKN'}, {base_feet_agl: 5000, code: 'OVC'}]],
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' }]],
98
97
  ['temperature', { celsius: -4, fahrenheit: 24.8 }],
99
- ['barometer', {kpa: 102.0 }],
98
+ ['barometer', { kpa: 102.0 }],
100
99
  ['flight_category', 'LIFR']
101
100
  ],
102
101
 
@@ -104,69 +103,69 @@ describe('metarParser', function() {
104
103
  },
105
104
  {
106
105
  source: 'https://en.wikipedia.org/wiki/METAR#2',
107
- metarCode: "METAR KTTN 051853Z 04011KT 1/2SM VCTS SN FZFG BKN003 OVC010 M02/M02 A3006 RMK AO2 TSB40 SLP176 P0002 T10171017=",
106
+ metarCode: 'METAR KTTN 051853Z 04011KT 1/2SM VCTS SN FZFG BKN003 OVC010 M02/M02 A3006 RMK AO2 TSB40 SLP176 P0002 T10171017=',
108
107
  expectedValues: [
109
108
  ['icao', 'KTTN'],
110
- ['wind', {degrees: 40, speed_kts: 11, gust_kts: 11}],
111
- ['visibility', { meters: "1000", meters_float: convert.milesToMeters(0.5) }],
112
- ['conditions', [ {code: 'VC'}, {code: 'TS'}, {code: 'SN'}, {code: 'FZ'}, {code: 'FG'} ]],
113
- ['clouds', [{base_feet_agl: 300, code: 'BKN'}, {base_feet_agl: 1000, code: 'OVC'}]],
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' }]],
114
113
  ['temperature', { celsius: -2, fahrenheit: 28.4 }],
115
- ['barometer', {kpa: convert.inhgToKpa(30.06) }],
114
+ ['barometer', { kpa: convert.inhgToKpa(30.06) }],
116
115
  ['flight_category', 'LIFR']
117
116
  ],
118
117
  output: false
119
118
  },
120
119
  {
121
120
  source: 'https://en.allmetsat.com/metar-taf/#1',
122
- metarCode: "KEYW 041053Z AUTO 13005KT 10SM CLR 24/22 A3000 RMK AO2 SLP159 T02440222",
121
+ metarCode: 'KEYW 041053Z AUTO 13005KT 10SM CLR 24/22 A3000 RMK AO2 SLP159 T02440222',
123
122
  expectedValues: [
124
123
  ['icao', 'KEYW'],
125
- ['wind', {degrees: 130, speed_kts: 5, gust_kts: 5}],
126
- ['visibility', { meters: "16000", meters_float: convert.milesToMeters(10) }],
124
+ ['wind', { degrees: 130, speed_kts: 5, gust_kts: 5 }],
125
+ ['visibility', { meters: '16000', meters_float: convert.milesToMeters(10) }],
127
126
  ['temperature', { celsius: 24 }],
128
- ['barometer', {kpa: 3000 / 10 / 2.9529988 }],
127
+ ['barometer', { kpa: 3000 / 10 / 2.9529988 }],
129
128
  ['flight_category', 'VFR']
130
129
  ],
131
130
  output: false
132
131
  },
133
132
  {
134
133
  source: 'https://en.allmetsat.com/metar-taf/#2',
135
- metarCode: "EDDH 041050Z 29013KT 6000 SCT006 BKN009 04/03 Q1028 TEMPO BKN012",
134
+ metarCode: 'EDDH 041050Z 29013KT 6000 SCT006 BKN009 04/03 Q1028 TEMPO BKN012',
136
135
  expectedValues: [
137
136
  ['icao', 'EDDH'],
138
- ['wind', {degrees: 290, speed_kts: 13, gust_kts: 13}],
139
- ['visibility', { meters: "6000", meters_float: 6000 }],
140
- ['clouds', [{base_feet_agl: 600, code: 'SCT'}, {base_feet_agl: 900, code: 'BKN'}]],
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' }]],
141
140
  ['temperature', { celsius: 4, fahrenheit: 39.2 }],
142
- ['barometer', {kpa: 102.8 }],
141
+ ['barometer', { kpa: 102.8 }],
143
142
  ['flight_category', 'IFR']
144
143
  ],
145
144
  output: false
146
145
  },
147
146
  {
148
147
  source: 'https://en.allmetsat.com/metar-taf/#3',
149
- metarCode: "ETEB 041056Z AUTO 26010KT 9999 SCT090 00/M01 A3052 RMK AO2 SLP378 T10031013",
148
+ metarCode: 'ETEB 041056Z AUTO 26010KT 9999 SCT090 00/M01 A3052 RMK AO2 SLP378 T10031013',
150
149
  expectedValues: [
151
150
  ['icao', 'ETEB'],
152
- ['wind', {degrees: 260, speed_kts: 10, gust_kts: 10}],
153
- ['visibility', { meters: "10000", meters_float: 9999 }],
154
- ['clouds', [{base_feet_agl: 9000, code: 'SCT'}]],
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' }]],
155
154
  ['temperature', { celsius: 0, fahrenheit: 32 }],
156
- ['barometer', {kpa: 3052 / 10 / 2.9529988 }],
155
+ ['barometer', { kpa: 3052 / 10 / 2.9529988 }],
157
156
  ['flight_category', 'VFR']
158
157
  ],
159
158
  output: false
160
159
  },
161
160
  {
162
161
  source: 'https://aviationweather.gov/metar/#3',
163
- metarCode: "KEYW 050653Z AUTO 19006KT FEW024 BKN039 26/23 A3000 RMK AO2 LTG DSNT W SLP159 T02610228",
162
+ metarCode: 'KEYW 050653Z AUTO 19006KT FEW024 BKN039 26/23 A3000 RMK AO2 LTG DSNT W SLP159 T02610228',
164
163
  expectedValues: [
165
164
  ['icao', 'KEYW'],
166
- ['wind', {degrees: 190, speed_kts: 6, gust_kts: 6}],
167
- ['clouds', [{base_feet_agl: 2400, code: 'FEW'}, {base_feet_agl: 3900, code: 'BKN'}]],
165
+ ['wind', { degrees: 190, speed_kts: 6, gust_kts: 6 }],
166
+ ['clouds', [{ base_feet_agl: 2400, code: 'FEW' }, { base_feet_agl: 3900, code: 'BKN' }]],
168
167
  ['temperature', { celsius: 26 }],
169
- ['barometer', {kpa: 3000 / 10 / 2.9529988 }],
168
+ ['barometer', { kpa: 3000 / 10 / 2.9529988 }],
170
169
  ['flight_category', 'VFR']
171
170
  ],
172
171
  output: false
@@ -176,11 +175,11 @@ describe('metarParser', function() {
176
175
  metarCode: 'KSFO 070121Z 19023KT 1 1/2SM R28R/6000VP6000FT -RA BKN004 BKN013 OVC035 15/12 A2970 RMK AO2 T01500122 PNO $',
177
176
  expectedValues: [
178
177
  ['icao', 'KSFO'],
179
- ['conditions', [ {code: '-'}, {code: 'RA'} ]],
180
- ['visibility', { meters: "2500", meters_float: convert.milesToMeters(1.5) }],
178
+ ['conditions', [{ code: '-' }, { code: 'RA' }]],
179
+ ['visibility', { meters: '2500', meters_float: convert.milesToMeters(1.5) }],
181
180
  ['temperature', { celsius: 15, fahrenheit: 59 }],
182
181
  ['dewpoint', { celsius: 12, fahrenheit: 53.6 }],
183
- ['barometer', {kpa: 2970 / 10 / 2.9529988, mb: 2970 / 2.9529988 }],
182
+ ['barometer', { kpa: 2970 / 10 / 2.9529988, mb: 2970 / 2.9529988 }],
184
183
  ['flight_category', 'IFR']
185
184
  ],
186
185
  output: false
@@ -189,7 +188,7 @@ describe('metarParser', function() {
189
188
  source: 'EHAM with CAVOK',
190
189
  metarCode: 'EHAM 100125Z 33004KT CAVOK M00/M01 Q1026 NOSIG',
191
190
  expectedValues: [
192
- ['visibility', { miles_float: 10, meters: "16000", meters_float: convert.milesToMeters(10) }],
191
+ ['visibility', { miles_float: 10, meters: '16000', meters_float: convert.milesToMeters(10) }],
193
192
  ['temperature', { celsius: -0, fahrenheit: 32 }],
194
193
  ['dewpoint', { celsius: -1, fahrenheit: 30.2 }],
195
194
  ['barometer', { hg: 102.6, kpa: 102.6, mb: 10.26 }],
@@ -201,8 +200,8 @@ describe('metarParser', function() {
201
200
  source: 'Without VIS because it is CLR',
202
201
  metarCode: 'KEYW 291553Z VRB03KT CLR 17/09 A3009 RMK AO2 SLP189 T01670089 $',
203
202
  expectedValues: [
204
- ['visibility', { miles_float: 10, meters: "16000", meters_float: convert.milesToMeters(10) }],
205
- ['wind', {degrees: 180, speed_kts: 3, gust_kts: 3}],
203
+ ['visibility', { miles_float: 10, meters: '16000', meters_float: convert.milesToMeters(10) }],
204
+ ['wind', { degrees: 180, speed_kts: 3, gust_kts: 3 }],
206
205
  ['temperature', { celsius: 17 }],
207
206
  ['dewpoint', { celsius: 9 }],
208
207
  ['flight_category', 'VFR']
@@ -213,14 +212,14 @@ describe('metarParser', function() {
213
212
  source: 'AUTO does stuff?',
214
213
  metarCode: 'KDVO 022335Z AUTO 4SM BR BKN007 BKN013 12/12 A2988 RMK AO2',
215
214
  expectedValues: [
216
- ['visibility', { miles_float: 4, meters: "6500", meters_float: convert.milesToMeters(4) }]
215
+ ['visibility', { miles_float: 4, meters: '6500', meters_float: convert.milesToMeters(4) }]
217
216
  ],
218
217
  output: false
219
218
  }
220
219
  ];
221
220
 
222
- metarTestcases.forEach(function(test) {
223
- it('must convert METAR string from ' + test.source, function() {
221
+ metarTestcases.forEach(function (test) {
222
+ it('must convert METAR string from ' + test.source, function () {
224
223
  const metarData = metarParser(test.metarCode);
225
224
  if (test.output) {
226
225
  console.log(metarData);
@@ -289,4 +288,17 @@ describe('metarParser', function() {
289
288
  });
290
289
  });
291
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
+ });
292
304
  });
package/.eslintrc.yaml DELETED
@@ -1,61 +0,0 @@
1
- root: true
2
- extends:
3
- - eslint:recommended
4
- env:
5
- node: true
6
- mocha: true
7
- es6: true
8
- parserOptions:
9
- ecmaVersion: 2017
10
- rules:
11
- arrow-parens:
12
- - error
13
- - always
14
- arrow-body-style:
15
- - error
16
- - always
17
- brace-style: error
18
- comma-dangle:
19
- - error
20
- - never
21
- comma-spacing:
22
- - error
23
- - { before: false, after: true }
24
- curly: error
25
- eqeqeq: error
26
- func-call-spacing:
27
- - error
28
- - never
29
- indent:
30
- - error
31
- - 2
32
- - SwitchCase: 1
33
- key-spacing:
34
- - error
35
- - beforeColon: false
36
- mode: minimum
37
- linebreak-style:
38
- - error
39
- - unix
40
- max-len:
41
- - warn
42
- - { code: 120, ignoreStrings: true, ignoreRegExpLiterals: true }
43
- no-console: off
44
- no-else-return: error
45
- no-lonely-if: error
46
- no-loop-func: error
47
- no-multi-str: error
48
- no-undef: error
49
- no-unused-vars: error
50
- no-var: error
51
- semi:
52
- - error
53
- - always
54
- space-before-function-paren:
55
- - error
56
- - never
57
- space-infix-ops: error
58
- strict:
59
- - error
60
- - safe
61
- valid-jsdoc: warn
package/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - "node"
4
- notifications:
5
- email:
6
- recipients:
7
- - info@3960.org
8
- on_success: change
9
- on_failure: change
package/gulpfile.js DELETED
@@ -1,62 +0,0 @@
1
- 'use strict';
2
-
3
- // Include gulp
4
- const gulp = require('gulp');
5
- const pkg = require('./package.json');
6
- const beep = require('beeper');
7
- const onError = function() {
8
- beep();
9
- return true;
10
- };
11
-
12
- // Include Our Plugins
13
- const eslint = require('gulp-eslint');
14
- const mocha = require('gulp-mocha');
15
- const plumber = require('gulp-plumber');
16
-
17
-
18
- const tasks = {
19
- doEslint: function() {
20
- return gulp.src(
21
- [
22
- '*.js',
23
- pkg.directories.lib + '/**/*.js',
24
- pkg.directories.test + '/**/*.js'
25
- ])
26
- .pipe(plumber({errorHandler: onError}))
27
- .pipe(eslint())
28
- .pipe(eslint.format())
29
- //.pipe(eslint.failAfterError())
30
- ;
31
- },
32
-
33
- doMocha: function() {
34
- return gulp.src(pkg.directories.test + '/**/*.js', {read: false})
35
- .pipe(plumber({errorHandler: onError}))
36
- .pipe(mocha({
37
- reporter: 'dot'
38
- }))
39
- ;
40
- },
41
-
42
- // Watch Files For Changes
43
- watch: function() {
44
- gulp.watch(['gulpfile.js', 'package.json'], process.exit);
45
- gulp.watch(
46
- [
47
- '*.js',
48
- pkg.directories.lib + '/**/*.js',
49
- pkg.directories.test + '/**/*.js'
50
- ],
51
- tasks.test
52
- );
53
- }
54
- };
55
-
56
- // Bundle tasks
57
- tasks.test = gulp.parallel(tasks.doEslint, tasks.doMocha);
58
-
59
- // Expose tasks
60
- gulp.task('test', tasks.test);
61
- gulp.task('watch', tasks.watch);
62
- gulp.task('default', tasks.watch);