Geo-GeoNames
view release on metacpan or search on metacpan
lib/Geo/GeoNames.pm view on Meta::CPAN
print ' Latitude: ', $result->[0]->{lat}, "\n";
# Make a query based on postcode
$result = $geo->postalcode_search(
postalcode => '1630', maxRows => 3, style => 'FULL'
);
=head1 DESCRIPTION
Before you start, get a free GeoNames account and enable it for
access to the free web service:
=over 4
=item * Get an account
Go to L<http://www.geonames.org/login>
=item * Respond to the email
=item * Login and enable your account for free access
L<http://www.geonames.org/enablefreewebservice>
=back
Provides a perl interface to the webservices found at
L<http://api.geonames.org>. That is, given a given placename or
postalcode, the module will look it up and return more information
(longitude, latitude, etc) for the given placename or postalcode.
Wikipedia lookups are also supported. If more than one match is found,
a list of locations will be returned.
=cut
# use vars qw($DEBUG $CACHE);
our %searches = (
cities => 'cities?',
country_code => 'countrycode?type=xml&',
country_info => 'countryInfo?',
earthquakes => 'earthquakesJSON?',
find_nearby_placename => 'findNearbyPlaceName?',
find_nearby_postalcodes => 'findNearbyPostalCodes?',
find_nearby_streets => 'findNearbyStreets?',
find_nearby_weather => 'findNearByWeatherXML?',
find_nearby_wikipedia => 'findNearbyWikipedia?',
find_nearby_wikipedia_by_postalcode => 'findNearbyWikipedia?',
find_nearest_address => 'findNearestAddress?',
find_nearest_intersection => 'findNearestIntersection?',
postalcode_country_info => 'postalCodeCountryInfo?',
postalcode_search => 'postalCodeSearch?',
search => 'search?',
wikipedia_bounding_box => 'wikipediaBoundingBox?',
wikipedia_search => 'wikipediaSearch?',
get => 'get?',
hierarchy => 'hierarchy?',
children => 'children?',
);
# r = required
# o = optional
# rc = required - only one of the fields marked with rc is allowed. At least one must be present
# om = optional, multiple entries allowed
# d = deprecated - will be removed in later versions
our %valid_parameters = (
search => {
'q' => 'rc',
name => 'rc',
name_equals => 'rc',
maxRows => 'o',
startRow => 'o',
country => 'om',
continentCode => 'o',
adminCode1 => 'o',
adminCode2 => 'o',
adminCode3 => 'o',
fclass => 'omd',
featureClass => 'om',
featureCode => 'om',
lang => 'o',
type => 'o',
style => 'o',
isNameRequired => 'o',
tag => 'o',
username => 'r',
name_startsWith => 'o', # TODO - should this be rc?
countryBias => 'o',
cities => 'om',
operator => 'o',
searchlang => 'o',
charset => 'o',
fuzzy => 'o',
north => 'o',
west => 'o',
east => 'o',
south => 'o',
orderby => 'o',
},
postalcode_search => {
postalcode => 'rc',
placename => 'rc',
country => 'o',
maxRows => 'o',
style => 'o',
username => 'r',
},
find_nearby_postalcodes => {
lat => 'r',
lng => 'r',
radius => 'o',
maxRows => 'o',
style => 'o',
country => 'o',
username => 'r',
},
postalcode_country_info => {
username => 'r',
},
find_nearby_placename => {
lat => 'r',
lng => 'r',
radius => 'o',
( run in 0.812 second using v1.01-cache-2.11-cpan-39bf76dae61 )