View Source Geospatial.Providers.Provider behaviour (Geospatial v0.3.2)

Provider Behaviour for Geospatial stuff.

Supported backends

Shared options

  • :lang Lang in which to prefer results. Used as a request parameter or through an Accept-Language HTTP header. Defaults to "en".
  • :country_code An ISO 3166 country code. String or nil
  • :limit Maximum limit for the number of results returned by the backend. Defaults to 10
  • :api_key Allows to override the API key (if the backend requires one) set inside the configuration.
  • :endpoint Allows to override the endpoint set inside the configuration.

Summary

Callbacks

Get an address from longitude and latitude coordinates.

Lookup for an address by id

Search for an address

Functions

Returns a Geo.Point for given coordinates

Returns the timezone for a Geo.Point

Callbacks

Link to this callback

geocode(longitude, latitude, options)

View Source
@callback geocode(longitude :: number(), latitude :: number(), options :: keyword()) :: [
  Geospatial.Address.t()
]

Get an address from longitude and latitude coordinates.

Options

In addition to the shared options, geocode/3 also accepts the following options:

  • zoom Level of detail required for the address. Default: 15

Examples

iex> geocode(48.11, -1.77)
%Address{}
@callback get_by_id(id :: String.t(), options :: keyword()) :: [Geospatial.Address.t()]

Lookup for an address by id

Link to this callback

search(address, options)

View Source
@callback search(address :: String.t(), options :: keyword()) :: [Geospatial.Address.t()]

Search for an address

Options

In addition to the shared options, search/2 also accepts the following options:

  • coords Map of coordinates (ex: %{lon: 48.11, lat: -1.77}) allowing to give a geographic priority to the search. Defaults to nil.
  • type Filter by type of results. Allowed values:
    • :administrative (cities, regions)

Examples

iex> search("10 rue Jangot")
%Address{}

Functions

@spec coordinates([number() | String.t()]) :: Geo.Point.t() | nil

Returns a Geo.Point for given coordinates

@spec endpoint(atom()) :: String.t()
@spec timezone(nil | Geo.Point.t()) :: nil | String.t()

Returns the timezone for a Geo.Point