-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
143 lines (95 loc) · 3.81 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
NAME
Geo::Hex - GeoHex decoder/encoder
INSTALLATION
To install this module, run the following commands:
perl Makefile.PL
make
make test
make install
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
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.