metar-taf-parser 3.1.2 → 4.0.2

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 (136) hide show
  1. package/README.md +1 -1
  2. package/{dist/locale → locale}/de.d.ts +0 -0
  3. package/{dist/locale → locale}/de.js +3 -3
  4. package/{dist/locale → locale}/en.d.ts +0 -0
  5. package/{dist/locale → locale}/en.js +3 -3
  6. package/{dist/locale → locale}/fr.d.ts +0 -0
  7. package/{dist/locale → locale}/fr.js +3 -3
  8. package/{dist/locale → locale}/it.d.ts +0 -0
  9. package/{dist/locale → locale}/it.js +3 -3
  10. package/{dist/locale → locale}/pl.d.ts +0 -0
  11. package/{dist/locale → locale}/pl.js +3 -3
  12. package/{dist/locale → locale}/zh-CN.d.ts +0 -0
  13. package/{dist/locale → locale}/zh-CN.js +3 -3
  14. package/metar-taf-parser.d.ts +1325 -0
  15. package/metar-taf-parser.js +2703 -0
  16. package/package.json +23 -16
  17. package/dist/command/common.d.ts +0 -54
  18. package/dist/command/common.js +0 -243
  19. package/dist/command/metar/AltimeterCommand.d.ts +0 -7
  20. package/dist/command/metar/AltimeterCommand.js +0 -26
  21. package/dist/command/metar/AltimeterMercuryCommand.d.ts +0 -7
  22. package/dist/command/metar/AltimeterMercuryCommand.js +0 -51
  23. package/dist/command/metar/RunwayCommand.d.ts +0 -7
  24. package/dist/command/metar/RunwayCommand.js +0 -60
  25. package/dist/command/metar/TemperatureCommand.d.ts +0 -7
  26. package/dist/command/metar/TemperatureCommand.js +0 -51
  27. package/dist/command/metar.d.ts +0 -9
  28. package/dist/command/metar.js +0 -31
  29. package/dist/command/remark/CeilingHeightCommand.d.ts +0 -18
  30. package/dist/command/remark/CeilingHeightCommand.js +0 -40
  31. package/dist/command/remark/CeilingSecondLocationCommand.d.ts +0 -12
  32. package/dist/command/remark/CeilingSecondLocationCommand.js +0 -40
  33. package/dist/command/remark/Command.d.ts +0 -8
  34. package/dist/command/remark/Command.js +0 -9
  35. package/dist/command/remark/DefaultCommand.d.ts +0 -11
  36. package/dist/command/remark/DefaultCommand.js +0 -38
  37. package/dist/command/remark/HailSizeCommand.d.ts +0 -11
  38. package/dist/command/remark/HailSizeCommand.js +0 -38
  39. package/dist/command/remark/HourlyMaximumMinimumTemperatureCommand.d.ts +0 -18
  40. package/dist/command/remark/HourlyMaximumMinimumTemperatureCommand.js +0 -39
  41. package/dist/command/remark/HourlyMaximumTemperatureCommand.d.ts +0 -14
  42. package/dist/command/remark/HourlyMaximumTemperatureCommand.js +0 -38
  43. package/dist/command/remark/HourlyMinimumTemperatureCommand.d.ts +0 -14
  44. package/dist/command/remark/HourlyMinimumTemperatureCommand.js +0 -38
  45. package/dist/command/remark/HourlyPrecipitationAmountCommand.d.ts +0 -14
  46. package/dist/command/remark/HourlyPrecipitationAmountCommand.js +0 -38
  47. package/dist/command/remark/HourlyPressureCommand.d.ts +0 -32
  48. package/dist/command/remark/HourlyPressureCommand.js +0 -40
  49. package/dist/command/remark/HourlyTemperatureDewPointCommand.d.ts +0 -18
  50. package/dist/command/remark/HourlyTemperatureDewPointCommand.js +0 -52
  51. package/dist/command/remark/IceAccretionCommand.d.ts +0 -15
  52. package/dist/command/remark/IceAccretionCommand.js +0 -38
  53. package/dist/command/remark/ObscurationCommand.d.ts +0 -14
  54. package/dist/command/remark/ObscurationCommand.js +0 -44
  55. package/dist/command/remark/PrecipitationAmount24HourCommand.d.ts +0 -14
  56. package/dist/command/remark/PrecipitationAmount24HourCommand.js +0 -39
  57. package/dist/command/remark/PrecipitationAmount36HourCommand.d.ts +0 -15
  58. package/dist/command/remark/PrecipitationAmount36HourCommand.js +0 -41
  59. package/dist/command/remark/PrecipitationBegCommand.d.ts +0 -15
  60. package/dist/command/remark/PrecipitationBegCommand.js +0 -45
  61. package/dist/command/remark/PrecipitationBegEndCommand.d.ts +0 -17
  62. package/dist/command/remark/PrecipitationBegEndCommand.js +0 -46
  63. package/dist/command/remark/PrecipitationEndCommand.d.ts +0 -15
  64. package/dist/command/remark/PrecipitationEndCommand.js +0 -45
  65. package/dist/command/remark/PrevailingVisibilityCommand.d.ts +0 -12
  66. package/dist/command/remark/PrevailingVisibilityCommand.js +0 -41
  67. package/dist/command/remark/SeaLevelPressureCommand.d.ts +0 -11
  68. package/dist/command/remark/SeaLevelPressureCommand.js +0 -39
  69. package/dist/command/remark/SecondLocationVisibilityCommand.d.ts +0 -12
  70. package/dist/command/remark/SecondLocationVisibilityCommand.js +0 -41
  71. package/dist/command/remark/SectorVisibilityCommand.d.ts +0 -13
  72. package/dist/command/remark/SectorVisibilityCommand.js +0 -42
  73. package/dist/command/remark/SmallHailSizeCommand.d.ts +0 -11
  74. package/dist/command/remark/SmallHailSizeCommand.js +0 -38
  75. package/dist/command/remark/SnowDepthCommand.d.ts +0 -11
  76. package/dist/command/remark/SnowDepthCommand.js +0 -38
  77. package/dist/command/remark/SnowIncreaseCommand.d.ts +0 -12
  78. package/dist/command/remark/SnowIncreaseCommand.js +0 -40
  79. package/dist/command/remark/SnowPelletsCommand.d.ts +0 -11
  80. package/dist/command/remark/SnowPelletsCommand.js +0 -37
  81. package/dist/command/remark/SunshineDurationCommand.d.ts +0 -11
  82. package/dist/command/remark/SunshineDurationCommand.js +0 -38
  83. package/dist/command/remark/SurfaceVisibilityCommand.d.ts +0 -11
  84. package/dist/command/remark/SurfaceVisibilityCommand.js +0 -39
  85. package/dist/command/remark/ThunderStormLocationCommand.d.ts +0 -12
  86. package/dist/command/remark/ThunderStormLocationCommand.js +0 -40
  87. package/dist/command/remark/ThunderStormLocationMovingCommand.d.ts +0 -19
  88. package/dist/command/remark/ThunderStormLocationMovingCommand.js +0 -42
  89. package/dist/command/remark/TornadicActivityBegCommand.d.ts +0 -16
  90. package/dist/command/remark/TornadicActivityBegCommand.js +0 -44
  91. package/dist/command/remark/TornadicActivityBegEndCommand.d.ts +0 -18
  92. package/dist/command/remark/TornadicActivityBegEndCommand.js +0 -46
  93. package/dist/command/remark/TornadicActivityEndCommand.d.ts +0 -16
  94. package/dist/command/remark/TornadicActivityEndCommand.js +0 -44
  95. package/dist/command/remark/TowerVisibilityCommand.d.ts +0 -11
  96. package/dist/command/remark/TowerVisibilityCommand.js +0 -39
  97. package/dist/command/remark/VariableSkyCommand.d.ts +0 -12
  98. package/dist/command/remark/VariableSkyCommand.js +0 -41
  99. package/dist/command/remark/VariableSkyHeightCommand.d.ts +0 -13
  100. package/dist/command/remark/VariableSkyHeightCommand.js +0 -43
  101. package/dist/command/remark/VirgaDirectionCommand.d.ts +0 -12
  102. package/dist/command/remark/VirgaDirectionCommand.js +0 -40
  103. package/dist/command/remark/WaterEquivalentSnowCommand.d.ts +0 -11
  104. package/dist/command/remark/WaterEquivalentSnowCommand.js +0 -38
  105. package/dist/command/remark/WindPeakCommandCommand.d.ts +0 -17
  106. package/dist/command/remark/WindPeakCommandCommand.js +0 -42
  107. package/dist/command/remark/WindShiftCommand.d.ts +0 -12
  108. package/dist/command/remark/WindShiftCommand.js +0 -38
  109. package/dist/command/remark/WindShiftFropaCommand.d.ts +0 -12
  110. package/dist/command/remark/WindShiftFropaCommand.js +0 -38
  111. package/dist/command/remark.d.ts +0 -109
  112. package/dist/command/remark.js +0 -152
  113. package/dist/commons/converter.d.ts +0 -21
  114. package/dist/commons/converter.js +0 -108
  115. package/dist/commons/errors.d.ts +0 -24
  116. package/dist/commons/errors.js +0 -46
  117. package/dist/commons/i18n.d.ts +0 -12
  118. package/dist/commons/i18n.js +0 -30
  119. package/dist/dates/metar.d.ts +0 -5
  120. package/dist/dates/metar.js +0 -8
  121. package/dist/dates/taf.d.ts +0 -28
  122. package/dist/dates/taf.js +0 -17
  123. package/dist/forecast/forecast.d.ts +0 -36
  124. package/dist/forecast/forecast.js +0 -72
  125. package/dist/helpers/date.d.ts +0 -11
  126. package/dist/helpers/date.js +0 -56
  127. package/dist/helpers/helpers.d.ts +0 -17
  128. package/dist/helpers/helpers.js +0 -46
  129. package/dist/index.d.ts +0 -32
  130. package/dist/index.js +0 -62
  131. package/dist/model/enum.d.ts +0 -265
  132. package/dist/model/enum.js +0 -280
  133. package/dist/model/model.d.ts +0 -188
  134. package/dist/model/model.js +0 -11
  135. package/dist/parser/parser.d.ts +0 -111
  136. package/dist/parser/parser.js +0 -480
