The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
NAME
    GeoHash - Geo::Hash* wrapper with any utils

SYNOPSIS
    simple wrapper

        use GeoHash;
        my $gh = GeoHash->new();
        my $hash = $gh->encode( $lat, $lon );  # default precision = 32
        my $hash = $gh->encode( $lat, $lon, $precision );
        my ($lat, $lon) = $gh->decode( $hash );
        my ($lat_range, $lon_range) = $gh->decode_to_interval( $hash );
        my $precision = $gh->precision($lat, $lon);

    compatible with Pure Perl and XS

        my $adjacent_hash = $gh->adjacent($hash, $where);
        my @list_of_geohashes = $gh->neighbors($hash, $around, $offset);

    specific utilities of GeoHash.pm

        my @list_of_merged_geohashes = $gh->merge(@list_of_geohashes);
        my @list_of_geohashes = $gh->split(@list_of_merged_geohashes);
        my $bool = $gh->validate( $geohash );

    fource use pp

       BEGIN { $ENV{PERL_GEOHASH_BACKEND} = 'Geo::Hash' }
       use GeoHash;

    fource use xs

       BEGIN { $ENV{PERL_GEOHASH_BACKEND} = 'Geo::Hash::XS' }
       use GeoHash;

DESCRIPTION
    GeoHash is a wrapper module for use in the same interface and Geo::Hash
    Geo::Hash::XS. and utility method has been added to it.

    You can use the methods in the Geo::Hash has been implemented in only
    Geo::Hash::XS.

METHODS
  $gh = GeoHash->new()
  $hash = $gh->encode($lat, $lon[, $precision])
    Encodes the given $lat and $lon to a geohash. If $precision is not
    given, automatically adjusts the precision according the the given $lat
    and $lon values.

    If you do not want GeoHash to spend time calculating this, explicitly
    specify $precision.

  ($lat, $lon) = $gh->decode( $hash )
    Decodes $hash to $lat and $lon

  ($lat_range, $lon_range) = $gh->decode_to_interval( $hash )
    Like "decode()" but "decode_to_interval()" decodes $hash to $lat_range
    and $lon_range. Each range is a reference to two element arrays which
    contains the upper and lower bounds.

  $precision = $gh->precision($lat, $lon)
    Returns the apparent required precision to describe the given latitude
    and longitude.

  $adjacent_hash = $gh->adjacent($hash, $where)
    Returns the adjacent geohash. $where denotes the direction, so if you
    want the block to the right of $hash, you say:

        use GeoHash qw(ADJ_RIGHT);

        my $gh = GeoHash->new();
        my $adjacent = $gh->adjacent( $hash, ADJ_RIGHT );

  @list_of_geohashes = $gh->neighbors($hash, $around, $offset)
    Returns the list of neighbors (the blocks surrounding $hash)

  @list_of_merged_geohashes = $gh->merge(@list_of_geohashes)
    Merged with the larger area from geohash list. And remove duplicated
    geohash in @list_of_geohashes.

        my @list = $gh->merge(qw/
            c2b25ps0 c2b25ps1 c2b25ps2 c2b25ps3 c2b25ps4 c2b25ps5 c2b25ps6 c2b25ps7 c2b25ps8 c2b25ps9
            c2b25psb c2b25psc c2b25psd c2b25pse c2b25psf c2b25psg c2b25psh c2b25psj c2b25psk c2b25psm
            c2b25psn c2b25psp c2b25psq c2b25psr c2b25pss c2b25pst c2b25psu c2b25psv c2b25psw c2b25psx
            c2b25psy c2b25psz
        /);
        is($list[0], 'c2b25ps');

  @list_of_geohashes = $gh->split(@list_of_merged_geohashes)
    geohash splitter.

        my @list = $gh->split('c2b25ps');
        is_deeply(\@list, [ qw/
            c2b25ps0 c2b25ps1 c2b25ps2 c2b25ps3 c2b25ps4 c2b25ps5 c2b25ps6 c2b25ps7 c2b25ps8 c2b25ps9
            c2b25psb c2b25psc c2b25psd c2b25pse c2b25psf c2b25psg c2b25psh c2b25psj c2b25psk c2b25psm
            c2b25psn c2b25psp c2b25psq c2b25psr c2b25pss c2b25pst c2b25psu c2b25psv c2b25psw c2b25psx
            c2b25psy c2b25psz
        / ]);

  $bool = $gh->validate($geohash)
    Verify correct as geohash.

        ok($gh->validate('c2b25ps0');
        ok(not $gh->validate('a'); # can not use 'a'
        ok(not $gh->validate(); # required option

CONSTANTS
  ADJ_LEFT, ADJ_RIGHT, ADJ_TOP, ADJ_BOTTOM
    Used to specify the direction in "adjacent()"

AUTHOR
    Kazuhiro Osawa <yappo {at} shibuya {dot} pl>

SEE ALSO
    Geo::Hash, Geo::Hash::XS

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