{"id":13508237,"url":"https://github.com/evuez/geohax","last_synced_at":"2025-04-12T06:24:39.000Z","repository":{"id":62429825,"uuid":"71473585","full_name":"evuez/geohax","owner":"evuez","description":"Geohash encoding and decoding for Elixir.","archived":false,"fork":false,"pushed_at":"2024-05-12T17:58:53.000Z","size":29,"stargazers_count":12,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-19T17:30:01.765Z","etag":null,"topics":["geohash","geolocation","hacktoberfest"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/geohax","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evuez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-20T14:51:49.000Z","updated_at":"2024-08-05T07:14:14.000Z","dependencies_parsed_at":"2024-06-21T16:40:47.973Z","dependency_job_id":"2daa5352-a197-4437-94cd-9c25badae764","html_url":"https://github.com/evuez/geohax","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evuez%2Fgeohax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evuez%2Fgeohax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evuez%2Fgeohax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evuez%2Fgeohax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evuez","download_url":"https://codeload.github.com/evuez/geohax/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248526356,"owners_count":21118870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geohash","geolocation","hacktoberfest"],"created_at":"2024-08-01T02:00:50.192Z","updated_at":"2025-04-12T06:24:38.973Z","avatar_url":"https://github.com/evuez.png","language":"Elixir","funding_links":[],"categories":["Geolocation"],"sub_categories":[],"readme":"# Geohax\n\n[![Hex.pm](https://img.shields.io/hexpm/v/geohax.svg)](https://hex.pm/packages/geohax)\n[![Build Status](https://travis-ci.org/evuez/geohax.svg?branch=main)](https://travis-ci.org/evuez/geohax)\n[![Inline docs](http://inch-ci.org/github/evuez/geohax.svg)](http://inch-ci.org/github/evuez/geohax)\n[![Hex.pm](https://img.shields.io/hexpm/dt/geohax.svg)](https://hex.pm/packages/geohax)\n\nGeohash encoding and decoding for Elixir.\n\n\n**Note**: This project doesn't receive many updates mainly because its API is fairly small. **I'm still actively maintaining it.**\n\n## Ordering of longitude and latitude\n\n*Every* function in `Geohax` use the `longitude,latitude` ordering; make sure not to invert these!\n\nBoth [Redis](https://redis.io/commands/geoadd) and [PostGIS](https://postgis.net/docs/ST_MakePoint.html) 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:\n\n```elixir\ndefmodule MyGeohash do\n  def decode(geohash) do\n    {lon, lat} = Geohax.decode(geohash)\n    {lat, lon}\n  end\n\n  def encode(latitude, longitude, precision \\\\ 12),\n    do: Geohax.encode(longitude, latitude, precision)\n\n  defdelegate neighbor(geohash, direction), to: Geohax\n\n  defdelegate neighbors(geohash), to: Geohax\n\n  defdelegate within(min, max, precision \\\\ 5), to: Geohax\nend\n```\n\n## Usage\n\n### Encoding and decoding\n\n```elixir\niex\u003e Geohax.encode(-132.83, -38.1033, 6)\n\"311x1r\"\niex\u003e Geohax.decode(\"311x1r\")\n{-132.83, -38.1033}\n```\n\nNote that the format for coordinates is `{longitude, latitude}`.\n\n### Finding neighbors\n\n```elixir\niex\u003e Geohax.neighbors(\"311x1r\")\n%{north: \"311x32\", south: \"311x1q\", east: \"311x1x\", west: \"311x1p\"}\niex\u003e Geohax.neighbor(\"311x1r\", :north)\n\"311x32\"\n```\n\n### Calculating geoashes within an envelope\n\n```elixir\niex\u003e Geohax.within({52.291725, 16.731831}, {52.508736, 17.071703})\n[\"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\"]\n```\n\n## Installation\n\nAdd the `:geohax` dependency to your `mix.exs` file:\n\n```elixir\ndefp deps do\n  [{:geohax, \"~\u003e 1.0\"}]\nend\n```\n\nThen, run `mix deps.get` to fetch the new dependency.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevuez%2Fgeohax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevuez%2Fgeohax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevuez%2Fgeohax/lists"}