{"id":19210337,"url":"https://github.com/seniverse/ex_fast_rgc","last_synced_at":"2025-07-30T08:08:34.956Z","repository":{"id":62429114,"uuid":"196244181","full_name":"seniverse/ex_fast_rgc","owner":"seniverse","description":"Super fast reverse geocoding for only city-level","archived":false,"fork":false,"pushed_at":"2019-07-15T17:24:24.000Z","size":445,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-26T15:05:59.316Z","etag":null,"topics":["elixir","geocoding","geocoding-elixir","reverse"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seniverse.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-10T16:59:24.000Z","updated_at":"2024-08-27T17:28:49.000Z","dependencies_parsed_at":"2022-11-01T20:03:04.926Z","dependency_job_id":null,"html_url":"https://github.com/seniverse/ex_fast_rgc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/seniverse/ex_fast_rgc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seniverse%2Fex_fast_rgc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seniverse%2Fex_fast_rgc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seniverse%2Fex_fast_rgc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seniverse%2Fex_fast_rgc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seniverse","download_url":"https://codeload.github.com/seniverse/ex_fast_rgc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seniverse%2Fex_fast_rgc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267527815,"owners_count":24102015,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["elixir","geocoding","geocoding-elixir","reverse"],"created_at":"2024-11-09T13:35:46.187Z","updated_at":"2025-07-30T08:08:34.880Z","avatar_url":"https://github.com/seniverse.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastRGC\n\nFast reverse geocoding at city level. it's inspired by [reversegeocode](https://github.com/kno10/reversegeocode), we implement same policy in elixir only for china region.\n\n## Usage\n\nTo prepare lookup by latitude and longitude, you need parse database first and\nhold the parsed object for later usage:\n\n```elixir\n    iex(1)\u003e {:ok, database} = FastRGC.load()\n```\n\nthen lookup by latitude and longitude pair:\n\n```elixir\n    iex(2)\u003e FastRGC.lookup(database, %{lat: 39, lng: 116})\n    %{\n      \"adcode\" =\u003e \"130632\",\n      \"center\" =\u003e \"115.931979,38.929912\",\n      \"name\" =\u003e \"安新县\",\n      \"path\" =\u003e \"中华人民共和国,河北省,保定市,安新县\"\n    }\n```\n\nif coordinate is outside of china, `nil` will be returned by `lookup/2` function.\n\n```elixir\n    iex(3)\u003e FastRGC.lookup(database, %{lat: 39, lng: 200})\n    nil\n```\n\n## Installation\n\nIf [available in Hex](https://hex.pm/docs/publish), the package can be installed\nby adding `ex_fast_rgc` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:ex_fast_rgc, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n## Format of Database\n\nThe file format is designed to support reading read every bits directly without any decompress or query, and this binary decrease final file size from `44MB` to `~1MB`.\n\nOrignal data is splited to 12 * 12 block, and only have four types of blocks:\n\nType 0, only one id in this block\nType 1, only two ids in this block\nType 2, three or four ids in this block\nType 3, four above ids in this block\n\n```\n\u003cHEADER\u003e\n 4 Bytes - SDB\\01 \u003c0x53444201\u003e\n 2 Bytes - width of the map in pixel\n 2 Bytes - height of the map in pixel\n 4 Bytes - width of the map in degree\n 4 Bytes - height of the map in degree\n 4 Bytes - longitude offset of the map in degree\n 4 Bytes - latitude offset of the map in degree\n 2 Bytes - tile size\n 2 Bytes - y, div(height, tile_size)\n 2 Bytes - x, div(width, tile_size)\n 2 Bytes - delta, offset of id number\n 2 Bytes - c0, count of type 0 block\n 2 Bytes - c1, count of type 1 block\n 2 Bytes - c2, count of type 2 block\n 2 Bytes - c3, count of type 3 block\n\n\u003cINDEX\u003e\n  x * y * 2 Bytes - query map for every tiled block\n\n\u003cBODY\u003e\n  c1 * (2 * 2 + n * n / 8) Bytes - Type1 Block Data\n  c2 * (2 * 4 + 2 * n * n / 8) Bytes - Type2 Block Data\n  c3 * (2 * n * n) Bytes - Type3 Block Data\n\u003cBODY\u003e\n x bytes for each row (run-length ecoding)\n```\n\nDocumentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)\nand published on [HexDocs](https://hexdocs.pm). Once published, the docs can\nbe found at [https://hexdocs.pm/ex_fast_rgc](https://hexdocs.pm/ex_fast_rgc).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseniverse%2Fex_fast_rgc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseniverse%2Fex_fast_rgc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseniverse%2Fex_fast_rgc/lists"}