metar-taf-parser 7.1.2 → 7.2.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/README.md CHANGED
@@ -32,6 +32,8 @@ The `parseMetar` & `parseTAF` functions are designed to parse the raw report str
32
32
 
33
33
  #### `parseMetar`
34
34
 
35
+ If the payload begins with [`METAR` or `SPECI`](http://www.bom.gov.au/aviation/data/education/metar-speci.pdf), that will be added as the `type`.
36
+
35
37
  ```ts
36
38
  import { parseMetar } from "metar-taf-parser";
37
39
 
@@ -1,3 +1,7 @@
1
+ declare enum MetarType {
2
+ METAR = "METAR",
3
+ SPECI = "SPECI"
4
+ }
1
5
  declare enum CloudQuantity {
2
6
  /**
3
7
  * Sky clear
@@ -1222,6 +1226,7 @@ interface IAbstractWeatherCodeDated extends IAbstractWeatherCode {
1222
1226
  issued: Date;
1223
1227
  }
1224
1228
  interface IMetar extends IAbstractWeatherCode {
1229
+ type?: MetarType;
1225
1230
  temperature?: number;
1226
1231
  dewPoint?: number;
1227
1232
  altimeter?: number;
@@ -1462,4 +1467,4 @@ declare function parseTAF(rawTAF: string, options?: IMetarTAFParserOptions): ITA
1462
1467
  declare function parseTAF(rawTAF: string, options?: IMetarTAFParserOptionsDated): ITAFDated;
1463
1468
  declare function parseTAFAsForecast(rawTAF: string, options: IMetarTAFParserOptionsDated): IForecastContainer;
1464
1469
 
1465
- export { CloudQuantity, CloudType, CommandExecutionError, Descriptive, Direction, Distance, DistanceUnit, Forecast, IAbstractTrend, IAbstractValidity, IAbstractWeatherCode, IAbstractWeatherCodeDated, IAbstractWeatherContainer, IBaseRemark, IBaseTAFTrend, ICeilingHeightRemark, ICeilingSecondLocationRemark, ICloud, ICompositeForecast, IEndValidity, IFMValidity, IFlags, IForecastContainer, IHourlyMaximumMinimumTemperatureRemark, IHourlyMaximumTemperatureRemark, IHourlyMinimumTemperatureRemark, IHourlyPrecipitationAmountRemark, IHourlyPressureRemark, IHourlyTemperatureDewPointRemark, IIceAccretionRemark, IIcing, IMetar, IMetarTAFParserOptions, IMetarTAFParserOptionsDated, IMetarTrend, IMetarTrendTime, IObscurationRemark, IPrecipitationAmount24HourRemark, IPrecipitationAmount36HourRemark, IPrecipitationBegEndRemark, IPrevailingVisibilityRemark, IRunwayInfo, ISeaLevelPressureRemark, ISecondLocationVisibilityRemark, ISectorVisibilityRemark, ISmallHailSizeRemark, ISnowIncreaseRemark, ISnowPelletsRemark, ISunshineDurationRemark, ISurfaceVisibilityRemark, ITAF, ITAFDated, ITafGroups, ITemperature, ITemperatureDated, IThunderStormLocationMovingRemark, IThunderStormLocationRemark, ITime, ITornadicActivityBegEndRemark, ITornadicActivityBegRemark, ITornadicActivityEndRemark, ITowerVisibilityRemark, ITurbulence, IUnknownRemark, IValidity, IValidityDated, IVariableSkyHeightRemark, IVariableSkyRemark, IVirgaDirectionRemark, IWaterEquivalentSnowRemark, IWeatherCondition, IWind, IWindPeakCommandRemark, IWindShear, IWindShiftFropaRemark, IcingIntensity, Intensity, InvalidWeatherStatementError, Locale, ParseError, Phenomenon, Remark, RemarkType, RunwayInfoTrend, RunwayInfoUnit, SpeedUnit, TAFTrend, TAFTrendDated, TimeIndicator, TimestampOutOfBoundsError, TurbulenceIntensity, UnexpectedParseError, ValueIndicator, Visibility, WeatherChangeType, getCompositeForecastForDate, isWeatherConditionValid, parseMetar, parseTAF, parseTAFAsForecast };
1470
+ export { CloudQuantity, CloudType, CommandExecutionError, Descriptive, Direction, Distance, DistanceUnit, Forecast, IAbstractTrend, IAbstractValidity, IAbstractWeatherCode, IAbstractWeatherCodeDated, IAbstractWeatherContainer, IBaseRemark, IBaseTAFTrend, ICeilingHeightRemark, ICeilingSecondLocationRemark, ICloud, ICompositeForecast, IEndValidity, IFMValidity, IFlags, IForecastContainer, IHourlyMaximumMinimumTemperatureRemark, IHourlyMaximumTemperatureRemark, IHourlyMinimumTemperatureRemark, IHourlyPrecipitationAmountRemark, IHourlyPressureRemark, IHourlyTemperatureDewPointRemark, IIceAccretionRemark, IIcing, IMetar, IMetarDated, IMetarTAFParserOptions, IMetarTAFParserOptionsDated, IMetarTrend, IMetarTrendTime, IObscurationRemark, IPrecipitationAmount24HourRemark, IPrecipitationAmount36HourRemark, IPrecipitationBegEndRemark, IPrevailingVisibilityRemark, IRunwayInfo, ISeaLevelPressureRemark, ISecondLocationVisibilityRemark, ISectorVisibilityRemark, ISmallHailSizeRemark, ISnowIncreaseRemark, ISnowPelletsRemark, ISunshineDurationRemark, ISurfaceVisibilityRemark, ITAF, ITAFDated, ITafGroups, ITemperature, ITemperatureDated, IThunderStormLocationMovingRemark, IThunderStormLocationRemark, ITime, ITornadicActivityBegEndRemark, ITornadicActivityBegRemark, ITornadicActivityEndRemark, ITowerVisibilityRemark, ITurbulence, IUnknownRemark, IValidity, IValidityDated, IVariableSkyHeightRemark, IVariableSkyRemark, IVirgaDirectionRemark, IWaterEquivalentSnowRemark, IWeatherCondition, IWind, IWindPeakCommandRemark, IWindShear, IWindShiftFropaRemark, IcingIntensity, Intensity, InvalidWeatherStatementError, Locale, MetarType, ParseError, Phenomenon, Remark, RemarkType, RunwayInfoTrend, RunwayInfoUnit, SpeedUnit, TAFTrend, TAFTrendDated, TimeIndicator, TimestampOutOfBoundsError, TurbulenceIntensity, UnexpectedParseError, ValueIndicator, Visibility, WeatherChangeType, getCompositeForecastForDate, isWeatherConditionValid, parseMetar, parseTAF, parseTAFAsForecast };
@@ -183,6 +183,11 @@ class CeilingSecondLocationCommand extends Command {
183
183
  }
184
184
  _CeilingSecondLocationCommand_regex = new WeakMap();
185
185
 
186
+ var MetarType;
187
+ (function (MetarType) {
188
+ MetarType["METAR"] = "METAR";
189
+ MetarType["SPECI"] = "SPECI";
190
+ })(MetarType || (MetarType = {}));
186
191
  var CloudQuantity;
187
192
  (function (CloudQuantity) {
188
193
  /**
@@ -2438,6 +2443,9 @@ class MetarParser extends AbstractParser {
2438
2443
  parse(input) {
2439
2444
  const metarTab = this.tokenize(input);
2440
2445
  let index = 0;
2446
+ const type = this.parseType(metarTab[index]);
2447
+ if (type)
2448
+ index++;
2441
2449
  // Only parse flag if precedes station identifier
2442
2450
  if (isStation(metarTab[index + 1])) {
2443
2451
  var flags = findFlags(metarTab[index]);
@@ -2445,8 +2453,9 @@ class MetarParser extends AbstractParser {
2445
2453
  index += 1;
2446
2454
  }
2447
2455
  const metar = {
2448
- ...parseDeliveryTime(metarTab[index + 1]),
2456
+ type,
2449
2457
  station: metarTab[index],
2458
+ ...parseDeliveryTime(metarTab[index + 1]),
2450
2459
  ...flags,
2451
2460
  message: input,
2452
2461
  remarks: [],
@@ -2492,6 +2501,12 @@ class MetarParser extends AbstractParser {
2492
2501
  }
2493
2502
  return metar;
2494
2503
  }
2504
+ parseType(token) {
2505
+ for (const type in MetarType) {
2506
+ if (token === MetarType[type])
2507
+ return type;
2508
+ }
2509
+ }
2495
2510
  }
2496
2511
  _MetarParser_commandSupplier = new WeakMap();
2497
2512
  /**
@@ -3023,4 +3038,4 @@ function parse(rawReport, options, parser, datesHydrator) {
3023
3038
  }
3024
3039
  }
3025
3040
 
3026
- export { CloudQuantity, CloudType, CommandExecutionError, Descriptive, Direction, DistanceUnit, IcingIntensity, Intensity, InvalidWeatherStatementError, ParseError, Phenomenon, RemarkType, RunwayInfoTrend, RunwayInfoUnit, SpeedUnit, TimeIndicator, TimestampOutOfBoundsError, TurbulenceIntensity, UnexpectedParseError, ValueIndicator, WeatherChangeType, getCompositeForecastForDate, isWeatherConditionValid, parseMetar, parseTAF, parseTAFAsForecast };
3041
+ export { CloudQuantity, CloudType, CommandExecutionError, Descriptive, Direction, DistanceUnit, IcingIntensity, Intensity, InvalidWeatherStatementError, MetarType, ParseError, Phenomenon, RemarkType, RunwayInfoTrend, RunwayInfoUnit, SpeedUnit, TimeIndicator, TimestampOutOfBoundsError, TurbulenceIntensity, UnexpectedParseError, ValueIndicator, WeatherChangeType, getCompositeForecastForDate, isWeatherConditionValid, parseMetar, parseTAF, parseTAFAsForecast };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metar-taf-parser",
3
- "version": "7.1.2",
3
+ "version": "7.2.0",
4
4
  "description": "Parse METAR and TAF reports",
5
5
  "homepage": "https://aeharding.github.io/metar-taf-parser",
6
6
  "keywords": [