metar-taf-parser 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +85 -12
  2. package/dist/command/common.js +13 -10
  3. package/dist/command/metar/AltimeterCommand.d.ts +7 -0
  4. package/dist/command/metar/AltimeterCommand.js +26 -0
  5. package/dist/command/metar/AltimeterMercuryCommand.d.ts +7 -0
  6. package/dist/command/metar/AltimeterMercuryCommand.js +51 -0
  7. package/dist/command/metar/RunwayCommand.d.ts +7 -0
  8. package/dist/command/metar/RunwayCommand.js +60 -0
  9. package/dist/command/metar/TemperatureCommand.d.ts +7 -0
  10. package/dist/command/metar/TemperatureCommand.js +51 -0
  11. package/dist/command/metar.d.ts +1 -22
  12. package/dist/command/metar.js +10 -113
  13. package/dist/command/remark/CeilingHeightCommand.d.ts +18 -0
  14. package/dist/command/remark/CeilingHeightCommand.js +40 -0
  15. package/dist/command/remark/CeilingSecondLocationCommand.d.ts +12 -0
  16. package/dist/command/remark/CeilingSecondLocationCommand.js +40 -0
  17. package/dist/command/remark/Command.d.ts +8 -0
  18. package/dist/command/remark/Command.js +9 -0
  19. package/dist/command/remark/DefaultCommand.d.ts +11 -0
  20. package/dist/command/remark/DefaultCommand.js +38 -0
  21. package/dist/command/remark/HailSizeCommand.d.ts +11 -0
  22. package/dist/command/remark/HailSizeCommand.js +37 -0
  23. package/dist/command/remark/HourlyMaximumMinimumTemperatureCommand.d.ts +18 -0
  24. package/dist/command/remark/HourlyMaximumMinimumTemperatureCommand.js +39 -0
  25. package/dist/command/remark/HourlyMaximumTemperatureCommand.d.ts +14 -0
  26. package/dist/command/remark/HourlyMaximumTemperatureCommand.js +38 -0
  27. package/dist/command/remark/HourlyMinimumTemperatureCommand.d.ts +14 -0
  28. package/dist/command/remark/HourlyMinimumTemperatureCommand.js +38 -0
  29. package/dist/command/remark/HourlyPrecipitationAmountCommand.d.ts +14 -0
  30. package/dist/command/remark/HourlyPrecipitationAmountCommand.js +38 -0
  31. package/dist/command/remark/HourlyPressureCommand.d.ts +32 -0
  32. package/dist/command/remark/HourlyPressureCommand.js +40 -0
  33. package/dist/command/remark/HourlyTemperatureDewPointCommand.d.ts +18 -0
  34. package/dist/command/remark/HourlyTemperatureDewPointCommand.js +52 -0
  35. package/dist/command/remark/IceAccretionCommand.d.ts +15 -0
  36. package/dist/command/remark/IceAccretionCommand.js +38 -0
  37. package/dist/command/remark/ObscurationCommand.d.ts +14 -0
  38. package/dist/command/remark/ObscurationCommand.js +44 -0
  39. package/dist/command/remark/PrecipitationAmount24HourCommand.d.ts +14 -0
  40. package/dist/command/remark/PrecipitationAmount24HourCommand.js +39 -0
  41. package/dist/command/remark/PrecipitationAmount36HourCommand.d.ts +15 -0
  42. package/dist/command/remark/PrecipitationAmount36HourCommand.js +41 -0
  43. package/dist/command/remark/PrecipitationBegCommand.d.ts +15 -0
  44. package/dist/command/remark/PrecipitationBegCommand.js +45 -0
  45. package/dist/command/remark/PrecipitationBegEndCommand.d.ts +17 -0
  46. package/dist/command/remark/PrecipitationBegEndCommand.js +46 -0
  47. package/dist/command/remark/PrecipitationEndCommand.d.ts +15 -0
  48. package/dist/command/remark/PrecipitationEndCommand.js +45 -0
  49. package/dist/command/remark/PrevailingVisibilityCommand.d.ts +12 -0
  50. package/dist/command/remark/PrevailingVisibilityCommand.js +40 -0
  51. package/dist/command/remark/SeaLevelPressureCommand.d.ts +11 -0
  52. package/dist/command/remark/SeaLevelPressureCommand.js +39 -0
  53. package/dist/command/remark/SecondLocationVisibilityCommand.d.ts +12 -0
  54. package/dist/command/remark/SecondLocationVisibilityCommand.js +40 -0
  55. package/dist/command/remark/SectorVisibilityCommand.d.ts +13 -0
  56. package/dist/command/remark/SectorVisibilityCommand.js +41 -0
  57. package/dist/command/remark/SmallHailSizeCommand.d.ts +11 -0
  58. package/dist/command/remark/SmallHailSizeCommand.js +37 -0
  59. package/dist/command/remark/SnowDepthCommand.d.ts +11 -0
  60. package/dist/command/remark/SnowDepthCommand.js +38 -0
  61. package/dist/command/remark/SnowIncreaseCommand.d.ts +12 -0
  62. package/dist/command/remark/SnowIncreaseCommand.js +40 -0
  63. package/dist/command/remark/SnowPelletsCommand.d.ts +11 -0
  64. package/dist/command/remark/SnowPelletsCommand.js +37 -0
  65. package/dist/command/remark/SunshineDurationCommand.d.ts +11 -0
  66. package/dist/command/remark/SunshineDurationCommand.js +38 -0
  67. package/dist/command/remark/SurfaceVisibilityCommand.d.ts +11 -0
  68. package/dist/command/remark/SurfaceVisibilityCommand.js +38 -0
  69. package/dist/command/remark/ThunderStormLocationCommand.d.ts +12 -0
  70. package/dist/command/remark/ThunderStormLocationCommand.js +40 -0
  71. package/dist/command/remark/ThunderStormLocationMovingCommand.d.ts +19 -0
  72. package/dist/command/remark/ThunderStormLocationMovingCommand.js +42 -0
  73. package/dist/command/remark/TornadicActivityBegCommand.d.ts +16 -0
  74. package/dist/command/remark/TornadicActivityBegCommand.js +44 -0
  75. package/dist/command/remark/TornadicActivityBegEndCommand.d.ts +18 -0
  76. package/dist/command/remark/TornadicActivityBegEndCommand.js +46 -0
  77. package/dist/command/remark/TornadicActivityEndCommand.d.ts +16 -0
  78. package/dist/command/remark/TornadicActivityEndCommand.js +44 -0
  79. package/dist/command/remark/TowerVisibilityCommand.d.ts +11 -0
  80. package/dist/command/remark/TowerVisibilityCommand.js +38 -0
  81. package/dist/command/remark/VariableSkyCommand.d.ts +12 -0
  82. package/dist/command/remark/VariableSkyCommand.js +41 -0
  83. package/dist/command/remark/VariableSkyHeightCommand.d.ts +13 -0
  84. package/dist/command/remark/VariableSkyHeightCommand.js +43 -0
  85. package/dist/command/remark/VirgaDirectionCommand.d.ts +12 -0
  86. package/dist/command/remark/VirgaDirectionCommand.js +40 -0
  87. package/dist/command/remark/WaterEquivalentSnowCommand.d.ts +11 -0
  88. package/dist/command/remark/WaterEquivalentSnowCommand.js +38 -0
  89. package/dist/command/remark/WindPeakCommandCommand.d.ts +17 -0
  90. package/dist/command/remark/WindPeakCommandCommand.js +42 -0
  91. package/dist/command/remark/WindShiftCommand.d.ts +12 -0
  92. package/dist/command/remark/WindShiftCommand.js +38 -0
  93. package/dist/command/remark/WindShiftFropaCommand.d.ts +12 -0
  94. package/dist/command/remark/WindShiftFropaCommand.js +38 -0
  95. package/dist/command/remark.d.ts +100 -194
  96. package/dist/command/remark.js +135 -753
  97. package/dist/commons/converter.d.ts +14 -2
  98. package/dist/commons/converter.js +53 -5
  99. package/dist/commons/errors.d.ts +6 -2
  100. package/dist/commons/errors.js +15 -8
  101. package/dist/commons/i18n.d.ts +2 -2
  102. package/dist/commons/i18n.js +9 -3
  103. package/dist/dates/metar.d.ts +5 -0
  104. package/dist/dates/metar.js +8 -0
  105. package/dist/dates/taf.d.ts +28 -0
  106. package/dist/dates/taf.js +17 -0
  107. package/dist/forecast/forecast.d.ts +36 -0
  108. package/dist/forecast/forecast.js +73 -0
  109. package/dist/helpers/date.d.ts +11 -0
  110. package/dist/helpers/date.js +56 -0
  111. package/dist/helpers/helpers.d.ts +7 -0
  112. package/dist/helpers/helpers.js +14 -1
  113. package/dist/index.d.ts +23 -2
  114. package/dist/index.js +24 -7
  115. package/dist/model/enum.d.ts +44 -0
  116. package/dist/model/enum.js +50 -1
  117. package/dist/model/model.d.ts +84 -19
  118. package/dist/model/model.js +3 -1
  119. package/dist/parser/parser.d.ts +13 -6
  120. package/dist/parser/parser.js +63 -29
  121. package/package.json +3 -3
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _CeilingSecondLocationCommand_regex;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.CeilingSecondLocationCommand = void 0;
10
+ const i18n_1 = require("../../commons/i18n");
11
+ const errors_1 = require("../../commons/errors");
12
+ const remark_1 = require("../remark");
13
+ const Command_1 = require("./Command");
14
+ class CeilingSecondLocationCommand extends Command_1.Command {
15
+ constructor() {
16
+ super(...arguments);
17
+ _CeilingSecondLocationCommand_regex.set(this, /^CIG (\d{3}) (\w+)\b/);
18
+ }
19
+ canParse(code) {
20
+ return __classPrivateFieldGet(this, _CeilingSecondLocationCommand_regex, "f").test(code);
21
+ }
22
+ execute(code, remark) {
23
+ const matches = code.match(__classPrivateFieldGet(this, _CeilingSecondLocationCommand_regex, "f"));
24
+ if (!matches)
25
+ throw new errors_1.UnexpectedParseError("Match not found");
26
+ const height = +matches[1] * 100;
27
+ const location = matches[2];
28
+ const description = (0, i18n_1.format)((0, i18n_1._)("Remark.Ceiling.Second.Location", this.locale), height, location);
29
+ remark.push({
30
+ type: remark_1.RemarkType.CeilingSecondLocation,
31
+ description,
32
+ raw: matches[0],
33
+ height,
34
+ location,
35
+ });
36
+ return [code.replace(__classPrivateFieldGet(this, _CeilingSecondLocationCommand_regex, "f"), "").trim(), remark];
37
+ }
38
+ }
39
+ exports.CeilingSecondLocationCommand = CeilingSecondLocationCommand;
40
+ _CeilingSecondLocationCommand_regex = new WeakMap();
@@ -0,0 +1,8 @@
1
+ import { Locale } from "../../commons/i18n";
2
+ import { Remark } from "../remark";
3
+ export declare abstract class Command {
4
+ protected locale: Locale;
5
+ constructor(locale: Locale);
6
+ abstract canParse(code: string): boolean;
7
+ abstract execute(code: string, remark: Remark[]): [string, Remark[]];
8
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Command = void 0;
4
+ class Command {
5
+ constructor(locale) {
6
+ this.locale = locale;
7
+ }
8
+ }
9
+ exports.Command = Command;
@@ -0,0 +1,11 @@
1
+ import { IBaseRemark, Remark, RemarkType } from "../remark";
2
+ import { Command } from "./Command";
3
+ declare type DefaultRemarkTypes = RemarkType.AO1 | RemarkType.AO2 | RemarkType.PRESFR | RemarkType.PRESRR | RemarkType.TORNADO | RemarkType.FUNNELCLOUD | RemarkType.WATERSPOUT | RemarkType.VIRGA;
4
+ export interface IDefaultCommandRemark extends IBaseRemark {
5
+ type: DefaultRemarkTypes;
6
+ }
7
+ export declare class DefaultCommand extends Command {
8
+ canParse(): boolean;
9
+ execute(code: string, remark: Remark[]): [string, Remark[]];
10
+ }
11
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultCommand = void 0;
4
+ const helpers_1 = require("../../helpers/helpers");
5
+ const i18n_1 = require("../../commons/i18n");
6
+ const remark_1 = require("../remark");
7
+ const Command_1 = require("./Command");
8
+ class DefaultCommand extends Command_1.Command {
9
+ canParse() {
10
+ return true;
11
+ }
12
+ execute(code, remark) {
13
+ const rmkSplit = (0, helpers_1.pySplit)(code, " ", 1);
14
+ const rem = (0, i18n_1._)(`Remark.${rmkSplit[0]}`, this.locale);
15
+ if (remark_1.RemarkType[rmkSplit[0]]) {
16
+ remark.push({
17
+ type: rmkSplit[0],
18
+ description: rem,
19
+ raw: rmkSplit[0],
20
+ });
21
+ }
22
+ else {
23
+ const lastRemark = remark[remark.length - 1];
24
+ if ((lastRemark === null || lastRemark === void 0 ? void 0 : lastRemark.type) === remark_1.RemarkType.Unknown) {
25
+ // Merge with last unknown value
26
+ lastRemark.raw = `${lastRemark.raw} ${rmkSplit[0]}`;
27
+ }
28
+ else {
29
+ remark.push({
30
+ type: remark_1.RemarkType.Unknown,
31
+ raw: rmkSplit[0],
32
+ });
33
+ }
34
+ }
35
+ return [rmkSplit.length === 1 ? "" : rmkSplit[1], remark];
36
+ }
37
+ }
38
+ exports.DefaultCommand = DefaultCommand;
@@ -0,0 +1,11 @@
1
+ import { IBaseRemark, RemarkType, Remark } from "../remark";
2
+ import { Command } from "./Command";
3
+ export interface IHailSizeRemark extends IBaseRemark {
4
+ type: RemarkType.HailSize;
5
+ size: string;
6
+ }
7
+ export declare class HailSizeCommand extends Command {
8
+ #private;
9
+ canParse(code: string): boolean;
10
+ execute(code: string, remark: Remark[]): [string, Remark[]];
11
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _HailSizeCommand_regex;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.HailSizeCommand = void 0;
10
+ const i18n_1 = require("../../commons/i18n");
11
+ const errors_1 = require("../../commons/errors");
12
+ const remark_1 = require("../remark");
13
+ const Command_1 = require("./Command");
14
+ class HailSizeCommand extends Command_1.Command {
15
+ constructor() {
16
+ super(...arguments);
17
+ _HailSizeCommand_regex.set(this, /^GR ((\d\/\d)|((\d) ?(\d\/\d)?))/);
18
+ }
19
+ canParse(code) {
20
+ return __classPrivateFieldGet(this, _HailSizeCommand_regex, "f").test(code);
21
+ }
22
+ execute(code, remark) {
23
+ const matches = code.match(__classPrivateFieldGet(this, _HailSizeCommand_regex, "f"));
24
+ if (!matches)
25
+ throw new errors_1.UnexpectedParseError("Match not found");
26
+ const description = (0, i18n_1.format)((0, i18n_1._)("Remark.Hail.0", this.locale), matches[1]);
27
+ remark.push({
28
+ type: remark_1.RemarkType.HailSize,
29
+ description,
30
+ raw: matches[0],
31
+ size: matches[1],
32
+ });
33
+ return [code.replace(__classPrivateFieldGet(this, _HailSizeCommand_regex, "f"), "").trim(), remark];
34
+ }
35
+ }
36
+ exports.HailSizeCommand = HailSizeCommand;
37
+ _HailSizeCommand_regex = new WeakMap();
@@ -0,0 +1,18 @@
1
+ import { IBaseRemark, RemarkType, Remark } from "../remark";
2
+ import { Command } from "./Command";
3
+ export interface IHourlyMaximumMinimumTemperatureRemark extends IBaseRemark {
4
+ type: RemarkType.HourlyMaximumMinimumTemperature;
5
+ /**
6
+ * Maximum temperature in C
7
+ */
8
+ max: number;
9
+ /**
10
+ * Minimum temperature in C
11
+ */
12
+ min: number;
13
+ }
14
+ export declare class HourlyMaximumMinimumTemperatureCommand extends Command {
15
+ #private;
16
+ canParse(code: string): boolean;
17
+ execute(code: string, remark: Remark[]): [string, Remark[]];
18
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _HourlyMaximumMinimumTemperatureCommand_regex;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.HourlyMaximumMinimumTemperatureCommand = void 0;
10
+ const converter_1 = require("../../commons/converter");
11
+ const i18n_1 = require("../../commons/i18n");
12
+ const errors_1 = require("../../commons/errors");
13
+ const remark_1 = require("../remark");
14
+ const Command_1 = require("./Command");
15
+ class HourlyMaximumMinimumTemperatureCommand extends Command_1.Command {
16
+ constructor() {
17
+ super(...arguments);
18
+ _HourlyMaximumMinimumTemperatureCommand_regex.set(this, /^4([01])(\d{3})([01])(\d{3})\b/);
19
+ }
20
+ canParse(code) {
21
+ return __classPrivateFieldGet(this, _HourlyMaximumMinimumTemperatureCommand_regex, "f").test(code);
22
+ }
23
+ execute(code, remark) {
24
+ const matches = code.match(__classPrivateFieldGet(this, _HourlyMaximumMinimumTemperatureCommand_regex, "f"));
25
+ if (!matches)
26
+ throw new errors_1.UnexpectedParseError("Match not found");
27
+ const description = (0, i18n_1.format)((0, i18n_1._)("Remark.Hourly.Maximum.Minimum.Temperature", this.locale), (0, converter_1.convertTemperatureRemarks)(matches[1], matches[2]).toFixed(1), (0, converter_1.convertTemperatureRemarks)(matches[3], matches[4]).toFixed(1));
28
+ remark.push({
29
+ type: remark_1.RemarkType.HourlyMaximumMinimumTemperature,
30
+ description: description,
31
+ raw: matches[0],
32
+ max: (0, converter_1.convertTemperatureRemarks)(matches[1], matches[2]),
33
+ min: (0, converter_1.convertTemperatureRemarks)(matches[3], matches[4]),
34
+ });
35
+ return [code.replace(__classPrivateFieldGet(this, _HourlyMaximumMinimumTemperatureCommand_regex, "f"), "").trim(), remark];
36
+ }
37
+ }
38
+ exports.HourlyMaximumMinimumTemperatureCommand = HourlyMaximumMinimumTemperatureCommand;
39
+ _HourlyMaximumMinimumTemperatureCommand_regex = new WeakMap();
@@ -0,0 +1,14 @@
1
+ import { IBaseRemark, RemarkType, Remark } from "../remark";
2
+ import { Command } from "./Command";
3
+ export interface IHourlyMaximumTemperatureRemark extends IBaseRemark {
4
+ type: RemarkType.HourlyMaximumTemperature;
5
+ /**
6
+ * Maximum temperature in C
7
+ */
8
+ max: number;
9
+ }
10
+ export declare class HourlyMaximumTemperatureCommand extends Command {
11
+ #private;
12
+ canParse(code: string): boolean;
13
+ execute(code: string, remark: Remark[]): [string, Remark[]];
14
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _HourlyMaximumTemperatureCommand_regex;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.HourlyMaximumTemperatureCommand = void 0;
10
+ const converter_1 = require("../../commons/converter");
11
+ const i18n_1 = require("../../commons/i18n");
12
+ const errors_1 = require("../../commons/errors");
13
+ const remark_1 = require("../remark");
14
+ const Command_1 = require("./Command");
15
+ class HourlyMaximumTemperatureCommand extends Command_1.Command {
16
+ constructor() {
17
+ super(...arguments);
18
+ _HourlyMaximumTemperatureCommand_regex.set(this, /^1([01])(\d{3})\b/);
19
+ }
20
+ canParse(code) {
21
+ return __classPrivateFieldGet(this, _HourlyMaximumTemperatureCommand_regex, "f").test(code);
22
+ }
23
+ execute(code, remark) {
24
+ const matches = code.match(__classPrivateFieldGet(this, _HourlyMaximumTemperatureCommand_regex, "f"));
25
+ if (!matches)
26
+ throw new errors_1.UnexpectedParseError("Match not found");
27
+ const description = (0, i18n_1.format)((0, i18n_1._)("Remark.Hourly.Maximum.Temperature", this.locale), (0, converter_1.convertTemperatureRemarks)(matches[1], matches[2]).toFixed(1));
28
+ remark.push({
29
+ type: remark_1.RemarkType.HourlyMaximumTemperature,
30
+ description: description,
31
+ raw: matches[0],
32
+ max: (0, converter_1.convertTemperatureRemarks)(matches[1], matches[2]),
33
+ });
34
+ return [code.replace(__classPrivateFieldGet(this, _HourlyMaximumTemperatureCommand_regex, "f"), "").trim(), remark];
35
+ }
36
+ }
37
+ exports.HourlyMaximumTemperatureCommand = HourlyMaximumTemperatureCommand;
38
+ _HourlyMaximumTemperatureCommand_regex = new WeakMap();
@@ -0,0 +1,14 @@
1
+ import { IBaseRemark, RemarkType, Remark } from "../remark";
2
+ import { Command } from "./Command";
3
+ export interface IHourlyMinimumTemperatureRemark extends IBaseRemark {
4
+ type: RemarkType.HourlyMinimumTemperature;
5
+ /**
6
+ * Minimum temperature in C
7
+ */
8
+ min: number;
9
+ }
10
+ export declare class HourlyMinimumTemperatureCommand extends Command {
11
+ #private;
12
+ canParse(code: string): boolean;
13
+ execute(code: string, remark: Remark[]): [string, Remark[]];
14
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _HourlyMinimumTemperatureCommand_regex;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.HourlyMinimumTemperatureCommand = void 0;
10
+ const converter_1 = require("../../commons/converter");
11
+ const i18n_1 = require("../../commons/i18n");
12
+ const errors_1 = require("../../commons/errors");
13
+ const remark_1 = require("../remark");
14
+ const Command_1 = require("./Command");
15
+ class HourlyMinimumTemperatureCommand extends Command_1.Command {
16
+ constructor() {
17
+ super(...arguments);
18
+ _HourlyMinimumTemperatureCommand_regex.set(this, /^2([01])(\d{3})\b/);
19
+ }
20
+ canParse(code) {
21
+ return __classPrivateFieldGet(this, _HourlyMinimumTemperatureCommand_regex, "f").test(code);
22
+ }
23
+ execute(code, remark) {
24
+ const matches = code.match(__classPrivateFieldGet(this, _HourlyMinimumTemperatureCommand_regex, "f"));
25
+ if (!matches)
26
+ throw new errors_1.UnexpectedParseError("Match not found");
27
+ const description = (0, i18n_1.format)((0, i18n_1._)("Remark.Hourly.Minimum.Temperature", this.locale), (0, converter_1.convertTemperatureRemarks)(matches[1], matches[2]).toFixed(1));
28
+ remark.push({
29
+ type: remark_1.RemarkType.HourlyMinimumTemperature,
30
+ description,
31
+ raw: matches[0],
32
+ min: (0, converter_1.convertTemperatureRemarks)(matches[1], matches[2]),
33
+ });
34
+ return [code.replace(__classPrivateFieldGet(this, _HourlyMinimumTemperatureCommand_regex, "f"), "").trim(), remark];
35
+ }
36
+ }
37
+ exports.HourlyMinimumTemperatureCommand = HourlyMinimumTemperatureCommand;
38
+ _HourlyMinimumTemperatureCommand_regex = new WeakMap();
@@ -0,0 +1,14 @@
1
+ import { IBaseRemark, RemarkType, Remark } from "../remark";
2
+ import { Command } from "./Command";
3
+ export interface IHourlyPrecipitationAmountRemark extends IBaseRemark {
4
+ type: RemarkType.HourlyPrecipitationAmount;
5
+ /**
6
+ * In inches
7
+ */
8
+ amount: number;
9
+ }
10
+ export declare class HourlyPrecipitationAmountCommand extends Command {
11
+ #private;
12
+ canParse(code: string): boolean;
13
+ execute(code: string, remark: Remark[]): [string, Remark[]];
14
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _HourlyPrecipitationAmountCommand_regex;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.HourlyPrecipitationAmountCommand = void 0;
10
+ const i18n_1 = require("../../commons/i18n");
11
+ const errors_1 = require("../../commons/errors");
12
+ const remark_1 = require("../remark");
13
+ const Command_1 = require("./Command");
14
+ class HourlyPrecipitationAmountCommand extends Command_1.Command {
15
+ constructor() {
16
+ super(...arguments);
17
+ _HourlyPrecipitationAmountCommand_regex.set(this, /^P(\d{4})\b/);
18
+ }
19
+ canParse(code) {
20
+ return __classPrivateFieldGet(this, _HourlyPrecipitationAmountCommand_regex, "f").test(code);
21
+ }
22
+ execute(code, remark) {
23
+ const matches = code.match(__classPrivateFieldGet(this, _HourlyPrecipitationAmountCommand_regex, "f"));
24
+ if (!matches)
25
+ throw new errors_1.UnexpectedParseError("Match not found");
26
+ const amount = +matches[1];
27
+ const description = (0, i18n_1.format)((0, i18n_1._)("Remark.Precipitation.Amount.Hourly", this.locale), amount);
28
+ remark.push({
29
+ type: remark_1.RemarkType.HourlyPrecipitationAmount,
30
+ description,
31
+ raw: matches[0],
32
+ amount: amount / 100,
33
+ });
34
+ return [code.replace(__classPrivateFieldGet(this, _HourlyPrecipitationAmountCommand_regex, "f"), "").trim(), remark];
35
+ }
36
+ }
37
+ exports.HourlyPrecipitationAmountCommand = HourlyPrecipitationAmountCommand;
38
+ _HourlyPrecipitationAmountCommand_regex = new WeakMap();
@@ -0,0 +1,32 @@
1
+ import { IBaseRemark, RemarkType, Remark } from "../remark";
2
+ import { Command } from "./Command";
3
+ export interface IHourlyPressureRemark extends IBaseRemark {
4
+ type: RemarkType.HourlyPressure;
5
+ /**
6
+ * https://www.e-education.psu.edu/files/meteo101/image/Section13/metar_decoding1203.html
7
+ *
8
+ * | Code Figure | Description | Primary Requirement |
9
+ * |:-----------:|:----------------------------------------------------------------------------------:|:-----------------------------------------------------------------:|
10
+ * | 0 | Increasing, then decreasing. | Atmospheric pressure now higher than 3 hours ago. (x3 rows below) |
11
+ * | 1 | Increasing, then steady, or increasing then increasing more slowly. | |
12
+ * | 2 | Increasing steadily or unsteadily. | |
13
+ * | 3 | Decreasing or steady, then increasing; or increasing then increasing more rapidly. | |
14
+ * | 0 | Increasing, then decreasing. | Atmospheric pressure now same as 3 hours ago. (x3 rows below) |
15
+ * | 4 | Steady | |
16
+ * | 5 | Decreasing then increasing. | |
17
+ * | 5 | Decreasing, then increasing. | Atmospheric pressure now lower than 3 hours ago. (x3 rows below) |
18
+ * | 6 | Decreasing, then steady, or decreasing then decreasing more slowly. | |
19
+ * | 7 | Decreasing steadily or unsteadily. | |
20
+ * | 8 | Steady or increasing, then decreasing; or decreasing then decreasing more rapidly. | |
21
+ */
22
+ code: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
23
+ /**
24
+ * In hectopascals
25
+ */
26
+ pressureChange: number;
27
+ }
28
+ export declare class HourlyPressureCommand extends Command {
29
+ #private;
30
+ canParse(code: string): boolean;
31
+ execute(code: string, remark: Remark[]): [string, Remark[]];
32
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _HourlyPressureCommand_regex;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.HourlyPressureCommand = void 0;
10
+ const i18n_1 = require("../../commons/i18n");
11
+ const errors_1 = require("../../commons/errors");
12
+ const remark_1 = require("../remark");
13
+ const Command_1 = require("./Command");
14
+ class HourlyPressureCommand extends Command_1.Command {
15
+ constructor() {
16
+ super(...arguments);
17
+ _HourlyPressureCommand_regex.set(this, /^5(\d)(\d{3})\b/);
18
+ }
19
+ canParse(code) {
20
+ return __classPrivateFieldGet(this, _HourlyPressureCommand_regex, "f").test(code);
21
+ }
22
+ execute(code, remark) {
23
+ const matches = code.match(__classPrivateFieldGet(this, _HourlyPressureCommand_regex, "f"));
24
+ if (!matches)
25
+ throw new errors_1.UnexpectedParseError("Match not found");
26
+ const part1 = (0, i18n_1._)(`Remark.Barometer.${+matches[1]}`, this.locale);
27
+ const part2 = (0, i18n_1.format)((0, i18n_1._)("Remark.Pressure.Tendency", this.locale), +matches[2] / 10);
28
+ const description = part1 != null && part2 != null ? `${part1} ${part2}` : undefined;
29
+ remark.push({
30
+ type: remark_1.RemarkType.HourlyPressure,
31
+ description,
32
+ raw: matches[0],
33
+ code: +matches[1],
34
+ pressureChange: +matches[2] / 10,
35
+ });
36
+ return [code.replace(__classPrivateFieldGet(this, _HourlyPressureCommand_regex, "f"), "").trim(), remark];
37
+ }
38
+ }
39
+ exports.HourlyPressureCommand = HourlyPressureCommand;
40
+ _HourlyPressureCommand_regex = new WeakMap();
@@ -0,0 +1,18 @@
1
+ import { IBaseRemark, RemarkType, Remark } from "../remark";
2
+ import { Command } from "./Command";
3
+ export interface IHourlyTemperatureDewPointRemark extends IBaseRemark {
4
+ type: RemarkType.HourlyTemperatureDewPoint;
5
+ /**
6
+ * In C
7
+ */
8
+ temperature: number;
9
+ /**
10
+ * In C
11
+ */
12
+ dewPoint?: number;
13
+ }
14
+ export declare class HourlyTemperatureDewPointCommand extends Command {
15
+ #private;
16
+ canParse(code: string): boolean;
17
+ execute(code: string, remark: Remark[]): [string, Remark[]];
18
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _HourlyTemperatureDewPointCommand_regex;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.HourlyTemperatureDewPointCommand = void 0;
10
+ const converter_1 = require("../../commons/converter");
11
+ const i18n_1 = require("../../commons/i18n");
12
+ const errors_1 = require("../../commons/errors");
13
+ const remark_1 = require("../remark");
14
+ const Command_1 = require("./Command");
15
+ class HourlyTemperatureDewPointCommand extends Command_1.Command {
16
+ constructor() {
17
+ super(...arguments);
18
+ _HourlyTemperatureDewPointCommand_regex.set(this, /^T([01])(\d{3})(([01])(\d{3}))?/);
19
+ }
20
+ canParse(code) {
21
+ return __classPrivateFieldGet(this, _HourlyTemperatureDewPointCommand_regex, "f").test(code);
22
+ }
23
+ execute(code, remark) {
24
+ const matches = code.match(__classPrivateFieldGet(this, _HourlyTemperatureDewPointCommand_regex, "f"));
25
+ if (!matches)
26
+ throw new errors_1.UnexpectedParseError("Match not found");
27
+ const temperature = (0, converter_1.convertTemperatureRemarks)(matches[1], matches[2]);
28
+ if (!matches[3]) {
29
+ const description = (0, i18n_1.format)((0, i18n_1._)("Remark.Hourly.Temperature.0", this.locale), temperature.toFixed(1));
30
+ remark.push({
31
+ type: remark_1.RemarkType.HourlyTemperatureDewPoint,
32
+ description,
33
+ raw: matches[0],
34
+ temperature,
35
+ });
36
+ }
37
+ else {
38
+ const dewPoint = (0, converter_1.convertTemperatureRemarks)(matches[4], matches[5]);
39
+ const description = (0, i18n_1.format)((0, i18n_1._)("Remark.Hourly.Temperature.Dew.Point", this.locale), temperature.toFixed(1), dewPoint.toFixed(1));
40
+ remark.push({
41
+ type: remark_1.RemarkType.HourlyTemperatureDewPoint,
42
+ description,
43
+ raw: matches[0],
44
+ temperature,
45
+ dewPoint,
46
+ });
47
+ }
48
+ return [code.replace(__classPrivateFieldGet(this, _HourlyTemperatureDewPointCommand_regex, "f"), "").trim(), remark];
49
+ }
50
+ }
51
+ exports.HourlyTemperatureDewPointCommand = HourlyTemperatureDewPointCommand;
52
+ _HourlyTemperatureDewPointCommand_regex = new WeakMap();
@@ -0,0 +1,15 @@
1
+ import { IBaseRemark, RemarkType, Remark } from "../remark";
2
+ import { Command } from "./Command";
3
+ export interface IIceAccretionRemark extends IBaseRemark {
4
+ type: RemarkType.IceAccretion;
5
+ /**
6
+ * In inches
7
+ */
8
+ amount: number;
9
+ periodInHours: number;
10
+ }
11
+ export declare class IceAccretionCommand extends Command {
12
+ #private;
13
+ canParse(code: string): boolean;
14
+ execute(code: string, remark: Remark[]): [string, Remark[]];
15
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _IceAccretionCommand_regex;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.IceAccretionCommand = void 0;
10
+ const i18n_1 = require("../../commons/i18n");
11
+ const errors_1 = require("../../commons/errors");
12
+ const remark_1 = require("../remark");
13
+ const Command_1 = require("./Command");
14
+ class IceAccretionCommand extends Command_1.Command {
15
+ constructor() {
16
+ super(...arguments);
17
+ _IceAccretionCommand_regex.set(this, /^l(\d)(\d{3})\b/);
18
+ }
19
+ canParse(code) {
20
+ return __classPrivateFieldGet(this, _IceAccretionCommand_regex, "f").test(code);
21
+ }
22
+ execute(code, remark) {
23
+ const matches = code.match(__classPrivateFieldGet(this, _IceAccretionCommand_regex, "f"));
24
+ if (!matches)
25
+ throw new errors_1.UnexpectedParseError("Match not found");
26
+ const description = (0, i18n_1.format)((0, i18n_1._)("Remark.Ice.Accretion.Amount", this.locale), +matches[2], +matches[1]);
27
+ remark.push({
28
+ type: remark_1.RemarkType.IceAccretion,
29
+ description,
30
+ raw: matches[0],
31
+ amount: +matches[2] / 100,
32
+ periodInHours: +matches[1],
33
+ });
34
+ return [code.replace(__classPrivateFieldGet(this, _IceAccretionCommand_regex, "f"), "").trim(), remark];
35
+ }
36
+ }
37
+ exports.IceAccretionCommand = IceAccretionCommand;
38
+ _IceAccretionCommand_regex = new WeakMap();
@@ -0,0 +1,14 @@
1
+ import { CloudQuantity, Phenomenon } from "../../model/enum";
2
+ import { IBaseRemark, RemarkType, Remark } from "../remark";
3
+ import { Command } from "./Command";
4
+ export interface IObscurationRemark extends IBaseRemark {
5
+ type: RemarkType.Obscuration;
6
+ quantity: CloudQuantity;
7
+ height: number;
8
+ phenomenon: Phenomenon;
9
+ }
10
+ export declare class ObscurationCommand extends Command {
11
+ #private;
12
+ canParse(code: string): boolean;
13
+ execute(code: string, remark: Remark[]): [string, Remark[]];
14
+ }