SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

BotDetect - Real-Time Bot Detection API
 
 

MAN page from Mandrake Other perl-Geo-WeatherNOAA-3.09-1.i386.rpm

WeatherNOAA

Section: User Contributed Perl Documentation (3)
Updated: perl 5.004, patch 04
Index 

NAME

Geo::WeatherNOAA - Perl extension for getting NOAA Weather(Wx) Data 

SYNOPSIS

  use Geo::WeatherNOAA;  print get_currentWX_html('NEW YORK','NY');  print_forecast('NEW YORK','NY');
  %wx = get_forecast('BOSTON','MA');  print "The forecast is $wx{NEAR}\n";  print "The extended forecast is $wx{EXTENDED}\n";  print "This information was updated $wx{Date}\n";  print "The affected areas are $wx{Coverage}\n";
 

DESCRIPTION

I needed a way to get NOAA weather data for both web pages andperl scripts for web pages etc. This module gets information from theNOAA web site and ``decodes'' it into usable format: hashes, lists, english, etc. 

FUNCTIONS

The idea behind these function calls is simplicity. Each function needsat least the city and state. If you want to use the neato cacheingfunction, give the minutes to cache and, optionally, the directory touse to hold the weather data cache.
get_forecast(CITY,STATE,CACHE,CACHEDIR,LWP_UserAgent)

Call with at least to tokens: City and State (Two letter abbr)

The third token, if used will tell the module to use thecaching function so that the data will only be retrievedfrom NOAA when the cached data is this many minutes old.I figured this would be usefull to a web server where onlythe first `hit' would have to wait for the remote data.

The fourth argument is the directory in which to cache the data.If omitted, the module will use /tmp/wxdata

The fifth argument is for a user created LWP::UserAgent(3) whichcan be configured to work with firewalls. See the LWP::UserAgent(3)manpage for specific instructions. A basic example is like this:

    my $ua = new LWP::UserAgent;    $ua->proxy(['http', 'ftp'], 'http://proxy.my.net:8080/');
This function returns a hash with the following keys:

  Coverage      => A list of the affected areas for the forecast  Date          => Date/time when the data was reported to NOAA  NEAR          => Newline delineated list, each line contains                   a colon (:) delin list of day and data.                   NOTE: If there's no data, the "key" is a weather                   warning  EXTENDED      => Same as NEAR but without weather warnings  URL           => URL where the data originated
It can be used like this:

  use Geo::WeatherNOAA;  %wx = get_forecast('BOSTON','MA');  print "The forecast is $wx{NEAR}\n";  print "The extended forecast is $wx{EXTENDED}\n";  print "This information was updated $wx{Date}\n";  print "and covers $wx{Coverage}\n";
In examples/wx.cgi, I split the NEAR and EXTENDED fields to make nicer output:

  use Geo::WeatherNOAA;  %wx = get_forecast('BOSTON','MA');  print "<TABLE>\n";  foreach $line (split "\n", $wx{NEAR}) {      my ($day,$data) = split /:/, $line;
      if ($data) {          # Normal line if there are both keys          print "<TR><TD>$day</TD><TD>$data</TD></TR>\n";      } else {          # Warning line if there's only the $day value          print "<TR><TD COLSPAN=2>$day</TD></TR>\n";      }  }       print "</TABLE>\n";

print_forecast(CITY,STATE)

Prints an english (text) description of the forecast

Its output looks like this:

        Forecast for BLACKSBURG, VA for March 6, 1998
  WARNING: The national weather service has issued a flood watch for    late tonight through monday      WARNING: A wind advisory has also been posted for very late tonight     through monday... 
  Tonight: Showers...With a chance of thunderstorms.  Lows in the upper    40s. South wind around 15 mph. Chance of rain near 100 percent.
  Monday: Showers with a chance of thunderstorms...Mainly in the     morning.
  Turning cooler.  Temperatures falling into the lower 40s. West wind    around 15 mph.  Chance of rain 90 percent.      Monday night: Mostly cloudy with a chance of rain or snow. Breezy.     Lows mostly in the 20s. Chance of precipitation 40 percent.      Tuesday: Partly cloudy with a chance of snow flurries.            Colder and breezy. Highs from the upper 20s to near 40.     

get_currentWX(CITY,STATE,CACHE,CACHEDIR,LWP_UserAgent)

Call with at least to tokens: City and State (Two letter abbr)

The third token, if used will tell the module to use thecaching function so that the data will only be retrievedfrom NOAA when the cached data is this many minutes old.I figured this would be usefull to a web server where onlythe first `hit' would have to wait for the remote data.

The fourth argument is the directory in which to cache the data.If omitted, the module will use /tmp/wxdata

The fifth argument is for a user created LWP::UserAgent(3) whichcan be configured to work with firewalls. See the LWP::UserAgent(3)manpage for specific instructions. A basic example is like this:

    my $ua = new LWP::UserAgent;    $ua->proxy(['http', 'ftp'], 'http://proxy.my.net:8080/');
This function returns a hash with the following keys:

  CITY          => Name of reported city  SKY/WX        => Sky conditions  TEMP          => Current temp  DEWPT         => Dewpoint  RH            => ???  WIND          => Wind direction and speed  PRES          => Pressure  REMARKS       => Remarks

get_current_html(CITY,STATE,CACHE)

Call with at least to tokens: City and State (Two letter abbr)

The third token, if used will tell the module to use the        caching function so that the data will only be retrieved
        from NOAA when the cached data is this many minutes old.
        I figured this would be usefull to a web server where only
        the first `hit' would have to wait for the remote data.

This call returns a scalar containing a (sort-of) htmlized englishsentence describing the weather in the requested city.

  use Geo::WeatherNOAA;  $weather = get_currentWX_html('RICHMOND','VA');  print "$weather\n";
The output looks like this:

  At 8:00pm EST, Richmond, VA was experiencing cloudy skies at 66°F,  wind is south at 15mph. 
 

AUTHOR

Mark Solomon

msolomonAATTseva.net

http://www.seva.net/~msolomon/wx/ 

SEE ALSO

perl(1), LWP(3), LWP::UserAgent(3).


 

Index

NAME
SYNOPSIS
DESCRIPTION
FUNCTIONS
AUTHOR
SEE ALSO

This document was created byman2html,using the manual pages.
 
ICM Bot detect detector