Reto Schär > Geo-Query-LatLong-0.8011 > Geo::Query::LatLong

Download:
Geo/Geo-Query-LatLong-0.8011.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.8011   Source  

NAME ^

Geo::Query::LatLong - Uniform interface to query latitude and longitude from a city.

SYNOPSIS ^

  use Geo::Query::LatLong;

  # Generic source
  $geo = Geo::Query::LatLong->new( debug => 0 );

or

  # Using Google Maps API
  $geo = Geo::Query::LatLong->new( source => 'Google', apikey => 'Your API key' );

DESCRIPTION ^

Query latitude and longitude from a city in any country. Useful to open specific locations in a Browser map. You can use a generic server or query the Google Maps API. In case of Google Maps you had to supply your Google key. Geo::Query::LatLong returns an uniform response independent of the chosen server.

Query example

  use Geo::Query::LatLong;

  $CITY = $ARGV[0] || 'Zurich';

  $res = $geo->query( city => $CITY, country_code => 'SZ' ); # FIPS 10 country code

  print "Latitude and longitude of $CITY: ",
                $res->{'lat'}, ' / ', $res->{'lng'}, "\n";

List all results from your query

  foreach (keys %{$res}) {
        print "$_ = ", $res->{$_}, "\n";
  }

Another example

Switch exactness to "off" will increase the chance you get a result.

  $res = $geo->query( city => 'Unterwalden', country_code => 'SZ', exact => 'off' ); # exact default: on

  print "-- $_ = ", $res->{$_}, "\n" foreach keys %{$res};

Parameter country_code (not required for Google API)

Country Codes according to FIPS 10: http://de.wikipedia.org/wiki/FIPS_10

Parameter city

Use the english translations for the city names, e.g. Zurich for Zuerich, Munich for Muenchen.

In conjunction with Google API you can send arguments like "Bellevue Zurich, Switzerland" as well.

Return values

The function query(...) always returns a hash reference. Hash key 'rc' is retured as 0 (Zero) on success and unequal 0 on a failure. Additionally it is a good advice to read or display the 'msg' key on a failure to get a hint about the cause.

On case the city was not found:

EXPORT

None by default.

Further documentation and feedback ^

http://meta.pgate.net/geo-query-latlong/

http://www.infocopter.com/perl/modules/

SEE ALSO ^

The Geo::Coder series here on CPAN.

AUTHOR ^

Reto Schaer, <retoh@cpan-cuthere.org>

COPYRIGHT AND LICENSE ^

Copyright (C) 2007 - 2008 by Reto Schaer

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.

http://www.infocopter.com/perl/licencing.html