Хранилища Subversion geo-modmetar

Сравнить редакции

Не учитывать пробелы Редакция 4 → Редакция 5

/tags/1.0/README
Новый файл
0,0 → 1,75
Readme for Geo::ModMETAR
 
Accessing Aviation Weather Information with Perl.
 
Copyright (c) 1997-2000, Jeremy D. Zawodny <Jeremy@Zawodny.com>
Copyright (c) 2007, Koos van den Hout <koos@kzdoos.xs4all.nl>
Copyright (c) 2010, Alexander Wolf <alex.v.wolf@gmail.com>
 
 
BACKGROUND
 
This is the README file for the Geo::ModMETAR Perl module.
 
The Geo::ModMETAR home page is located at:
 
http://astro.uni-altai.ru/~aw/perl/Geo-ModMETAR/
 
There may be bugs in the code as well as in the documentation. If
you find either, I'd appreciate a patch or at least a mail message
to let me know what's wrong so that I can add it to the TODO list.
 
Geo::ModMETAR as been developed and tested on Linux and Solaris
as well as Windows NT. It may well work on other platforms. It is
pure Perl. If you install it on another platform, and have trouble
I'd like to hear about it. If you develop patches for that
platform, I'd REALLY like to hear about it. Send me a note.
 
REQUIREMENTS
 
You will need Perl 5.005 or newer to install and use
Geo::ModMETAR. It may work with older versions of Perl, but I
make no guarantees.
 
 
INSTALLATION
 
Installing Geo::ModMETAR is an easy process.
 
$ perl Makefile.PL
$ make
$ make test
$ make install
 
 
DOCUMENTATION
 
The documentation is built-in to the Geo::ModMETAR module in POD
format. You can use any of the pod2* converters to translate it
to a more readable format. The three most common formats are
'man', 'html', and 'text'.
 
When you ran the 'make install' above, documentation should have
been installed on your system such that 'perldoc Geo::ModMETAR'
will spit it out. Of course, you can run your favorite pod
converter and generate it in alternative formats.
 
 
EXAMPLE SCRIPTS
 
The following scripts are included in the `examples'
directory. They are provided as examples. They should provide an
idea of what you can do with this module.
 
simple_dump.pl Process a simple ModMETAR.
fetch_temp.pl Fetch the temperature and print it out.
 
If you develop a good example that would be useful to others, I'd
be glad to add it to the distribution.
 
 
TODO LIST
 
If you're wondering what will come next in Geo::ModMETAR, see
the TODO file.
 
/tags/1.0/examples/fetch_temp.pl
Новый файл
0,0 → 1,80
#!/usr/bin/perl -w
 
# $Id: fetch_temp.pl,v 1.1 2007/11/13 21:19:27 koos Exp $
 
# Brief Description
# =================
#
# fetch_temp.pl is a program that demonstrates how to get the current
# temperature from a nearby (or not) airport using Geo::METAR and the
# LWP modules.
#
# Given an airport site code on the command line, fetch_temp.pl
# fetches the current temperature and displays it on the
# command-line. For fun, here are some example airports:
#
# LA : KLAX
# Dallas : KDFW
# Detroit: KDTW
# Chicago: KMDW
 
# Get the site code.
 
my $site_code = shift @ARGV;
 
die "Usage: $0 <site_code>\n" unless $site_code;
 
# Get the modules we need.
 
use Geo::ModMETAR;
use LWP::UserAgent;
use strict;
 
my $ua = new LWP::UserAgent;
 
my $req = new HTTP::Request GET =>
"http://weather.noaa.gov/cgi-bin/mgetmetar.pl?cccc=$site_code";
 
my $response = $ua->request($req);
 
if (!$response->is_success) {
 
print $response->error_as_HTML;
my $err_msg = $response->error_as_HTML;
warn "$err_msg\n\n";
die "$!";
 
} else {
 
# Yep, get the data and find the METAR.
 
my $m = new Geo::ModMETAR;
my $data;
$data = $response->as_string; # grap response
$data =~ s/\n//go; # remove newlines
$data =~ m/($site_code\s\d+Z.*?)</go; # find the METAR string
my $metar = $1; # keep it
 
# Sanity check
 
if (length($metar)<10) {
die "METAR is too short! Something went wrong.";
}
 
# pass the data to the METAR module.
$m->metar($metar);
 
# ask for the temperature(s)
my $f_temp = $m->TEMP_F;
my $c_temp = $m->TEMP_C;
 
my $time = localtime(time);
print "The temperature at $site_code is $f_temp F ($c_temp C) as of $time.\n";
 
} # end else
 
exit;
 
__END__
 
 
/tags/1.0/examples/simple_dump.pl
Новый файл
0,0 → 1,12
#!/usr/bin/perl
 
# $Id: simple_dump.pl,v 1.1 2007/11/13 21:19:27 koos Exp $
 
# Example script for METAR.pm.
 
use Geo::ModMETAR;
 
my $m = new Geo::ModMETAR;
$m->metar("KFDY 251450Z 21012G21KT 8SM OVC065 04/M01 A3010 RMK 57014");
$m->dump;
exit;