{"id":28353546,"url":"https://github.com/davidjulien/erlang-geocoding","last_synced_at":"2026-01-30T05:09:34.012Z","repository":{"id":62429785,"uuid":"347971104","full_name":"davidjulien/erlang-geocoding","owner":"davidjulien","description":"Geocoding provides function to find cities according to latitude/longitude coordinates.","archived":false,"fork":false,"pushed_at":"2024-12-05T09:28:58.000Z","size":3178,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-27T23:03:56.794Z","etag":null,"topics":["geonames","reverse-geocoding"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidjulien.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}},"created_at":"2021-03-15T13:01:18.000Z","updated_at":"2024-12-05T09:29:02.000Z","dependencies_parsed_at":"2022-11-01T20:07:32.108Z","dependency_job_id":null,"html_url":"https://github.com/davidjulien/erlang-geocoding","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/davidjulien/erlang-geocoding","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidjulien%2Ferlang-geocoding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidjulien%2Ferlang-geocoding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidjulien%2Ferlang-geocoding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidjulien%2Ferlang-geocoding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidjulien","download_url":"https://codeload.github.com/davidjulien/erlang-geocoding/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidjulien%2Ferlang-geocoding/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28904742,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T04:02:34.702Z","status":"ssl_error","status_checked_at":"2026-01-30T04:02:33.562Z","response_time":66,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["geonames","reverse-geocoding"],"created_at":"2025-05-28T01:12:39.021Z","updated_at":"2026-01-30T05:09:34.007Z","avatar_url":"https://github.com/davidjulien.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"**Geocoding does not rely on any external API**.\nIt relies on an internal (huge) database of 165,602 coordinates corresponding to cities of more than 500 inhabitants (see `Data sources` for more details).\n\n## Compile, test and try\n\nCompilation:\n\n```\nrebar compile\n```\n\nTests:\n```\nrebar eunit\n```\n\nUsage:\n```\n\u003e erl -pa _build/default/lib/geocoding/ebin/ \nErlang/OTP 23 [erts-11.1.8] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe] [dtrace]\n\nEshell V11.1.8  (abort with ^G)\n1\u003e application:start(geocoding).\nok\n\n2\u003e geocoding:reverse(48.857929, 2.346707).\n{ok,{2988507,europe,fr,\u003c\u003c\"Paris\"\u003e\u003e,525.451956}}\n\n3\u003e geocoding:distance({48.857929, 2.346707}, {40.7630463, -73.973527}).\n5832947\n\n4\u003e geocoding:lookup('FR', \u003c\u003c\"paris\"\u003e\u003e).\n{ok,{2988507,{48.85341,2.3488},europe,'FR',\u003c\u003c\"Paris\"\u003e\u003e}}\n```\n\n`geocoding:reverse/2` returns the geoname id, continent name, country code (ISO 3166-1 alpha-2),\ncity name, distance between city center and provided coordinates.\n\n## Installation\n\nErlang (`rebar3`):\n```\n{deps, [\n  {geocoding, \"0.4.0\"}}\n]}\n```\n\n\nElixir (`mix`):\n```\ndefp deps do\n  [\n    {:geocoding, \"~\u003e 0.4.0\"}\n  ]\nend\n```\n\n## Database rebuilding\n\nAn escript allows to rebuild your `cities.txt` data from geonames. It will fetch the last version of `cities500.zip`, unzip it, filter out city with too low population, and build continent name. It will generate a `cities.txt.new` file. Existing `citiers.txt` will not be erased.\n\n```\n\u003e ./scripts/cities_builder.escript\n```\n\nIf you want to replace your `cities.txt`, add `--replace` parameter. Old `cities.txt` will be renamed to `cities.txt.old`.\n\n```\n\u003e ./scripts/cities_builder.escript --replace\n```\n\n## Technical information\n\n### Algorithm\n\nReverse geocoding is done thanks to a k-d tree algorithm. We use Martin F. Krafft implementation. Original source code is here: https://github.com/kbranigan/libkdtree/tree/master/kdtree%2B%2B . It is embeded in an erlang driver.\n\nFrom latitude/longitude coordinates, geocoding finds the nearest point in our locations database. Associated data are returned, as well as a distance between provided coordinates and real coordinates. Since reverse geocoding relies only on coordinates, strange behaviour may occured when a big city is near a small one: a point inside the big city and near its border may be associated to the small city because the small city coordinates will be nearest than the big city coordinates.\n\n### Data sources\n\nAll locations data come from https://www.geonames.org database (http://download.geonames.org/export/dump/cities500.zip - 2024-12-05):\n- Locations without population have been excluded.\n- PPLX (section of populated places) and PPLA5 (seat of a fifth-order administrative division) have been excluded.\n- Fields have been reduced to: geonameId, latitude, longitude, country code (ISO-3166), standard name.\nA 6th fields have been added between longitude and country code: continent.\nEach field is separated by a tabulation.\n\nExample:\n```\n2988507 48.85341        2.3488  europe  FR      Paris\n```\n\nEach location is associated to one of the following continents:\n- africa (africa and islands nearby like Madagascar, Canary, La Réunion...)\n- antarctica (only one country)\n- asia (including russian cities after Ural Mountains)\n- europe (including russian cities before Ural Mountains)\n- oceania (including Australia continent and pacific islands)\n- north america\n- south america\n\nMissing locations may be added on request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidjulien%2Ferlang-geocoding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidjulien%2Ferlang-geocoding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidjulien%2Ferlang-geocoding/lists"}