metar-taf-parser 4.0.2 → 4.1.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/locale/en.js +1 -1
- package/metar-taf-parser.d.ts +24 -4
- package/metar-taf-parser.js +26 -9
- package/package.json +1 -1
package/locale/en.js
CHANGED
|
@@ -207,7 +207,7 @@ var en = {
|
|
|
207
207
|
Hourly: "{0}/100 of an inch of precipitation fell in the last hour",
|
|
208
208
|
},
|
|
209
209
|
Beg: {
|
|
210
|
-
"0": "{0} {1} beginning at {2}:{3}
|
|
210
|
+
"0": "{0} {1} beginning at {2}:{3}",
|
|
211
211
|
End: "{0} {1} beginning at {2}:{3} ending at {4}:{5}",
|
|
212
212
|
},
|
|
213
213
|
End: "{0} {1} ending at {2}:{3}",
|
package/metar-taf-parser.d.ts
CHANGED
|
@@ -1101,7 +1101,29 @@ interface ICloud {
|
|
|
1101
1101
|
quantity: CloudQuantity;
|
|
1102
1102
|
type?: CloudType;
|
|
1103
1103
|
}
|
|
1104
|
-
interface
|
|
1104
|
+
interface IFlags {
|
|
1105
|
+
/**
|
|
1106
|
+
* Amended TAF
|
|
1107
|
+
*/
|
|
1108
|
+
amendment?: true;
|
|
1109
|
+
/**
|
|
1110
|
+
* Amended METAR
|
|
1111
|
+
*/
|
|
1112
|
+
auto?: true;
|
|
1113
|
+
/**
|
|
1114
|
+
* Canceled TAF
|
|
1115
|
+
*/
|
|
1116
|
+
canceled?: true;
|
|
1117
|
+
/**
|
|
1118
|
+
* Corrected METAR/TAF
|
|
1119
|
+
*/
|
|
1120
|
+
corrected?: true;
|
|
1121
|
+
/**
|
|
1122
|
+
* No data
|
|
1123
|
+
*/
|
|
1124
|
+
nil?: true;
|
|
1125
|
+
}
|
|
1126
|
+
interface IAbstractWeatherContainer extends IFlags {
|
|
1105
1127
|
wind?: IWind;
|
|
1106
1128
|
visibility?: Visibility;
|
|
1107
1129
|
verticalVisibility?: number;
|
|
@@ -1138,7 +1160,6 @@ interface IMetar extends IAbstractWeatherCode {
|
|
|
1138
1160
|
dewPoint?: number;
|
|
1139
1161
|
altimeter?: number;
|
|
1140
1162
|
nosig?: true;
|
|
1141
|
-
auto?: true;
|
|
1142
1163
|
runwaysInfo: IRunwayInfo[];
|
|
1143
1164
|
/**
|
|
1144
1165
|
* Not used in North America
|
|
@@ -1149,7 +1170,6 @@ interface ITAF extends IAbstractWeatherCode {
|
|
|
1149
1170
|
validity: IValidity;
|
|
1150
1171
|
maxTemperature?: ITemperatureDated;
|
|
1151
1172
|
minTemperature?: ITemperatureDated;
|
|
1152
|
-
amendment?: true;
|
|
1153
1173
|
trends: TAFTrend[];
|
|
1154
1174
|
}
|
|
1155
1175
|
interface IAbstractTrend extends IAbstractWeatherContainer {
|
|
@@ -1322,4 +1342,4 @@ declare function parseTAF(rawTAF: string, options?: IMetarTAFParserOptions): ITA
|
|
|
1322
1342
|
declare function parseTAF(rawTAF: string, options?: IMetarTAFParserOptionsDated): ITAFDated;
|
|
1323
1343
|
declare function parseTAFAsForecast(rawTAF: string, options: IMetarTAFParserOptionsDated): IForecastContainer;
|
|
1324
1344
|
|
|
1325
|
-
export { CloudQuantity, CloudType, CommandExecutionError, Descriptive, Direction, Distance, DistanceUnit, Forecast, IAbstractTrend, IAbstractValidity, IAbstractWeatherCode, IAbstractWeatherCodeDated, IAbstractWeatherContainer, IAirport, IBaseRemark, IBaseTAFTrend, ICeilingHeightRemark, ICeilingSecondLocationRemark, ICloud, ICompositeForecast, ICountry, IEndValidity, IFMValidity, IForecastContainer, IHourlyMaximumMinimumTemperatureRemark, IHourlyMaximumTemperatureRemark, IHourlyMinimumTemperatureRemark, IHourlyPrecipitationAmountRemark, IHourlyPressureRemark, IHourlyTemperatureDewPointRemark, IIceAccretionRemark, IMetar, IMetarTAFParserOptions, IMetarTAFParserOptionsDated, IMetarTrend, IMetarTrendTime, IObscurationRemark, IPrecipitationAmount24HourRemark, IPrecipitationAmount36HourRemark, IPrecipitationBegEndRemark, IPrevailingVisibilityRemark, IRunwayInfo, ISeaLevelPressureRemark, ISecondLocationVisibilityRemark, ISectorVisibilityRemark, ISmallHailSizeRemark, ISnowIncreaseRemark, ISnowPelletsRemark, ISunshineDurationRemark, ISurfaceVisibilityRemark, ITAF, ITAFDated, ITemperatureDated, IThunderStormLocationMovingRemark, IThunderStormLocationRemark, ITime, ITornadicActivityBegEndRemark, ITornadicActivityBegRemark, ITornadicActivityEndRemark, ITowerVisibilityRemark, IUnknownRemark, IValidity, IValidityDated, IVariableSkyHeightRemark, IVariableSkyRemark, IVirgaDirectionRemark, IWaterEquivalentSnowRemark, IWeatherCondition, IWind, IWindPeakCommandRemark, IWindShear, IWindShiftFropaRemark, Intensity, InvalidWeatherStatementError, Locale, ParseError, Phenomenon, Remark, RemarkType, RunwayInfoTrend, RunwayInfoUnit, TAFTrend, TAFTrendDated, TimeIndicator, TimestampOutOfBoundsError, UnexpectedParseError, ValueIndicator, Visibility, WeatherChangeType, getCompositeForecastForDate, isWeatherConditionValid, parseMetar, parseTAF, parseTAFAsForecast };
|
|
1345
|
+
export { CloudQuantity, CloudType, CommandExecutionError, Descriptive, Direction, Distance, DistanceUnit, Forecast, IAbstractTrend, IAbstractValidity, IAbstractWeatherCode, IAbstractWeatherCodeDated, IAbstractWeatherContainer, IAirport, IBaseRemark, IBaseTAFTrend, ICeilingHeightRemark, ICeilingSecondLocationRemark, ICloud, ICompositeForecast, ICountry, IEndValidity, IFMValidity, IFlags, IForecastContainer, IHourlyMaximumMinimumTemperatureRemark, IHourlyMaximumTemperatureRemark, IHourlyMinimumTemperatureRemark, IHourlyPrecipitationAmountRemark, IHourlyPressureRemark, IHourlyTemperatureDewPointRemark, IIceAccretionRemark, IMetar, IMetarTAFParserOptions, IMetarTAFParserOptionsDated, IMetarTrend, IMetarTrendTime, IObscurationRemark, IPrecipitationAmount24HourRemark, IPrecipitationAmount36HourRemark, IPrecipitationBegEndRemark, IPrevailingVisibilityRemark, IRunwayInfo, ISeaLevelPressureRemark, ISecondLocationVisibilityRemark, ISectorVisibilityRemark, ISmallHailSizeRemark, ISnowIncreaseRemark, ISnowPelletsRemark, ISunshineDurationRemark, ISurfaceVisibilityRemark, ITAF, ITAFDated, ITemperatureDated, IThunderStormLocationMovingRemark, IThunderStormLocationRemark, ITime, ITornadicActivityBegEndRemark, ITornadicActivityBegRemark, ITornadicActivityEndRemark, ITowerVisibilityRemark, IUnknownRemark, IValidity, IValidityDated, IVariableSkyHeightRemark, IVariableSkyRemark, IVirgaDirectionRemark, IWaterEquivalentSnowRemark, IWeatherCondition, IWind, IWindPeakCommandRemark, IWindShear, IWindShiftFropaRemark, Intensity, InvalidWeatherStatementError, Locale, ParseError, Phenomenon, Remark, RemarkType, RunwayInfoTrend, RunwayInfoUnit, TAFTrend, TAFTrendDated, TimeIndicator, TimestampOutOfBoundsError, UnexpectedParseError, ValueIndicator, Visibility, WeatherChangeType, getCompositeForecastForDate, isWeatherConditionValid, parseMetar, parseTAF, parseTAFAsForecast };
|
package/metar-taf-parser.js
CHANGED
|
@@ -2071,6 +2071,24 @@ function parseDeliveryTime(timeString) {
|
|
|
2071
2071
|
minute,
|
|
2072
2072
|
};
|
|
2073
2073
|
}
|
|
2074
|
+
function parseFlags(abstractWeatherCode, flag) {
|
|
2075
|
+
const flags = findFlags(flag);
|
|
2076
|
+
if (flags)
|
|
2077
|
+
Object.assign(abstractWeatherCode, flags);
|
|
2078
|
+
return !!flags;
|
|
2079
|
+
}
|
|
2080
|
+
var FlagMap;
|
|
2081
|
+
(function (FlagMap) {
|
|
2082
|
+
FlagMap["AMD"] = "amendment";
|
|
2083
|
+
FlagMap["AUTO"] = "auto";
|
|
2084
|
+
FlagMap["CNL"] = "canceled";
|
|
2085
|
+
FlagMap["COR"] = "corrected";
|
|
2086
|
+
FlagMap["NIL"] = "nil";
|
|
2087
|
+
})(FlagMap || (FlagMap = {}));
|
|
2088
|
+
function findFlags(flag) {
|
|
2089
|
+
if (flag in FlagMap)
|
|
2090
|
+
return { [FlagMap[flag]]: true };
|
|
2091
|
+
}
|
|
2074
2092
|
/**
|
|
2075
2093
|
* This function parses the array containing the remark and concat the array into a string
|
|
2076
2094
|
* @param container the metar, taf or taf trend to update
|
|
@@ -2273,13 +2291,11 @@ class MetarParser extends AbstractParser {
|
|
|
2273
2291
|
};
|
|
2274
2292
|
let index = 2;
|
|
2275
2293
|
while (index < metarTab.length) {
|
|
2276
|
-
if (!super.generalParse(metar, metarTab[index])
|
|
2294
|
+
if (!super.generalParse(metar, metarTab[index]) &&
|
|
2295
|
+
!parseFlags(metar, metarTab[index])) {
|
|
2277
2296
|
if (metarTab[index] === "NOSIG") {
|
|
2278
2297
|
metar.nosig = true;
|
|
2279
2298
|
}
|
|
2280
|
-
else if (metarTab[index] === "AUTO") {
|
|
2281
|
-
metar.auto = true;
|
|
2282
|
-
}
|
|
2283
2299
|
else if (metarTab[index] === this.TEMPO ||
|
|
2284
2300
|
metarTab[index] === this.BECMG) {
|
|
2285
2301
|
const trend = {
|
|
@@ -2327,15 +2343,14 @@ class TAFParser extends AbstractParser {
|
|
|
2327
2343
|
* @throws ParseError if the message is invalid
|
|
2328
2344
|
*/
|
|
2329
2345
|
parse(input) {
|
|
2330
|
-
let amendment;
|
|
2331
2346
|
const lines = this.extractLinesTokens(input);
|
|
2332
2347
|
let index = 0;
|
|
2333
2348
|
if (lines[0][0] === this.TAF)
|
|
2334
2349
|
index = 1;
|
|
2335
2350
|
if (lines[0][1] === this.TAF)
|
|
2336
2351
|
index = 2;
|
|
2337
|
-
|
|
2338
|
-
|
|
2352
|
+
const flags = findFlags(lines[0][index]);
|
|
2353
|
+
if (flags) {
|
|
2339
2354
|
index += 1;
|
|
2340
2355
|
}
|
|
2341
2356
|
const station = lines[0][index];
|
|
@@ -2345,7 +2360,7 @@ class TAFParser extends AbstractParser {
|
|
|
2345
2360
|
const validity = parseValidity(lines[0][index]);
|
|
2346
2361
|
const taf = {
|
|
2347
2362
|
station,
|
|
2348
|
-
|
|
2363
|
+
...flags,
|
|
2349
2364
|
...time,
|
|
2350
2365
|
validity,
|
|
2351
2366
|
message: input,
|
|
@@ -2364,8 +2379,10 @@ class TAFParser extends AbstractParser {
|
|
|
2364
2379
|
taf.maxTemperature = parseTemperature(token);
|
|
2365
2380
|
else if (token.startsWith(this.TN))
|
|
2366
2381
|
taf.minTemperature = parseTemperature(token);
|
|
2367
|
-
else
|
|
2382
|
+
else {
|
|
2383
|
+
parseFlags(taf, token);
|
|
2368
2384
|
this.generalParse(taf, token);
|
|
2385
|
+
}
|
|
2369
2386
|
}
|
|
2370
2387
|
// Handle the other lines
|
|
2371
2388
|
for (let i = 1; i < lines.length; i++) {
|