Dirk-Jan Koopman > Geo-TAF > Geo::TAF

Download:
Geo-TAF-1.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.04   Source  

NAME ^

Geo::TAF - Decode METAR and TAF strings

SYNOPSIS ^

  use strict;
  use Geo::TAF;

  my $t = new Geo::TAF;

  $t->metar("EGSH 311420Z 29010KT 1600 SHSN SCT004 BKN006 01/M00 Q1021");
  or
  $t->taf("EGSH 311205Z 311322 04010KT 9999 SCT020
     TEMPO 1319 3000 SHSN BKN008 PROB30
     TEMPO 1318 0700 +SHSN VV///
     BECMG 1619 22005KT");
  or 
  $t->decode("METAR EGSH 311420Z 29010KT 1600 SHSN SCT004 BKN006 01/M00 Q1021");
  or
  $t->decode("TAF EGSH 311205Z 311322 04010KT 9999 SCT020
     TEMPO 1319 3000 SHSN BKN008 PROB30
     TEMPO 1318 0700 +SHSN VV///
     BECMG 1619 22005KT");

  foreach my $c ($t->chunks) {
          print $c->as_string, ' ';
  }
  or
  print $self->as_string;

  foreach my $c ($t->chunks) {
          print $c->as_chunk, ' ';
  }
  or 
  print $self->as_chunk_string;

  my @out = $self->as_strings;
  my @out = $self->as_chunk_strings;
  my $line = $self->raw;
  print Geo::TAF::is_weather($line) ? 1 : 0;

ABSTRACT ^

Geo::TAF decodes aviation METAR and TAF weather forecast code strings into English or, if you sub-class, some other language.

DESCRIPTION ^

METAR (Routine Aviation weather Report) and TAF (Terminal Area weather Report) are ascii strings containing codes describing the weather at airports and weather bureaus around the world.

This module attempts to decode these reports into a form of English that is hopefully more understandable than the reports themselves.

It is possible to sub-class the translation routines to enable translation to other langauages.

METHODS ^

new(%args)

Constructor for the class. Each weather announcement will need a new constructor.

If you sub-class the built-in English translation routines then you can pick this up by called the constructor thus:-

  my $t = Geo::TAF->new(chunk_package => 'Geo::TAF::ES');

or whatever takes your fancy.

decode($line)

The main routine that decodes a weather string. It expects a string that begins with either the word METAR or TAF. It creates a decoded form of the weather string in the object.

There are a number of fixed fields created and also array of chunks chunks() of (as default) Geo::TAF::EN.

You can decode these manually or use one of the built-in routines.

This method returns undef if it is successful, a number otherwise. You can use errorp($r) routine to get a stringified version.

metar($line)

This simply adds METAR to the front of the string and calls decode().

taf($line)

This simply adds TAF to the front of the string and calls decode().

It makes very little difference to the decoding process which of these routines you use. It does, however, affect the output in that it will mark it as the appropriate type of report.

as_string()

Returns the decoded weather report as a human readable string.

This is probably the simplest and most likely of the output options that you might want to use. See also as_strings().

as_strings()

Returns an array of strings without separators. This simply the decoded, human readable, normalised strings presented as an array.

as_chunk_string()

Returns a human readable version of the internal decoded, normalised form of the weather report.

This may be useful if you are doing something special, but see chunks() or as_chunk_strings() for a procedural approach to accessing the internals.

Although you can read the result, it is not, officially, human readable.

as_chunk_strings()

Returns an array of the stringified versions of the internal normalised form without separators.. This simply the decoded (English as default) normalised strings presented as an array.

chunks()

Returns a list of (as default) Geo::TAF::EN objects. You can use $c->as_string or $c->as_chunk to translate the internal form into something readable. There is also a routine ($c->day)to turn a day number into things like "1st", "2nd" and "24th".

If you replace the English versions of these objects then you will need at an as_string() method.

raw()

Returns the (cleaned up) weather report. It is cleaned up in the sense that all whitespace is reduced to exactly one space character.

errorp($r)

Returns a stringified version of any error returned by decode()

ACCESSORS ^

taf()

Returns whether this object is a taf or not.

icao()

Returns the ICAO code contained in the weather report

day()

Returns the day of the month of this report

time()

Returns the issue time of this report

valid_day()

Returns the day this report is valid for (if there is one).

valid_from()

Returns the time from which this report is valid for (if there is one).

valid_to()

Returns the time to which this report is valid for (if there is one).

viz_dist()

Returns the minimum visibility, if present.

viz_units()

Returns the units of the visibility information.

wind_dir()

Returns the wind direction in degrees, if present.

wind_speed()

Returns the wind speed.

wind_units()

Returns the units of wind_speed.

wind_gusting()

Returns any wind gust speed. It is possible to have wind_speed() without gust information.

pressure()

Returns the QNH (altimeter setting atmospheric pressure), if present.

pressure_units()

Returns the units in which pressure() is messured.

temp()

Returns any temperature present.

dewpoint()

Returns any dewpoint present.

ROUTINES ^

is_weather($line)

This is a routine that determines, fairly losely, whether the passed string is likely to be a weather report;

This routine is not exported. You must call it explicitly.

SEE ALSO ^

Geo::METAR

For a example of a weather forecast from the Norwich Weather Centre (EGSH) see http://www.tobit.co.uk

For data see ftp://weather.noaa.gov/data/observations/metar/ ftp://weather.noaa.gov/data/forecasts/taf/ and also ftp://weather.noaa.gov/data/forecasts/shorttaf/

To find an ICAO code for your local airport see http://www.ar-group.com/icaoiata.htm

AUTHOR ^

Dirk Koopman, mailto:djk@tobit.co.uk

COPYRIGHT AND LICENSE ^

Copyright (c) 2003 by Dirk Koopman, G1TLH

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: