geohash v1.1.0 Geohash
Geohash encode/decode and helper functions
Usage
- Encode coordinates with
Geohash.encode(lat, lon, precision \\ 11)
Geohash.encode(42.6, -5.6, 5)
# "ezs42"
- Decode coordinates with
Geohash.decode(geohash)
Geohash.decode("ezs42")
# {42.605, -5.603}
- Find neighbors with
Geohash.neighbors(geohash)
Geohash.neighbors("abx1")
# %{"n" => "abx4",
# "s" => "abx0",
# "e" => "abx3",
# "w" => "abwc",
# "ne" => "abx6",
# "se" => "abx2",
# "nw" => "abwf",
# "sw" => "abwb"}
- Find adjacent with
Geohash.adjacent(geohash, direction)
Geohash.adjacent("abx1", "n")
# "abx4"
Summary
Functions
Calculate adjacent/2
geohash in ordinal direction ["n","s","e","w"]
.
Deals with boundary cases when adjacent is not of the same prefix
Decodes given geohash to a coordinate pair
Decodes given geohash to a bitstring
Encodes given coordinates to a geohash of length precision
Encodes given coordinates to a bitstring of length bits_length
Calculate adjacent hashes for the 8 touching neighbors/1
Functions
Calculate adjacent/2
geohash in ordinal direction ["n","s","e","w"]
.
Deals with boundary cases when adjacent is not of the same prefix.
Examples
iex> Geohash.adjacent("abx1","n")
"abx4"
Decodes given geohash to a coordinate pair
Examples
iex> {_lat, _lng} = Geohash.decode("ezs42")
{42.605, -5.603}
Decodes given geohash to a bitstring
Examples
iex> Geohash.decode_to_bits("ezs42")
<<0b0110111111110000010000010::25>>
Encodes given coordinates to a geohash of length precision
Examples
iex> Geohash.encode(42.6, -5.6, 5)
"ezs42"
Encodes given coordinates to a bitstring of length bits_length
Examples
iex> Geohash.encode_to_bits(42.6, -5.6, 25)
<<0b0110111111110000010000010::25>>
Calculate adjacent hashes for the 8 touching neighbors/1
Examples
iex> Geohash.neighbors("abx1")
%{"n" => "abx4",
"s" => "abx0",
"e" => "abx3",
"w" => "abwc",
"ne" => "abx6",
"se" => "abx2",
"nw" => "abwf",
"sw" => "abwb"}