Skip to content

Jdyn/rgeo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RGeo

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.

Installation

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.

Example Usage

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"
        }}

About

Local-only reverse geocoder for Elixir

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages