metar-taf-parser 6.0.0 → 6.1.1
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/metar-taf-parser.d.ts +7 -2
- package/metar-taf-parser.js +29 -16
- package/package.json +1 -1
package/metar-taf-parser.d.ts
CHANGED
|
@@ -242,6 +242,11 @@ declare enum DistanceUnit {
|
|
|
242
242
|
Meters = "m",
|
|
243
243
|
StatuteMiles = "SM"
|
|
244
244
|
}
|
|
245
|
+
declare enum SpeedUnit {
|
|
246
|
+
Knot = "KT",
|
|
247
|
+
MetersPerSecond = "MPS",
|
|
248
|
+
KilometersPerHour = "KM/H"
|
|
249
|
+
}
|
|
245
250
|
/**
|
|
246
251
|
* Used to indicate the actual value is greater than or less than the value written
|
|
247
252
|
*
|
|
@@ -1052,7 +1057,7 @@ interface IWind {
|
|
|
1052
1057
|
gust?: number;
|
|
1053
1058
|
minVariation?: number;
|
|
1054
1059
|
maxVariation?: number;
|
|
1055
|
-
unit:
|
|
1060
|
+
unit: SpeedUnit;
|
|
1056
1061
|
}
|
|
1057
1062
|
interface IWindShear extends IWind {
|
|
1058
1063
|
height: number;
|
|
@@ -1372,4 +1377,4 @@ declare function parseTAF(rawTAF: string, options?: IMetarTAFParserOptions): ITA
|
|
|
1372
1377
|
declare function parseTAF(rawTAF: string, options?: IMetarTAFParserOptionsDated): ITAFDated;
|
|
1373
1378
|
declare function parseTAFAsForecast(rawTAF: string, options: IMetarTAFParserOptionsDated): IForecastContainer;
|
|
1374
1379
|
|
|
1375
|
-
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, ITemperature, 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 };
|
|
1380
|
+
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, ITemperature, 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, SpeedUnit, TAFTrend, TAFTrendDated, TimeIndicator, TimestampOutOfBoundsError, UnexpectedParseError, ValueIndicator, Visibility, WeatherChangeType, getCompositeForecastForDate, isWeatherConditionValid, parseMetar, parseTAF, parseTAFAsForecast };
|
package/metar-taf-parser.js
CHANGED
|
@@ -436,6 +436,12 @@ var DistanceUnit;
|
|
|
436
436
|
DistanceUnit["Meters"] = "m";
|
|
437
437
|
DistanceUnit["StatuteMiles"] = "SM";
|
|
438
438
|
})(DistanceUnit || (DistanceUnit = {}));
|
|
439
|
+
var SpeedUnit;
|
|
440
|
+
(function (SpeedUnit) {
|
|
441
|
+
SpeedUnit["Knot"] = "KT";
|
|
442
|
+
SpeedUnit["MetersPerSecond"] = "MPS";
|
|
443
|
+
SpeedUnit["KilometersPerHour"] = "KM/H";
|
|
444
|
+
})(SpeedUnit || (SpeedUnit = {}));
|
|
439
445
|
/**
|
|
440
446
|
* Used to indicate the actual value is greater than or less than the value written
|
|
441
447
|
*
|
|
@@ -1743,7 +1749,7 @@ function makeWind(direction, speed, gust, unit) {
|
|
|
1743
1749
|
direction: degreesToCardinal(direction),
|
|
1744
1750
|
degrees: direction !== "VRB" ? +direction : undefined,
|
|
1745
1751
|
gust: gust ? +gust : undefined,
|
|
1746
|
-
unit
|
|
1752
|
+
unit,
|
|
1747
1753
|
};
|
|
1748
1754
|
}
|
|
1749
1755
|
class CloudCommand {
|
|
@@ -1806,7 +1812,7 @@ class WindCommand {
|
|
|
1806
1812
|
const matches = windString.match(__classPrivateFieldGet(this, _WindCommand_regex, "f"));
|
|
1807
1813
|
if (!matches)
|
|
1808
1814
|
throw new UnexpectedParseError("Wind should be defined");
|
|
1809
|
-
return makeWind(matches[1], matches[2], matches[3], matches[4]);
|
|
1815
|
+
return makeWind(matches[1], matches[2], matches[3], as(matches[4] || "KT", SpeedUnit));
|
|
1810
1816
|
}
|
|
1811
1817
|
execute(container, windString) {
|
|
1812
1818
|
const wind = this.parseWind(windString);
|
|
@@ -1849,7 +1855,7 @@ class WindShearCommand {
|
|
|
1849
1855
|
if (!matches)
|
|
1850
1856
|
throw new UnexpectedParseError("Wind shear should be defined");
|
|
1851
1857
|
return {
|
|
1852
|
-
...makeWind(matches[2], matches[3], matches[4], matches[5]),
|
|
1858
|
+
...makeWind(matches[2], matches[3], matches[4], as(matches[5], SpeedUnit)),
|
|
1853
1859
|
height: 100 * +matches[1],
|
|
1854
1860
|
};
|
|
1855
1861
|
}
|
|
@@ -2378,21 +2384,36 @@ class TAFParser extends AbstractParser {
|
|
|
2378
2384
|
parseRemark(taf, lines[0], i, this.locale);
|
|
2379
2385
|
break;
|
|
2380
2386
|
}
|
|
2381
|
-
else if (token.startsWith(this.TX))
|
|
2382
|
-
taf.maxTemperature = parseTemperature(token);
|
|
2383
|
-
else if (token.startsWith(this.TN))
|
|
2384
|
-
taf.minTemperature = parseTemperature(token);
|
|
2385
2387
|
else {
|
|
2386
2388
|
parseFlags(taf, token);
|
|
2387
2389
|
this.generalParse(taf, token);
|
|
2388
2390
|
}
|
|
2389
2391
|
}
|
|
2392
|
+
const minMaxTemperatureLines = [
|
|
2393
|
+
lines[0].slice(index + 1), // EU countries have min/max in first line
|
|
2394
|
+
];
|
|
2395
|
+
// US military bases have min/max in last line
|
|
2396
|
+
if (lines.length > 1)
|
|
2397
|
+
minMaxTemperatureLines.push(lines[lines.length - 1]);
|
|
2398
|
+
this.parseMaxMinTemperatures(taf, minMaxTemperatureLines);
|
|
2390
2399
|
// Handle the other lines
|
|
2391
2400
|
for (let i = 1; i < lines.length; i++) {
|
|
2392
2401
|
this.parseLine(taf, lines[i]);
|
|
2393
2402
|
}
|
|
2394
2403
|
return taf;
|
|
2395
2404
|
}
|
|
2405
|
+
parseMaxMinTemperatures(taf, lines) {
|
|
2406
|
+
for (const line of lines) {
|
|
2407
|
+
for (const token of line) {
|
|
2408
|
+
if (token == this.RMK)
|
|
2409
|
+
break;
|
|
2410
|
+
else if (token.startsWith(this.TX))
|
|
2411
|
+
taf.maxTemperature = parseTemperature(token);
|
|
2412
|
+
else if (token.startsWith(this.TN))
|
|
2413
|
+
taf.minTemperature = parseTemperature(token);
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2396
2417
|
/**
|
|
2397
2418
|
* Format the message as a multiple line code so each line can be parsed
|
|
2398
2419
|
* @param tafCode The base message
|
|
@@ -2414,14 +2435,6 @@ class TAFParser extends AbstractParser {
|
|
|
2414
2435
|
return ls;
|
|
2415
2436
|
}
|
|
2416
2437
|
const linesToken = lines.map(this.tokenize);
|
|
2417
|
-
if (linesToken.length > 1) {
|
|
2418
|
-
const lastLine = linesToken[lines.length - 1];
|
|
2419
|
-
const temperatures = lastLine.filter((l) => l.startsWith(this.TX) || l.startsWith(this.TN));
|
|
2420
|
-
if (temperatures.length) {
|
|
2421
|
-
linesToken[0] = linesToken[0].concat(temperatures);
|
|
2422
|
-
linesToken[lines.length - 1] = lastLine.filter((l) => !l.startsWith(this.TX) && !l.startsWith(this.TN));
|
|
2423
|
-
}
|
|
2424
|
-
}
|
|
2425
2438
|
return linesToken;
|
|
2426
2439
|
}
|
|
2427
2440
|
/**
|
|
@@ -2818,4 +2831,4 @@ function parse(rawReport, options, parser, datesHydrator) {
|
|
|
2818
2831
|
}
|
|
2819
2832
|
}
|
|
2820
2833
|
|
|
2821
|
-
export { CloudQuantity, CloudType, CommandExecutionError, Descriptive, Direction, DistanceUnit, Intensity, InvalidWeatherStatementError, ParseError, Phenomenon, RemarkType, RunwayInfoTrend, RunwayInfoUnit, TimeIndicator, TimestampOutOfBoundsError, UnexpectedParseError, ValueIndicator, WeatherChangeType, getCompositeForecastForDate, isWeatherConditionValid, parseMetar, parseTAF, parseTAFAsForecast };
|
|
2834
|
+
export { CloudQuantity, CloudType, CommandExecutionError, Descriptive, Direction, DistanceUnit, Intensity, InvalidWeatherStatementError, ParseError, Phenomenon, RemarkType, RunwayInfoTrend, RunwayInfoUnit, SpeedUnit, TimeIndicator, TimestampOutOfBoundsError, UnexpectedParseError, ValueIndicator, WeatherChangeType, getCompositeForecastForDate, isWeatherConditionValid, parseMetar, parseTAF, parseTAFAsForecast };
|