geohash v1.0.0 Geohash

Geohash encode/decode and helper functions

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 coordinate pair

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

adjacent(geohash, direction)

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"
bits_to_coordinates_pair(bits)
decode(geohash)

Decodes given geohash to a coordinate pair

Examples

iex> Geohash.decode(“ezs42”) {42.605, -5.603}

decode_to_bits(geohash)

Decodes given geohash to a coordinate pair

Examples

iex> Geohash.decode(“ezs42”) {42.605, -5.603}

encode(lat, lon, precision \\ 11)

Encodes given coordinates to a geohash of length precision

Examples

iex> Geohash.encode(42.6, -5.6, 5) “ezs42”

encode_to_bits(lat, lon, bits_length)

Encodes given coordinates to a bitstring of length bits_length

Examples

iex> Geohash.encode_to_bits(42.6, -5.6, 25) <<0b0110111111110000010000010::25>>

neighbors(geohash)

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"}