|
Geo::TAF - Decode METAR and TAF strings |
Geo::TAF - Decode METAR and TAF strings
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;
Geo::TAF decodes aviation METAR and TAF weather forecast code strings into English or, if you sub-class, some other language.
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.
new(%args)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)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)METAR to the front of the string and calls
decode().
taf($line)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()This is probably the simplest and most likely of the output options that you might want to use. See also as_strings().
as_strings()as_chunk_string()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()chunks()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()errorp($r)
taf()icao()day()time()valid_day()valid_from()valid_to()viz_dist()viz_units()wind_dir()wind_speed()wind_units()wind_gusting()pressure()pressure_units()temp()dewpoint()
is_weather($line)This routine is not exported. You must call it explicitly.
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
Dirk Koopman, mailto:djk@tobit.co.uk
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.
|
Geo::TAF - Decode METAR and TAF strings |