@@ -1,188 +0,0 @@
1
- import { CloudQuantity, CloudType, Descriptive, ValueIndicator, Phenomenon, TimeIndicator, WeatherChangeType, DistanceUnit, RunwayInfoTrend, RunwayInfoUnit, Intensity } from "../model/enum";
2
- import { Remark } from "../command/remark";
3
- export interface ICountry {
4
- name: string;
5
- }
6
- export interface IAirport {
7
- name: string;
8
- city: string;
9
- country: string;
10
- iata: string;
11
- icao: string;
12
- latitude: string;
13
- longitude: string;
14
- altitude: string;
15
- timezone: string;
16
- dst: boolean;
17
- tzDatabase: unknown;
18
- }
19
- export interface IWind {
20
- speed: number;
21
- direction: string;
22
- degrees?: number;
23
- gust?: number;
24
- minVariation?: number;
25
- maxVariation?: number;
26
- unit: string;
27
- }
28
- export interface IWindShear extends IWind {
29
- height: number;
30
- }
31
- export interface Distance {
32
- indicator?: ValueIndicator;
33
- value: number;
34
- unit: DistanceUnit;
35
- /** No Directional Visibility */
36
- ndv?: true;
37
- }
38
- export declare type Visibility = Distance & {
39
- /**
40
- * Never in North American METARs
41
- */
42
- min?: {
43
- /** Always in meters */
44
- value: number;
45
- direction: string;
46
- };
47
- };
48
- export interface IWeatherCondition {
49
- intensity?: Intensity;
50
- descriptive?: Descriptive;
51
- phenomenons: Phenomenon[];
52
- }
53
- export declare function isWeatherConditionValid(weather: IWeatherCondition): boolean;
54
- export interface ITemperatureDated {
55
- temperature: number;
56
- day: number;
57
- hour: number;
58
- }
59
- export interface IRunwayInfo {
60
- name: string;
61
- minRange: number;
62
- maxRange?: number;
63
- /**
64
- * Only used in North American runway ranges (feet unit of measurement)
65
- */
66
- indicator?: ValueIndicator;
67
- /**
68
- * Only used in IACO runway ranges (meters unit of measurement)
69
- */
70
- trend?: RunwayInfoTrend;
71
- unit: RunwayInfoUnit;
72
- }
73
- export interface ICloud {
74
- height?: number;
75
- quantity: CloudQuantity;
76
- type?: CloudType;
77
- }
78
- export interface IAbstractWeatherContainer {
79
- wind?: IWind;
80
- visibility?: Visibility;
81
- verticalVisibility?: number;
82
- windShear?: IWindShear;
83
- cavok?: true;
84
- remark?: string;
85
- remarks: Remark[];
86
- clouds: ICloud[];
87
- weatherConditions: IWeatherCondition[];
88
- }
89
- export interface IAbstractValidity {
90
- startDay: number;
91
- startHour: number;
92
- }
93
- /**
94
- * Exclusive for the TS port (because python has `time()` and js does not)
95
- */
96
- export interface ITime {
97
- hour: number;
98
- minute: number;
99
- }
100
- export interface IAbstractWeatherCode extends IAbstractWeatherContainer, ITime {
101
- day: number;
102
- airport?: IAirport;
103
- message: string;
104
- station: string;
105
- trends: IAbstractTrend[];
106
- }
107
- export interface IAbstractWeatherCodeDated extends IAbstractWeatherCode {
108
- issued: Date;
109
- }
110
- export interface IMetar extends IAbstractWeatherCode {
111
- temperature?: number;
112
- dewPoint?: number;
113
- altimeter?: number;
114
- nosig?: true;
115
- auto?: true;
116
- runwaysInfo: IRunwayInfo[];
117
- /**
118
- * Not used in North America
119
- */
120
- trends: IMetarTrend[];
121
- }
122
- export interface ITAF extends IAbstractWeatherCode {
123
- validity: IValidity;
124
- maxTemperature?: ITemperatureDated;
125
- minTemperature?: ITemperatureDated;
126
- amendment?: true;
127
- trends: TAFTrend[];
128
- }
129
- export interface IAbstractTrend extends IAbstractWeatherContainer {
130
- type: WeatherChangeType;
131
- }
132
- export interface IMetarTrendTime extends ITime {
133
- type: TimeIndicator;
134
- }
135
- export interface IMetarTrend extends IAbstractTrend {
136
- times: IMetarTrendTime[];
137
- }
138
- export interface IBaseTAFTrend extends IAbstractTrend {
139
- /**
140
- * Will not be found on FM trends. May exist on others.
141
- *
142
- * If does not exist, probability is > 40%
143
- */
144
- probability?: number;
145
- /**
146
- * All trends have `startDay` and `startHour` defined. Additionally:
147
- *
148
- * - FM trends also have `startMinutes`. They **DO NOT** have an explicit end
149
- * validity (it is implied by the following FM).
150
- * - All others (PROB, TEMPO, BECMG) have `endDay` and `endHour`.
151
- *
152
- * All properties are allowed to be accessed (as optionals), but if you want
153
- * type guarantees, you can check the trend type. For example:
154
- *
155
- * ```ts
156
- * switch (trend.type) {
157
- * case WeatherChangeType.FM:
158
- * // trend.validity now has startMinutes defined
159
- * break;
160
- * case WeatherChangeType.PROB:
161
- * case WeatherChangeType.BECMG:
162
- * case WeatherChangeType.TEMPO:
163
- * // trend.validity now has endHour, endDay defined
164
- * }
165
- * ```
166
- */
167
- validity: IAbstractValidity & Partial<IFMValidity> & Partial<IValidity>;
168
- }
169
- export declare type TAFTrend = IBaseTAFTrend & ({
170
- type: WeatherChangeType.FM;
171
- validity: IFMValidity;
172
- } | {
173
- type: WeatherChangeType;
174
- validity: IValidity;
175
- });
176
- export interface IEndValidity {
177
- endHour: number;
178
- endDay: number;
179
- }
180
- export interface IValidity extends IAbstractValidity, IEndValidity {
181
- }
182
- export interface IValidityDated extends IAbstractValidity, IEndValidity {
183
- start: Date;
184
- end: Date;
185
- }
186
- export interface IFMValidity extends IAbstractValidity {
187
- startMinutes: number;
188
- }
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isWeatherConditionValid = void 0;
4
- const enum_1 = require("../model/enum");
5
- function isWeatherConditionValid(weather) {
6
- return (weather.phenomenons.length !== 0 ||
7
- weather.descriptive == enum_1.Descriptive.THUNDERSTORM ||
8
- (weather.intensity === enum_1.Intensity.IN_VICINITY &&
9
- weather.descriptive == enum_1.Descriptive.SHOWERS));
10
- }
11
- exports.isWeatherConditionValid = isWeatherConditionValid;
@@ -1,111 +0,0 @@
1
- import { Remark } from "../command/remark";
2
- import { IAbstractWeatherContainer, IMetar, IMetarTrend, ITAF, TAFTrend, ITemperatureDated, IValidity, IWeatherCondition, IValidityDated } from "../model/model";
3
- import { Locale } from "../commons/i18n";
4
- /**
5
- * Parses the temperature in a TAF
6
- * @param input the string containing the temperature
7
- * @returns TemperatureDated object
8
- */
9
- export declare function parseTemperature(input: string): ITemperatureDated;
10
- /**
11
- * Parses validity of a TAF or a TAFTrend
12
- * @param input the string containing the validity
13
- * @returns Validity object
14
- */
15
- export declare function parseValidity(input: string, date?: Date): IValidityDated | IValidity;
16
- /**
17
- * Abstract class.
18
- * Base parser.
19
- */
20
- export declare abstract class AbstractParser {
21
- #private;
22
- protected locale: Locale;
23
- FM: string;
24
- TEMPO: string;
25
- BECMG: string;
26
- RMK: string;
27
- constructor(locale: Locale);
28
- parseWeatherCondition(input: string): IWeatherCondition;
29
- /**
30
- * Parses the message into different tokens
31
- * @param input The metar or TAF as string
32
- * @returns List of tokens
33
- */
34
- tokenize(input: string): string[];
35
- /**
36
- * Common parse method for METAR, TAF and trends object
37
- * @param abstractWeatherCode the object to update
38
- * @param input The token to parse
39
- * @returns True if the token was parsed false otherwise
40
- */
41
- generalParse(abstractWeatherContainer: IAbstractWeatherContainer, input: string): boolean;
42
- }
43
- export declare class MetarParser extends AbstractParser {
44
- #private;
45
- AT: string;
46
- TL: string;
47
- /**
48
- * Parses a trend of a metar
49
- * @param index the index starting the trend in the list
50
- * @param trend The trend to update
51
- * @param trendParts array of tokens
52
- * @returns the last index of the token that was last parsed
53
- */
54
- parseTrend(index: number, trend: IMetarTrend, trendParts: string[]): number;
55
- /**
56
- * Parses an message and returns a METAR
57
- * @param input The message to parse
58
- * @returns METAR
59
- */
60
- parse(input: string): IMetar;
61
- }
62
- /**
63
- * Parser for TAF messages
64
- */
65
- export declare class TAFParser extends AbstractParser {
66
- #private;
67
- TAF: string;
68
- PROB: string;
69
- TX: string;
70
- TN: string;
71
- /**
72
- * the message to parse
73
- * @param input
74
- * @returns a TAF object
75
- * @throws ParseError if the message is invalid
76
- */
77
- parse(input: string): ITAF;
78
- /**
79
- * Format the message as a multiple line code so each line can be parsed
80
- * @param tafCode The base message
81
- * @returns a list of string representing the lines of the message
82
- */
83
- extractLinesTokens(tafCode: string): string[][];
84
- /**
85
- * Parses the tokens of the line and updates the TAF object
86
- * @param taf TAF object to update
87
- * @param lineTokens the array of tokens representing a line
88
- */
89
- parseLine(taf: ITAF, lineTokens: string[]): void;
90
- /**
91
- * Finds a non-FM validity in a line
92
- * @param index the index at which the array should be parsed
93
- * @param line The array of string containing the line
94
- * @param trend The trend object to update
95
- */
96
- findLineValidity(index: number, line: string[]): IValidity | undefined;
97
- /**
98
- * Parses a trend of the TAF
99
- * @param index the index at which the array should be parsed
100
- * @param line The array of string containing the line
101
- * @param trend The trend object to update
102
- */
103
- parseTrend(index: number, line: string[], trend: TAFTrend): void;
104
- makeEmptyTAFTrend(): Omit<TAFTrend, "type" | "validity">;
105
- }
106
- export declare class RemarkParser {
107
- #private;
108
- private locale;
109
- constructor(locale: Locale);
110
- parse(code: string): Remark[];
111
- }