NAME

Geo::Coder::OSM - Geocode addresses with the OpenStreetMap Nominatim API

SYNOPSIS

use Geo::Coder::OSM;

my $geocoder = Geo::Coder::OSM->new;
my $location = $geocoder->geocode(
    location => 'Hollywood and Highland, Los Angeles, CA'
);

DESCRIPTION

The Geo::Coder::OSM module provides an interface to the OpenStreet Nominatim geocoding service.

METHODS

new

$geocoder = Geo::Coder::OSM->new();

Creates a new geocoding object.

Accepts an optional ua parameter for passing in a custom LWP::UserAgent object.

geocode

$location = $geocoder->geocode(location => $location)
@locations = $geocoder->geocode(location => $location)

In scalar context, this method returns the first location result; and in list context it returns all locations results.

Each location result is a hashref; a typical example looks like:

{
    address => {
        city         => "Los Angeles",
        country      => "United States of America",
        country_code => "us",
        hamlet       => "Hollywood",
        road         => "Hollywood Boulevard",
        station      => "Hollywood/Highland",
        suburb       => "Little Armenia",
    },
    boundingbox => [
        "34.101634979248",   "34.1018371582031",
        "-118.339317321777", "-118.33910369873",
    ],
    class => "railway",
    display_name =>
        "Hollywood/Highland, Hollywood Boulevard, Little Armenia, Hollywood, Los Angeles, United States of America",
    icon =>
        "http://nominatim.openstreetmap.org/images/mapicons/transport_train_station2.p.20.png",
    lat => "34.101736",
    licence =>
        "Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.",
    lon      => "-118.33921",
    osm_id   => 472413621,
    osm_type => "node",
    place_id => 9071654,
    type     => "station",
}

response

$response = $geocoder->response()

Returns an HTTP::Response object for the last submitted request. Can be used to determine the details of an error.

ua

$ua = $geocoder->ua()
$ua = $geocoder->ua($ua)

Accessor for the UserAgent object.

SEE ALSO

http://wiki.openstreetmap.org/wiki/Nominatim

Geo::Coder::Bing, Geo::Coder::Google, Geo::Coder::Mapquest, Geo::Coder::Multimap, Geo::Coder::Yahoo

REQUESTS AND BUGS

Please report any bugs or feature requests to http://rt.cpan.org/Public/Bug/Report.html?Queue=Geo-Coder-OSM. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Geo::Coder::OSM

You can also look for information at:

COPYRIGHT AND LICENSE

Copyright (C) 2010 gray <gray at cpan.org>, all rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

gray, <gray at cpan.org>