Giter VIP home page Giter VIP logo

geo-coder-geocodefarm's Introduction

NAME

Geo::Coder::GeocodeFarm - Geocode addresses with the GeocodeFarm API

SYNOPSIS

use Geo::Coder::GeocodeFarm;

my $geocoder = Geo::Coder::GeocodeFarm->new(
    key => '3d517dd448a5ce1c2874637145fed69903bc252a'
);
my $result = $geocoder->geocode(
    location => '530 West Main St Anoka MN 55303'
);
printf "%f,%f",
    $result->{COORDINATES}{latitude},
    $result->{COORDINATES}{longitude};

DESCRIPTION

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

METHODS

new

$geocoder = Geo::Coder::GeocodeFarm->new(
    key    => '3d517dd448a5ce1c2874637145fed69903bc252a',
    url    => 'http://www.geocodefarm.com/api/',
    ua     => LWP::UserAgent->new,
    parser => JSON->new->utf8,
    raise_failure => 1,
);

Creates a new geocoding object. key argument is required.

An API key can be obtained at http://geocodefarm.com/dashboard/login/

New account can be registered at http://geocodefarm.com/dashboard/register/free/

geocode

$result = $geocoder->geocode(
    location => $location
)

Forward geocoding takes a provided address or location and returns the coordinate set for the requested location as a nested list:

{
    ACCOUNT => {
        api_key => '3d517dd448a5ce1c2874637145fed69903bc252a',
        email => '[email protected]',
        monthly_due => '25.00',
        name => 'Joe Sixpack',
        next_due => '20130901',
        remaining_queries => '24995',
        usage_limit => '25000',
        used_today => '5',
    },
    ADDRESS => {
        accuracy => 'GOOD ACCURACY',
        address_provided => '530 WEST MAIN ST ANOKA MN 55303',
        address_returned => '530 WEST MAIN STREET, ANOKA, MN 55303, USA',
    },
    COORDINATES => {
        latitude => '45.2040305',
        longitude => '-93.3995728',
    },
    PROVIDER => {
        import => 'ALREADY STORED',
        provider => 'LOCAL FARM',
    },
    STATUS => {
        access => 'KEY_VALID, ACCESS_GRANTED',
        copyright_logo => 'http://www.geocodefarm.com/assets/img/logo.png',
        copyright_notice => 'Results Copyright (c) 2013 GeocodeFarm. All Rights Reserved. No unauthorized redistribution without written consent from GeocodeFarm's Owners and Operators.',
        status => 'SUCCESS',
    },
}

Slash / is replaced with dash - in location string.

Method throws an error (or returns failure as nested list if raise_failure argument is false) if the service failed to find coordinates or wrong key was used.

Methods throws an error if there was an other problem.

reverse_geocode

$result = $geocoder->reverse_geocode(
    lat => $latitude,
    lng => $longtitude,
)

or

$result = $geocoder->reverse_geocode(
    latlng => "$latitude,$longtitude",
)

Reverse geocoding takes a provided coordinate set and returns the address for the requested coordinates as a nested list:

{
    ACCOUNT => {
        api_key => '3d517dd448a5ce1c2874637145fed69903bc252a',
        email => '[email protected]',
        monthly_due => '25.00',
        name => 'Joe Sixpack',
        next_due => '20130901',
        remaining_queries => '24994',
        usage_limit => '25000',
        used_today => '6',
    },
    ADDRESS => {
        address => '500-534 West Main Street, Anoka, MN 55303, USA',
        accuracy => 'GOOD ACCURACY',
    },
    COORDINATES => {
        latitude => '45.204031',
        longitude => '-93.399573',
    },
    PROVIDER => {
        import => 'ALREADY STORED',
        provider => 'LOCAL FARM',
    },
    STATUS => {
        access => 'KEY_VALID, ACCESS_GRANTED',
        copyright_logo => 'http://www.geocodefarm.com/assets/img/logo.png',
        copyright_notice => 'Results Copyright (c) 2013 GeocodeFarm. All Rights Reserved. No unauthorized redistribution without written consent from GeocodeFarm's Owners and Operators.',
        status => 'SUCCESS',
    },
}

Method throws an error (or returns failure as nested list if raise_failure argument is false) if the service failed to find coordinates or wrong key was used.

Method throws an error if there was an other problem.

SEE ALSO

http://www.geocodefarm.com/

BUGS

If you find the bug or want to implement new features, please report it at https://github.com/dex4er/perl-Geo-Coder-GeocodeFarm/issues

The code repository is available at http://github.com/dex4er/perl-Geo-Coder-GeocodeFarm

AUTHOR

Piotr Roszatycki [email protected]

LICENSE

Copyright (c) 2013 Piotr Roszatycki [email protected].

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

See http://dev.perl.org/licenses/artistic.html

geo-coder-geocodefarm's People

Contributors

dex4er avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.