Index of /perl/yahoo/geocoder
Name Last modified Size Description
Parent Directory -
Changes 2008-11-22 09:15 139
Yahoo-Geocoder-1.0.t..> 2008-11-22 09:15 4.2K GZIP compressed docume>
NAME
Yahoo::Geocoder - Simple OO wrapper for Yahoo geocoder REST API
SYNOPSIS
use Yahoo::Geocoder;
use Error qw(:try);
my $geo = Yahoo::Geocoder->new({appid=>"yer_appid_here"});
my $xpath = undef;
try {
$xpath = $geo->geocode({location=>"Montreal, QC"});
}
catch Yahoo::Geocoder::ConfigError with {
my $e = shift;
die "There's something wrong with your request. $e";
}
catch Yahoo::Geocoder::HTTPError with {
my $e = shift;
die "There was a problem talking to Yahoo! $e";
}
catch Yahoo::Geocoder::XMLParseError with {
my $e = shift;
die "There was a problem with the data sent back by Yahoo! $e";
}
otherwise {
my $e = shift;
die "OMGWTF?!?! $e";
};
foreach my $place ($xpath->findnodes("/ResultSet/Result")) {
print $place->findvalue("Latitude");
}
# And for people who prefer good
# old-fashion hash references - for
# the sake of brevity, we'll assume
# the request throws no errors
my @results = $geo->geocode_as_list({location=>"Springfield"});
foreach my $place (@results) {
print $place->{Latitude};
}
DESCRIPTION
Simple OO wrapper for Yahoo geocoder REST API.
PACKAGE METHODS
__PACKAGE__->new(\%args)
Valid arguments are :
* appid
String.
Your Yahoo! application ID.
Returns a *Yahoo::Geocoder* object, which subclasses *LWP::UserAgent*
__PACKAGE__->service_url()
Returns a string.
__PACKAGE__->request_params()
Returns a list.
__PACKAGE__->response_fields()
Returns a list.
__PACKAGE__->response_attributes()
Returns a list.
OBJECT METHODS
$obj->geocode(\%args)
Valid arguments are :
* address
String.
* city
String.
* state
String.
* zip
String.
* appid
String.
At least one argument, not including *appid* is required. If <appid> is
present, it will override any application ID passed to the object's
constructor.
Returns a *XML::XPath* object on success. Throws an *Error::Simple*
derived exception if there was a problem.
$obj->geocode_as_list(\%args)
This is a clone of the *geocode* method whose only difference is it's
return value.
Returns a list of hash references on success. Throws an *Error::Simple*
derived exception if there was a problem.
$api_call($url)
Returns a *XML::XPath* object on success. Throws an *Error::Simple*
derived exception if there was a problem.
$obj->do_request($url)
Returns a *HTTP::Response* object on success. Throws an *Error::Simple*
derived exception if there was a problem.
$obj->parse_response(HTTP::Response)
Returns a *XML::XPath* object on success. Throws an *Error::Simple*
derived exception if there was a problem.
$obj->node_to_hashref(XML::XPath::Node)
Returns a hash reference.
VERSION
1.0
DATE
$Date: 2005/11/06 17:49:27 $
AUTHOR
Aaron Straup Cope <ascope@cpan.org>
SEE ALSO
http://developer.yahoo.net/maps/rest/V1/geocode.html
LICENSE
Copyright (c) 2005 Aaron Straup Cope. All Rights Reserved.
This is free software. You may redistribute it and/or modify it under
the same terms as Perl itself.