aewx-metar-parser 3.0.1 → 4.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/CHANGELOG.md +14 -0
- package/README.md +5 -1
- package/dist/convert.js +27 -32
- package/dist/convert.test.js +1 -1
- package/dist/metar-parser-helpers.js +100 -0
- package/dist/metar-parser.js +160 -217
- package/dist/metar-parser.test.js +159 -68
- package/dist/metar-parser.type.js +1 -0
- package/eslint.config.js +11 -8
- package/package.json +10 -9
- package/src/convert.test.ts +1 -1
- package/src/convert.ts +35 -40
- package/src/metar-parser-helpers.ts +129 -0
- package/src/metar-parser.test.ts +174 -68
- package/src/metar-parser.ts +188 -308
- package/src/metar-parser.type.ts +85 -0
- package/tsconfig.json +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/types/convert.d.ts +9 -14
- package/types/convert.d.ts.map +1 -1
- package/types/metar-parser-helpers.d.ts +23 -0
- package/types/metar-parser-helpers.d.ts.map +1 -0
- package/types/metar-parser.d.ts +1 -61
- package/types/metar-parser.d.ts.map +1 -1
- package/types/metar-parser.type.d.ts +74 -0
- package/types/metar-parser.type.d.ts.map +1 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { MetarVisibility, MetarCloudCode, MetarCloud, MetarTemperature, MetarCeiling, MetarFlightCategory as MetarUsFlightCategory, MetarIcaoFlightCategory } from "./metar-parser.type.js";
|
|
2
|
+
/**
|
|
3
|
+
* @param {Number} value dito
|
|
4
|
+
* @param {Number} toNext round to next full xxxx
|
|
5
|
+
* @returns {Number} rounded value
|
|
6
|
+
*/
|
|
7
|
+
export declare function round(value: number, toNext?: number): number;
|
|
8
|
+
export declare function metarVisibility(visibility_miles: number, visibility_meters: number): MetarVisibility;
|
|
9
|
+
export declare function metarCloud(code: MetarCloudCode, hundredFeet: string): MetarCloud;
|
|
10
|
+
export declare function metarTemperature(temperatureString: string): MetarTemperature | null;
|
|
11
|
+
/**
|
|
12
|
+
* @see http://andrew.rsmas.miami.edu/bmcnoldy/Humidity.html
|
|
13
|
+
*/
|
|
14
|
+
export declare function relativeHumidityPercent(temp: MetarTemperature | null, dew: MetarTemperature | null): number | null;
|
|
15
|
+
export declare function flightCategoryUs(visibility: MetarVisibility | null, ceiling: MetarCeiling | null): MetarUsFlightCategory | null;
|
|
16
|
+
export declare function flightCategoryIcao(visibility: MetarVisibility | null, ceiling: MetarCeiling | null): MetarIcaoFlightCategory | null;
|
|
17
|
+
export declare function metarCeiling(clouds: MetarCloud[]): MetarCeiling | null;
|
|
18
|
+
/**
|
|
19
|
+
* @return METAR string split along its white spaces. Will convert fractional
|
|
20
|
+
* visibility values into one concatenated value.
|
|
21
|
+
*/
|
|
22
|
+
export declare function metarSplit(metarString: string): string[];
|
|
23
|
+
//# sourceMappingURL=metar-parser-helpers.d.ts.map
|
|
@@ -0,0 +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,EACxB,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,uBAAuB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,EAAE,GAAG,EAAE,gBAAgB,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CASlH;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,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"}
|
package/types/metar-parser.d.ts
CHANGED
|
@@ -1,64 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
code: string;
|
|
3
|
-
}
|
|
4
|
-
export interface MetarWind {
|
|
5
|
-
degrees: number | null;
|
|
6
|
-
speed_kts: number;
|
|
7
|
-
speed_mps: number;
|
|
8
|
-
gust_kts: number | null;
|
|
9
|
-
gust_mps: number | null;
|
|
10
|
-
degrees_from: number | null;
|
|
11
|
-
degrees_to: number | null;
|
|
12
|
-
}
|
|
13
|
-
export interface MetarVisibility {
|
|
14
|
-
miles: number;
|
|
15
|
-
miles_text: string;
|
|
16
|
-
meters: number;
|
|
17
|
-
meters_text: string;
|
|
18
|
-
}
|
|
19
|
-
export type MetarCloudCode = "FEW" | "SCT" | "BKN" | "OVC";
|
|
20
|
-
export interface MetarCloud {
|
|
21
|
-
code: MetarCloudCode;
|
|
22
|
-
feet: number;
|
|
23
|
-
meters: number;
|
|
24
|
-
}
|
|
25
|
-
export interface MetarCeiling {
|
|
26
|
-
feet: number | null;
|
|
27
|
-
meters: number | null;
|
|
28
|
-
}
|
|
29
|
-
export interface MetarTemperature {
|
|
30
|
-
celsius: number | null;
|
|
31
|
-
fahrenheit: number | null;
|
|
32
|
-
}
|
|
33
|
-
export interface MetarHumidity {
|
|
34
|
-
percent: number | null;
|
|
35
|
-
}
|
|
36
|
-
export interface MetarPressure {
|
|
37
|
-
hg: number | null;
|
|
38
|
-
kpa: number | null;
|
|
39
|
-
mb: number | null;
|
|
40
|
-
}
|
|
41
|
-
export type MetarIcaoFlightCategory = "VFR" | "IFR";
|
|
42
|
-
export type MetarFlightCategory = MetarIcaoFlightCategory | "MVFR" | "LIFR";
|
|
43
|
-
export interface Metar {
|
|
44
|
-
raw_text: string;
|
|
45
|
-
raw_parts: string[];
|
|
46
|
-
icao: string;
|
|
47
|
-
observed: Date;
|
|
48
|
-
forecastFrom: Date | null;
|
|
49
|
-
forecastTo: Date | null;
|
|
50
|
-
wind: MetarWind;
|
|
51
|
-
visibility: MetarVisibility;
|
|
52
|
-
conditions: MetarCode[];
|
|
53
|
-
clouds: MetarCloud[];
|
|
54
|
-
ceiling: MetarCeiling;
|
|
55
|
-
temperature: MetarTemperature;
|
|
56
|
-
dewpoint: MetarTemperature;
|
|
57
|
-
humidity: MetarHumidity;
|
|
58
|
-
barometer: MetarPressure;
|
|
59
|
-
flight_category: MetarFlightCategory | null;
|
|
60
|
-
icao_flight_category: MetarIcaoFlightCategory | null;
|
|
61
|
-
}
|
|
1
|
+
import type { Metar } from "./metar-parser.type.js";
|
|
62
2
|
/**
|
|
63
3
|
* Convert METAR string into structured object.
|
|
64
4
|
* @see https://api.checkwx.com/#31-single
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metar-parser.d.ts","sourceRoot":"","sources":["../src/metar-parser.ts"],"names":[],"mappings":"AAEA,
|
|
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,KAuFjD,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export interface MetarCode {
|
|
2
|
+
code: string;
|
|
3
|
+
}
|
|
4
|
+
export interface MetarWind {
|
|
5
|
+
degrees: number | null;
|
|
6
|
+
speed_kts: number | null;
|
|
7
|
+
speed_mps: number | null;
|
|
8
|
+
gust_kts: number | null;
|
|
9
|
+
gust_mps: number | null;
|
|
10
|
+
degrees_from: number | null;
|
|
11
|
+
degrees_to: number | null;
|
|
12
|
+
}
|
|
13
|
+
export interface MetarVisibility {
|
|
14
|
+
miles: number;
|
|
15
|
+
miles_text: string;
|
|
16
|
+
meters: number;
|
|
17
|
+
meters_text: string;
|
|
18
|
+
}
|
|
19
|
+
export type MetarCloudCode = "FEW" | "SCT" | "BKN" | "OVC" | "VV";
|
|
20
|
+
export interface MetarCloud {
|
|
21
|
+
code: MetarCloudCode;
|
|
22
|
+
feet: number;
|
|
23
|
+
meters: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Ceiling values of lowest cloud layer reporting `BKN` or `OVC`.
|
|
27
|
+
* Values will be `null` if no such layer was found.
|
|
28
|
+
*/
|
|
29
|
+
export interface MetarCeiling {
|
|
30
|
+
/**
|
|
31
|
+
* Ceiling in feet of lowest cloud layer reporting `BKN` or `OVC`.
|
|
32
|
+
* Ceiling in feet will be `null` if no such layer was found.
|
|
33
|
+
*/
|
|
34
|
+
feet: number;
|
|
35
|
+
/**
|
|
36
|
+
* Ceiling in meters of lowest cloud layer reporting `BKN` or `OVC`.
|
|
37
|
+
* Ceiling in meters will be `null` if no such layer was found.
|
|
38
|
+
*/
|
|
39
|
+
meters: number;
|
|
40
|
+
}
|
|
41
|
+
export interface MetarTemperature {
|
|
42
|
+
celsius: number;
|
|
43
|
+
fahrenheit: number;
|
|
44
|
+
}
|
|
45
|
+
export interface MetarHumidity {
|
|
46
|
+
percent: number | null;
|
|
47
|
+
}
|
|
48
|
+
export interface MetarPressure {
|
|
49
|
+
hg: number | null;
|
|
50
|
+
kpa: number | null;
|
|
51
|
+
mb: number | null;
|
|
52
|
+
}
|
|
53
|
+
export type MetarIcaoFlightCategory = "VFR" | "IFR";
|
|
54
|
+
export type MetarFlightCategory = MetarIcaoFlightCategory | "MVFR" | "LIFR";
|
|
55
|
+
export interface Metar {
|
|
56
|
+
raw_text: string;
|
|
57
|
+
raw_parts: string[];
|
|
58
|
+
icao: string;
|
|
59
|
+
observed: Date;
|
|
60
|
+
forecastFrom: Date | null;
|
|
61
|
+
forecastTo: Date | null;
|
|
62
|
+
wind: MetarWind;
|
|
63
|
+
visibility: MetarVisibility | null;
|
|
64
|
+
conditions: MetarCode[];
|
|
65
|
+
clouds: MetarCloud[];
|
|
66
|
+
ceiling: MetarCeiling | null;
|
|
67
|
+
temperature: MetarTemperature | null;
|
|
68
|
+
dewpoint: MetarTemperature | null;
|
|
69
|
+
humidity: MetarHumidity;
|
|
70
|
+
barometer: MetarPressure;
|
|
71
|
+
flight_category: MetarFlightCategory | null;
|
|
72
|
+
icao_flight_category: MetarIcaoFlightCategory | null;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=metar-parser.type.d.ts.map
|
|
@@ -0,0 +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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