fboes / metar-parser

✈️ Parse METAR information into structured JavaScript object
MIT License
23 stars 7 forks source link

TEMPO FIELD #2

Open zeus1999 opened 1 year ago

zeus1999 commented 1 year ago

example: EDDF 221420Z AUTO 20013KT 160V230 CAVOK 33/17 Q1011 TEMPO SHRA

output:

{
  raw_text: 'EDDF 221420Z AUTO 20013KT 160V230 CAVOK 33/17 Q1011 TEMPO SHRA',
  raw_parts: [
    'EDDF',    '221420Z',
    'AUTO',    '20013KT',
    '160V230', 'CAVOK',
    '33/17',   'Q1011',
    'TEMPO',   'SHRA'
  ],
  icao: 'EDDF',
  observed: 2023-06-22T14:20:19.372Z,
  wind: {
    degrees: 200,
    speed_kts: 13,
    speed_mps: 6.687777751769754,
    gust_kts: 13,
    gust_mps: 6.687777751769754,
    degrees_from: 160,
    degrees_to: 230
  },
  visibility: {
    miles: '10',
    miles_float: 10,
    meters: '16000',
    meters_float: 16093.44
  },
  temperature: { celsius: 33, fahrenheit: 91.4 },
  dewpoint: { celsius: 17, fahrenheit: 62.6 },
  humidity_percent: 38.488718673594086,
  barometer: { hg: 29.854817868, kpa: 101.1, mb: 1011 },
  flight_category: 'VFR'
}

but TEMPO SHRA isnt parsed.

is it possible to add this as a feature?

fboes commented 1 year ago

@zeus1999 Currently there is a simple trick to find a certain extra property in the METAR object: You can search the raw_parts with indexOf():

[
    'EDDF',    '221420Z',
    'AUTO',    '20013KT',
    '160V230', 'CAVOK',
    '33/17',   'Q1011',
    'TEMPO',   'SHRA'
].indexOf('SHRA'); // is > -1

Or do you have something more accessible in mind? Or at least an extra property for all unparsed METAR parts?