NAME
Weather::Bug::Station - Simple class interface to the WeatherBug station data
VERSION
This document describes Weather::Bug::Station version 0.25
SYNOPSIS
use Weather::Bug;
my $wbug = Weather::Bug->new( 'YOURAPIKEYHERE' );
my @stations = $wbug->list_stations( 77096 );
for my $s (@stations)
{
my $l = $s->location();
printf( "%s: %s\n\tin %s, %s %s\n\t(%0.5f,%0.5f), (dist=%0.3f, type=%s)\n",
$s->id(), $s->name(),
$l->city(), $l->state(), $l->zipcode(),
$l->latitude(), $l->longitude(),
$l->distance(), $l->station_type()
);
}
DESCRIPTION
The Station class wraps the concept of a WeatherBug station. A Station object provides some information about its location and identity. Since actual weather observations are made at particular stations, this object also supplies the methods needed to request the current weather.
INTERFACE
The Station interface can be divided into three groups of methods: factory methods, accessor methods, and request methods.
Factory Methods
Since the Station object will almost always be created from an XML stream, this class provides a set of methods for constructing a Station object from the XML responses.
- from_xml
-
Extract the station information from an aws:station node, such as the ones returned by the getStations WeatherBug request.
Return a new Weather::Bug::Station object on success.
- from_compact_xml
-
Extract the station information from an
aws:weather
node, such as the ones returned by the getLiveCompactWeather WeatherBug request.Return a new Weather::Bug::Station object on success.
- from_obs_xml
-
Extract the station information from an
aws:obs
node, such as the ones returned by the getLiveWeather WeatherBug request.- $bug
-
the Weather::Bug object
- $statnode
-
the
aws:obs
XML node
Return a new Weather::Bug::Station object on success.
Accessor Methods
The Station object provides accessor methods for the following fields:
- id
-
This is the short ID string that can be used to refer to a particular WeatherBug station.
- name
-
This is a longer printable name for the WeatherBug station.
- location
-
This is a Weather::Bug::Location object that describes the location of the station.
- station_type
-
This is a string telling what kind of station this is. This value appears to be either WeatherBug or NWS (National Weather Service).
- url
-
An optional URL associated with the Station returned as a string.
- has_url
-
A boolean method that returns a true value if the Station has an associated URL.
- is_equivalent
-
Returns true if all of the required elements of the Station match those of the other Station and if both Stations have a URL, they match.
Request Methods
- get_live_weather
-
Perform a request on this Station to get the live weather. A Weather::Bug::Weather object representing the current weather is returned.
- get_live_compact_weather
-
Perform a request on this Station to get the compact version of the live weather. A Weather::Bug::CompactWeather object representing the current weather is returned.
Request for '%s' failed.
-
The request to the WeatherBug API was not successful. The
%s
is the name of the page that failed. Unable to parse output from '%s' request.
-
Although the WeatherBug API did return successfully, the output could not be parsed as well-formed XML. The
%s
is the name of the page that failed. No '%s' node found.
-
Although the WeatherBug API did return successfully, the output XML did not contain the specified node.
CONFIGURATION AND ENVIRONMENT
Weather::Bug requires no configuration files or environment variables.
DEPENDENCIES
Moose
, XML::LibXML
.
INCOMPATIBILITIES
None reported.
BUGS AND LIMITATIONS
No bugs have been reported.
Please report any bugs or feature requests to bug-weather-weatherbug@rt.cpan.org
, or through the web interface at http://rt.cpan.org.
AUTHOR
G. Wade Johnson <wade@anomaly.org>
LICENCE AND COPYRIGHT
Copyright (c) 2008, G. Wade Johnson <wade@anomaly.org>
. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.