| Net-Geohash documentation | Contained in the Net-Geohash distribution. |
Net::Geohash - The great new Net::Geohash!
Version 1.1
Quick summary of what the module does.
Perhaps a little code snippet.
use Net::Geohash;
my $ghurl = Net::Geohash::get('37.391012 -122.071873');
...
The get function accepts a string containing the lat/lon to send to geohash.org for hashing. It returns the fully qualified geohash.org url on success. If an error occurs it will give a warning message and return an empty string.
Location names such as 'Paris, France' can also be given.
Nick Gerakines, <nick at gerakines.net>
Please report any bugs or feature requests to
bug-net-geohash at rt.cpan.org, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Geohash.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Net::Geohash
You can also look for information at:
http://del.icio.us/tag/geohash
Copyright 2008 Nick Gerakines, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Net-Geohash documentation | Contained in the Net-Geohash distribution. |
package Net::Geohash; use strict; use warnings; use LWP::UserAgent; our $VERSION = '1.1'; sub get { my ($coords) = shift @_; if (! $coords) { warn 'Missing lattitude/longitude param'; return ''; } if (@_) { warn 'Extra parameters found.'; return; } my $ua = LWP::UserAgent->new(); $ua->agent('perl-Net-Geohash/' . $VERSION ); $ua->max_redirect(0); my $resp = $ua->get('http://geohash.org/?q=' . $coords); if ($resp->code() eq '303') { if (my $loc = $resp->header('location')) { if ($loc eq 'http://geohash.org/') { warn 'geohash.org response indicates that the geocode was invalid.'; return ''; } return $loc; } else { return ''; } } warn 'geohash.org response was not a redirect, possibly invalid geocoords.'; return ''; }
1; # End of Net::Geohash