GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Geo::Coder::OSM(3) User Contributed Perl Documentation Geo::Coder::OSM(3)

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

    use Geo::Coder::OSM;

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

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

    $geocoder = Geo::Coder::OSM->new()
    $geocoder = Geo::Coder::OSM->new(
        ua      => $ua,
        sources => [ 'osm', 'mapquest' ],
        debug   => 1,
    )

Creates a new geocoding object.

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

Accepts an optional sources parameter for specifying the data sources. Current valid values are osm and mapquest. The default value is osm. To cycle between different sources, specify an array reference for the sources value. To define additional sources, see "SOURCES" below.

    $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 location 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",
    }

    $location = $geocoder->reverse_geocode(lat => $lat, lon => $lon)
    $location = $geocoder->reverse_geocode(latlng => "$lat,$lon")

Returns a location result for the given lat/lon pair.

    $response = $geocoder->response()

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

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

Accessor for the UserAgent object.

To define additional sources add them to the %SOURCES package variable like so:

    $Geo::Coder::OSM::SOURCES{local} = 'http://127.0.0.1/api_base_path';
    $Geo::Coder::OSM::SOURCES{internal} = 'http://internal.corp/api_base_path';

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

<http://open.mapquestapi.com/nominatim/>

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.

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

    perldoc Geo::Coder::OSM

You can also look for information at:

  • GitHub Source Repository

    <http://github.com/gray/geo-coder-osm>

  • AnnoCPAN: Annotated CPAN documentation

    <http://annocpan.org/dist/Geo-Coder-OSM>

  • CPAN Ratings

    <http://cpanratings.perl.org/d/Geo-Coder-OSM>

  • RT: CPAN's request tracker

    <http://rt.cpan.org/Public/Dist/Display.html?Name=Geo-Coder-OSM>

  • Search CPAN

    <http://search.cpan.org/dist/Geo-Coder-OSM/>

Copyright (C) 2010-2013 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.

gray, <gray at cpan.org>
2013-11-13 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.