Code Monkey home page Code Monkey logo

geohex-perl's Introduction

Build Status Coverage Status

NAME

Geo::Hex - GeoHex decoder/encoder

SYNOPSIS

use Geo::Hex;

# OO-style
my $geohex = Geo::Hex->new( version => 3 ); # v3 by default

$geohex->spec_version; # => 3

my ($lat, $lon, $level) = $geohex->decode( 'XM4885487' );
my $code                = $geohex->encode( $lat, $lon, $level );
# => XM4885487

my $zone = $geohex->to_zone( 'XM4885487' );
   $zone = $geohex->to_zone( $lat, $lon, $level );

# * zone object: hash value
# $zone->code  : GeoHex code
# $zone->level : Level
# $zone->lat   : Latirude of given GeoHex's center point
# $zone->lon   : Longitude of given GeoHex's center point
# $zone->x     : Mercator X coordinate of given GeoHex's center point 
# $zone->y     : Mercator Y coordinate of given GeoHex's center point 

my $polygon = $zone->hex_coords; # return the hex coords (six points hold lat and lon)


# Export function - GeoHex v3 by default
($lat, $lon, $level) = decode_geohex( $code );
$code = encode_geohex( $lat, $lon, $level );

# Explicit export function
use Geo::Hex v => 3, qw(latlng2geohex geohex2latlng latlng2zone geohex2zone);

# From latitude/longitude to hex code
$code = latlng2geohex( $lat, $lng, $level );
    # From hex code to center latitude/longitude
my ( $center_lat, $center_lng, $level ) = geohex2latlng( $code );

VERSION

This is a beta version, so interfaces may be changed in future.

CLASS METHODS

new

$geohex = Geo::Hex->new( %option );

Creates a new Geo::Hex::Coder object. It can take options:

  • version

    The GeoHex specification vresion.

  • v

    The synonym to version option.

spec_version

Returns specification version.

INSTANCE METHODS

decode

( $lat, $lon, $level ) = $geohex->decode( $code );

encode

$code = $geohex->encode( $lat, $lon, $level );

to_zone

$zone = $geohex->to_zone( $code );

$zone = $geohex->to_zone( $lat, $lon, $level );

spec_version

Returns specification version.

EXPORT FUNCTIONS

decode_geohex

($lat, $lon, $level) = decode_geohex( $code );

Convert latitude/longitude to GeoHex code.

encode_geohex

$code = encode_geohex( $lat, $lon, $level );

Convert GeoHex code to center latitude/longitude, and level value.

FUNCTIONS

use Geo::Hex v => 3;

latlng2geohex

$code = latlng2geohex( $lat, $lon, $level );

Same as encode_geohex.

geohex2latlng

($lat, $lon, $level) = geohex2latlng( $code );

Same as decode_geohex.

latlng2zone

$zone = latlng2zone( $lat, $lon, $level );

Takes a location and its level, and returns GeoHex::Zone.

geohex2zone

$zone = geohex2zone( $code );

Takes a geohex code and returns GeoHex::Zone.

SEE ALSO

https://sites.google.com/site/geohexdocs/, http://geogames.net/geohex/v3

Geo::Hex::V1, Geo::Hex::V2, Geo::Hex::V3, Geo::Hex::Zone

AUTHORS

Frontend module Geo::Hex by Makamaka Hannyaharamitu

Geo::Hex::V1 are originally written by OHTSUKA Ko-hei <[email protected]>

Geo::Hex::V2 are originally written by OHTSUKA Ko-hei and maintained by Makamaka Hannyaharamitu

Geo::Hex::V2::XS are originally written by lestrrat

Geo::Hex::V3 are originally written by soh335

LICENCE AND COPYRIGHT

GeoHex by @sa2da (http://geogames.net) is licensed under Creative Commons BY-SA 2.1 Japan License.

Geo::Hex - Copyright 2011 Makamaka Hannyaharamitu

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

geohex-perl's People

Contributors

makamaka avatar karupanerura avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.