The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Geo::Query::LatLong - Perl module to query latitude and longitude from a city.

SYNOPSIS

  use Geo::Query::LatLong;

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

DESCRIPTION

Query latitude and longitude from any city in any country.

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

  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

  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.

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:

  • Hash key 'rc' returns a number unequal to zero.

  • Hash keys 'lat' / 'lng' are being returned as '99' / '99'.

EXPORT

None by default.

Further documentation and feedback

http://meta.pgate.net/perl-modules/

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

SEE ALSO

The Geo::Coder::* series.

AUTHOR

Reto Schaer, <retoh@cpan.org>

COPYRIGHT AND LICENSE

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

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 131:

'=item' outside of any '=over'

Around line 139:

You forgot a '=back' before '=head2'