
WWW::MySociety::Gaze - An interface to MySociety.org's Gazetteer service

This document describes WWW::MySociety::Gaze version 0.02

use WWW::MySociety::Gaze;

MySociety.org Gaze is a REST based gazetteer service. You can find out more about it here:
http://www.mysociety.org/2005/09/15/gaze-web-service/
WWW::MySociety::Gaze is a Perl wrapper around Gaze.

newCreate a new WWW::MySociety::Gaze.
get_country_from_ip( $ip )Guess the country of location of a host from its dotted quad IP address. Returns an ISO country code or undef if the country code is unknown.
my $gaze = WWW::MySociety::Gaze->new;
my $country = $gaze->get_country_from_ip( '82.152.157.85' );
get_find_places_countriesReturn the list of countries for which find_places has a gazetteer available.
Takes no arguments, returns a list of ISO country codes.
my $gaze = WWW::MySociety::Gaze->new;
my @countries = $gaze->get_find_places_countries;
find_placesLookup a location in the gazetteer. Takes a number of key, value pairs as follows:
countryISO country code of country in which to search for places
stateState in which to search for places; presently this is only meaningful for country=US (United States), in which case it should be a conventional two-letter state code (AZ, CA, NY etc.); optional
queryQuery term input by the user; must be at least two characters long
maxresultsLargest number of results to return, from 1 to 100 inclusive; optional; default 10
minscoreMinimum match score of returned results, from 1 to 100 inclusive; optional; default 0
Returns a list of hash references. Each hash has the following fields:
NameName of the place described by this row
InBlank, or the name of an administrative region in which this place lies (for instance, a county)
NearA reference to a (possibly empty) array of nearby placenames.
LatitudeWGS-84 latitude of place in decimal degrees, north-positive
LongitudeWGS-84 longitude of place in decimal degrees, east-positive
StateBlank, or containing state code for US
ScoreMatch score for this place, from 0 to 100 inclusive
get_population_density( $lat, $lon )Given a latitude, longitude pair return an estimate of the population density at (lat, lon), in persons per square kilometer.
get_radius_containing_populationReturn an estimate of the smallest radius around (lat, lon) containing at least number persons, or maximum, if that value is smaller. Takes key value parameters:
latWGS84 latitude, in decimal degrees
lonWGS84 longitude, in decimal degrees
numbernumber of persons
maximumlargest radius returned, in kilometers; optional; default 150
get_country_bounding_coordsGet the bounding box of a country given its ISO country code. Returns a four element list containing max_lat, min_lat, max_lon, min_lon.
my @bb = $gaze->get_country_bounding_coords( 'GB' );
get_places_nearGet a list of places near a specific location. Takes a list of name, value pairs like this:
latWGS84 latitude, in north-positive decimal degrees
lonWGS84 longitude, in east-positive decimal degrees
distancedistance in kilometres
numbernumber of persons to calculate circle radius
maximummaximum radius to return (default 150km)
countryISO country code of country to limit results to (optional)
Returns a list of hash references like this:
NameName of the nearby place.
DistanceDistance from the base place.
LatitudeLatitude of the nearby place.
LongitudeLongitude of the nearby place.
CountryCountry of the nearby place.
StateState of the nearby place (currently US only).

WWW::MySociety::Gaze requires no configuration files or environment variables.

None.

None reported.

No bugs have been reported.
Please report any bugs or feature requests to bug-www-mysociety-gaze@rt.cpan.org, or through the web interface at http://rt.cpan.org.

Andy Armstrong <andy@hexten.net>

Copyright (c) 2008, Andy Armstrong <andy@hexten.net>.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.