Geo::Hash(3pm)

Geo::Hash3pm

Encode / decode geohash.org locations.

Usage

    use Geo::Hash;
    my $gh = Geo::Hash->new;
    my $hash = $gh->encode( $lat, $lon );
    my ( $lat, $lon ) = $gh->decode( $hash );

Version

This document describes Geo::Hash version 0.02

Overview

Geohash is a latitude/longitude geocode system invented by Gustavo Niemeyer when writing the web service at geohash.org, and put into the public domain.

This module encodes and decodes geohash locations.

See <http://en.wikipedia.org/wiki/Geohash> and <http://geohash.org> for more information.

Interface

"new"

Create a new Geo::Hash object.

    my $gh = Geo::Hash->new;

"precision"

Infer a suitable precision (number of character in hash) for a given lat, lon pair.

    my $prec = $gh->precision( $lat, $lon );

"encode"

Encode a lat, long pair into a geohash.

    my $hash = $gh->encode( $lat, $lon );

You may optionally supply the length of the desired geohash:

    # Very precise
    my $hash = $gh->encode( $lat, $lon, 10 );

If the precision argument is omitted "precision" will be used to provide a default.

"decode_to_interval"

Like "decode" but instead of returning a pair of coordinates returns the interval for each coordinate. This gives some indication of how precisely the original hash specified the location.

The return value is a pair of array refs. Each referred to array contains the upper and lower bounds for each coordinate.

    my ( $lat_range, $lon_range ) = $gh->decode_to_interval( $hash );
    # $lat_range and $lon_range are references to two element arrays

"decode"

Decode a geohash into a lat, long pair.

    my ( $lat, $lon ) = $gh->decode( $hash );

Configuration and environment

Geo::Hash requires no configuration files or environment variables.

Dependencies

None.

Incompatibilities

None reported.

Bugs and limitations

No bugs have been reported.

Please report any bugs or feature requests to "[email protected]", or through the web interface at <http://rt.cpan.org>.

Releases

Unchanged in 2 releases since Debian 12 (Bookworm).

  1. 12–13

Author

Andy Armstrong "<[email protected]>"

<http://geohash.org/gcwrdtsvrfgr>

From libgeo-hash-perl 0.02-3 in Debian 13 (Trixie). Parsed by carta from the page's man source.