RGeo is an extremely basic reverse geocoding library that provides location information based on a given %Geo.Point{}
.
The library currently only provides extremely basic location information down to the country level. The goal was to only spend about an hour on the current iteration so there is a lot of features missing.
RGeo
loads the entire countries dataset with 100m resolution into memory. Data is sourced from naturalearthdata.com
NOTE: Not tested thoroughly in production.
If available in Hex, the package can be installed
by adding rgeo
to your list of dependencies in mix.exs
:
def deps do
[
{:rgeo, "~> 0.0.1-dev"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/rgeo.
RGeo
uses the felt/geo library to represent GeoJSON.
# Add the RGeo.Backend to your supervision tree.
# In a Phoenix application, it it would be a link in your children
# Application.ex
...
children = [
RGeo.Backend
]
Supervisor.start_link(children, opts)
...
# Calling the library in your application
RGeo.location_at(%Geo.Point{coordinates: {-74.0060, 40.7128}})
{:ok, %RGeo.Location{
continent: "North America",
country: "United States of America",
country_code2: "US",
country_code3: "USA",
country_long: "United States of America",
region: "Americas",
subregion: "Northern America"
}}