ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - evuez/geohax: Geohash encoding and decoding for Elixir.
Geohash encoding and decoding for Elixir. Contribute to evuez/geohax development by creating an account on GitHub.
Visit Site

GitHub - evuez/geohax: Geohash encoding and decoding for Elixir.

GitHub - evuez/geohax: Geohash encoding and decoding for Elixir.

Geohax

Hex.pm Build Status Inline docs Hex.pm

Geohash encoding and decoding for Elixir.

Note: This project doesn't receive many updates mainly because its API is fairly small. I'm still actively maintaining it.

Ordering of longitude and latitude

Every function in Geohax use the longitude,latitude ordering; make sure not to invert these!

Both Redis and PostGIS use this same ordering, but if you feel strongly about that and would prefer to use latitude,longitude instead, you can simply create a new module that does this for you:

defmodule MyGeohash do
  def decode(geohash) do
    {lon, lat} = Geohax.decode(geohash)
    {lat, lon}
  end

  def encode(latitude, longitude, precision \\ 12),
    do: Geohax.encode(longitude, latitude, precision)

  defdelegate neighbor(geohash, direction), to: Geohax

  defdelegate neighbors(geohash), to: Geohax

  defdelegate within(min, max, precision \\ 5), to: Geohax
end

Usage

Encoding and decoding

iex> Geohax.encode(-132.83, -38.1033, 6)
"311x1r"
iex> Geohax.decode("311x1r")
{-132.83, -38.1033}

Note that the format for coordinates is {longitude, latitude}.

Finding neighbors

iex> Geohax.neighbors("311x1r")
%{north: "311x32", south: "311x1q", east: "311x1x", west: "311x1p"}
iex> Geohax.neighbor("311x1r", :north)
"311x32"

Calculating geoashes within an envelope

iex> Geohax.within({52.291725, 16.731831}, {52.508736, 17.071703})
["u37ck", "u37cm", "u37cq", "u37cr", "u3k12", "u3k13", "u3k16", "u3k17", "u3k1k", "u37cs", "u37ct", "u37cw", "u37cx", "u3k18", "u3k19", "u3k1d", "u3k1e", "u3k1s", "u37cu", "u37cv", "u37cy", "u37cz", "u3k1b", "u3k1c", "u3k1f", "u3k1g", "u3k1u", "u37fh", "u37fj", "u37fn", "u37fp", "u3k40", "u3k41", "u3k44", "u3k45", "u3k4h", "u37fk", "u37fm", "u37fq", "u37fr", "u3k42", "u3k43", "u3k46", "u3k47", "u3k4k", "u37fs", "u37ft", "u37fw", "u37fx", "u3k48", "u3k49", "u3k4d", "u3k4e", "u3k4s"]

Installation

Add the :geohax dependency to your mix.exs file:

defp deps do
  [{:geohax, "~> 1.0"}]
end

Then, run mix deps.get to fetch the new dependency.

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory