Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Perl Modules

    Geo::Postcode::Location 0.15

    Download button

    No screenshots available
    Downloads: 443  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Good (3.0/5)
    6 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    William Ross | More programs
    Perl Artistic License / FREE
    January 21st, 2008, 12:21 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Geo::Postcode::Location description

    Geo::Postcode::Location is a helper class for Geo::Postcode that handles grid reference lookups.

    Geo::Postcode::Location is a helper class for Geo::Postcode that handles grid reference lookups.

    SYNOPSIS

    $Geo::Postcode::Location::datafile = '/usr/local/lib/postcodes.db';
    my ($x, $y) = Geo::Postcode->coordinates('EC1R 8BB');

    Geo::Postcode::Location holds the gridref-lookup functions of Geo::Postcode. It is separated here to minimise the footprint of the main module and to facilitate subclassing.

    It doesn't really have a useful direct interface, since it requires an object of Geo::Postcode (or a subclass) and is most easily reached through that object, but it does have a couple of configuration variables and there is method documentation here for anyone interested in subclassing it or changing the data source.

    GRIDREF DATA

    There are at least three ways to supply your own gridref data.
    replace the data file

    If you can get your data into a SQLite file, all you have to do is set the either Geo::Postcode::Location::datafile or $ENV{POSTCODE_DATA} to the full path to your data file:

    $Geo::Postcode::Location::datafile = '/home/site/data/postcodes.db';
    # or
    PerlSetEnv POSTCODE_DATA /home/site/data/postcodes.db

    I've included (in ./useful) an idiot script that I use to turn .csv data into a SQLite file suitable for use with this module.

    replace the database handle

    The query that we use to retrieve location information is very simple, and should work with any DBI database handle. If your application already makes available a suitable database handle, or you would like to create one externally and make sure it is reused, it should just work:

    $Geo::Postcode::Location::dbh = $my_dbh;
    $Geo::Postcode::Location::tablename = 'postcodedata';
    my ($x, $y) = Geo::Postcode->coordinates('EC1Y 8PQ');

    If running under mod_perl, you probably don't want to share the handle like that. You can achieve the same thing with instance methods and avoid side-effects, but you have to make the calls at the right time:

    my $postcode = Geo::Postcode->new('EC1Y 8PQ');
    $postcode->location->dbh( $my_dbh );
    $postcode->location->tablename( 'postcodedata' );
    my ($x, $y) = $postcode->coordinates;

    override the lookup mechanism in subclass

    The data-retrieval process is divided up to make this as simple as possible: see the method descriptions below for details. You should be able to replace the data source by overriding dbh or redo the whole lookup by replacing retrieve.

    $Geo::Postcode->location_class('My::Location');

    package My::Location;
    use base qw(Geo::Postcode::Location);
    sub dbh { ... }

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    Geo::Postcode helper | grid reference lookups | Perl module | Geo::Postcode | grid | reference

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM