NAME

Geo::Coder::Bing::Bulk - Geocode addresses in bulk with the Bing Spatial Data Services API

SYNOPSIS

use Geo::Coder::Bing::Bulk;

my $bulk = Geo::Coder::Bing::Bulk->new(key => 'Your Bing Maps key');
my $id = $bulk->upload(\@locations);
sleep 30 while $bulk->is_pending;
my $data = $bulk->download;
my $failed = $bulk->failed;

DESCRIPTION

The Geo::Coder::Bing::Bulk module provides an interface to the Bing Spatial Data Services API.

METHODS

new

$bulk = Geo::Coder::Bing->new('Your Bing Maps key')
$bulk = Geo::Coder::Bing->new(
    key => 'Your Bing Maps key',
    id  => 'Job ID',
)

Creates a new bulk geocoding object.

A Bing Maps key can be obtained here: http://msdn.microsoft.com/en-us/library/ff428642.aspx.

Accepts an optional https parameter for securing network traffic.

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

Accepts an optional id parameter from a previous call to "upload".

upload

$id = $bulk->upload(\@locations)

Submits a single bulk query for all the given location strings and returns the assigned job id.

Note that query size is limited to 300 MB (uncompressed) and 200,000 locations; there is a limit of 10 concurrent bulk jobs and 50 jobs per 24 hours.

is_pending

$bool = $bulk->is_pending

Polls for the job status and returns true if it has not yet completed.

download

$array_ref = $bulk->download

Downloads the results of the query and returns an array reference if there were results. A typical result looks like:

{
    Address => {
        AddressLine   => "W Sunset Blvd & Los Liones Dr",
        AdminDistrict => "CA",
        CountryRegion => "United States",
        FormattedAddress =>
            "W Sunset Blvd & Los Liones Dr, Pacific Palisades, CA 90272",
        Locality   => "Pacific Palisades",
        PostalCode => 90272,
    },
    Confidence => "High",
    DisplayName =>
        "W Sunset Blvd & Los Liones Dr, Pacific Palisades, CA 90272",
    EntityType => "RoadIntersection",
    Id         => 0,
    InterpolatedLocation =>
        { Latitude => "34.04185", Longitude => "-118.554" },
    Query      => "Sunset Blvd and Los Liones Dr, Pacific Palisades, CA",
    StatusCode => "Success",
},

failed

$array_ref = $bulk->failed

Returns an array reference if there were query failures.

Note that Bing will report invalid addresses as successfully geocoded even though it could not determine its location. Failures appear to only concern query construction- ex. missing fields, etc. So this is likely not going to affect users of this module- until advanced locations (hashrefs of fields) are permitted.

response

$response = $bulk->response()

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

ua

$ua = $bulk->ua()
$ua = $bulk->ua($ua)

Accessor for the UserAgent object.

SEE ALSO

http://msdn.microsoft.com/en-us/library/ff701734.aspx

Geo::Coder::Bing

REQUESTS AND BUGS

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

You can also look for information at:

COPYRIGHT AND LICENSE

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