View Source Geohash (geohash v1.3.0)
Geohash encoder/decoder and helper functions.
Summary
Functions
Calculate adjacent/2
geohash in ordinal direction ["n","s","e","w"]
.
Calculates bounds for a given geohash.
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"
Calculates bounds for a given geohash.
Examples
iex> Geohash.bounds("u4pruydqqv")
%{
min_lon: 10.407432317733765,
min_lat: 57.649109959602356,
max_lon: 10.407443046569824,
max_lat: 57.649115324020386
}
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"
}