NAME

Geo::Coder::Mappy - Geocode addresses with the Mappy AJAX API

SYNOPSIS

use Geo::Coder::Mappy;

my $geocoder = Geo::Coder::Mappy->new(
    token => 'Your Mappy AJAX API token'
);
my $location = $geocoder->geocode(
    location => '47 Rue de Charonne, 75011 Paris, France'
);

DESCRIPTION

The Geo::Coder::Mappy module provides an interface to the geocoding functionality of the Mappy AJAX API.

METHODS

new

$geocoder = Geo::Coder::Mappy->new('Your Mappy AJAX API token')
$geocoder = Geo::Coder::Mappy->new(
    token => 'Your Mappy AJAX API token',
    https => 1,
    debug => 1,
)

Creates a new geocoding object.

An API token can be obtained here: http://connect.mappy.com/en/product/add/free

Accepts an optional https parameter for securing network traffic.

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 location results.

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

{
    AddressDetails => {
        Country => {
            AdministrativeArea => {
                AdministrativeAreaName => "Ile-de-France",
                Locality               => {
                    LocalityName => "Paris",
                    Thoroughfare => {
                        PostalCode
                            => { PostalCodeNumber => 75011 },
                        ThoroughfareName   => "Rue de Charonne",
                        ThoroughfareNumber => [
                            { Type => "Interpolated", value => 47 },
                            { Type => "Requested",    value => 47 },
                        ],
                        Type => 1,
                    },
                    Type => 1,
                },
            },
            CountryName => "France",
            CountryNameCode =>
                { Scheme => "ISO 3166-1 numeric", value => 250 },
        },
        xmlns => "urn:oasis:names:tc:ciq:xsdschema:xAL:2.0",
    },
    ExtendedData => {
        "mappy:address" =>
            "47, Rue de Charonne, 75011, Paris, Ile-de-France, France",
        "mappy:coordinates_system" => 4326,
        "mappy:geocode_level"      => {
            "mappy:code"  => 4,
            "mappy:label" => "Road element level geocoding"
        },
        "mappy:global_score"      => "100.000000",
        "mappy:LocalGeocodeLevel" => {
            "mappy:code"  => 5,
            "mappy:label" => "Road element level geocoding"
        },
        "mappy:OfficialTownCode"        => 75056,
        "mappy:road_element_id"         => "202500065742970",
        "mappy:road_element_percentage" => "50.00",
        "mappy:SubcountryIsoCode"       => 11,
        "xmlns:mappy"
            => "http://schemas.mappy.com/loc/2.1",
    },
    name  => "47 Rue de Charonne 75011 Paris",
    Point => { coordinates => "2.377409,48.853351" },
}

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://connect.mappy.com/en/api/overview

REQUESTS AND BUGS

Please report any bugs or feature requests to http://rt.cpan.org/Public/Bug/Report.html?Queue=Geo-Coder-Mappy. 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::Mappy

You can also look for information at:

COPYRIGHT AND LICENSE

Copyright (C) 2011 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>