Module for handling IBGE BNGB API (v1) — Banco de Nomes Geográficos do Brasil.
Provides access to geographic names, their locations, categories, and classes as maintained by IBGE's geographic names database.
Summary
Functions
Get geographic names within a bounding box defined by four coordinates.
Same as by_bounding_box/4, but raises on failure.
Get geographic names belonging to a given category.
Same as by_category/1, but raises on failure.
Get geographic names belonging to a given class.
Same as by_class/1, but raises on failure.
Get geographic names by municipality geocode.
Same as by_municipality/1, but raises on failure.
Get geographic names near a coordinate within a given distance.
Same as by_proximity/3, but raises on failure.
Get geographic names by state (UF).
Same as by_state/1, but raises on failure.
Get the list of categories available in the BNGB (EDGV 3.0).
Same as categories/0, but raises on failure.
Get the list of classes available in the BNGB (EDGV 3.0).
Same as classes/0, but raises on failure.
Get the dictionary of API terms with translations to English, Spanish, and Portuguese labels.
Same as dictionary/0, but raises on failure.
Get the list of all geographic names in the BNGB.
Same as geo_names/0, but raises on failure.
Get a geographic name by its identifier.
Search geographic names by a pattern in the name.
Same as search/1, but raises on failure.
Functions
@spec by_bounding_box(number(), number(), number(), number()) :: {:ok, [ExIbge.Bngb.GeographicName.t()]} | {:error, any()}
Get geographic names within a bounding box defined by four coordinates.
Parameters
lon_w- Western longitude.lat_s- Southern latitude.lon_e- Eastern longitude.lat_n- Northern latitude.
Examples
iex> ExIbge.Bngb.by_bounding_box(-48.0, -16.0, -47.0, -15.0)
{:ok, [%ExIbge.Bngb.GeographicName{...}, ...]}See Also
@spec by_bounding_box!(number(), number(), number(), number()) :: [ ExIbge.Bngb.GeographicName.t() ]
Same as by_bounding_box/4, but raises on failure.
@spec by_category(String.t()) :: {:ok, [ExIbge.Bngb.GeographicName.t()]} | {:error, any()}
Get geographic names belonging to a given category.
Parameters
category- The category name (e.g., "Hidrografia", "Relevo").
Examples
iex> ExIbge.Bngb.by_category("Hidrografia")
{:ok, [%ExIbge.Bngb.GeographicName{category: "Hidrografia", ...}, ...]}See Also
@spec by_category!(String.t()) :: [ExIbge.Bngb.GeographicName.t()]
Same as by_category/1, but raises on failure.
@spec by_class(String.t()) :: {:ok, [ExIbge.Bngb.GeographicName.t()]} | {:error, any()}
Get geographic names belonging to a given class.
Parameters
class- The class name (e.g., "ilha", "curso_dagua").
Examples
iex> ExIbge.Bngb.by_class("ilha")
{:ok, [%ExIbge.Bngb.GeographicName{class: "ilha", ...}, ...]}See Also
@spec by_class!(String.t()) :: [ExIbge.Bngb.GeographicName.t()]
Same as by_class/1, but raises on failure.
@spec by_municipality(integer() | String.t()) :: {:ok, [ExIbge.Bngb.GeographicName.t()]} | {:error, any()}
Get geographic names by municipality geocode.
Parameters
geocode- The municipality geocode (e.g., "5300108" for Brasília).
Examples
iex> ExIbge.Bngb.by_municipality("5300108")
{:ok, [%ExIbge.Bngb.GeographicName{...}, ...]}See Also
@spec by_municipality!(integer() | String.t()) :: [ExIbge.Bngb.GeographicName.t()]
Same as by_municipality/1, but raises on failure.
@spec by_proximity(number(), number(), number()) :: {:ok, [ExIbge.Bngb.GeographicName.t()]} | {:error, any()}
Get geographic names near a coordinate within a given distance.
Parameters
lat- Latitude of the reference point.lon- Longitude of the reference point.km- Search radius in kilometers.
Examples
iex> ExIbge.Bngb.by_proximity(-15.79, -47.88, 10)
{:ok, [%ExIbge.Bngb.GeographicName{...}, ...]}See Also
@spec by_proximity!(number(), number(), number()) :: [ExIbge.Bngb.GeographicName.t()]
Same as by_proximity/3, but raises on failure.
@spec by_state(atom() | String.t()) :: {:ok, [ExIbge.Bngb.GeographicName.t()]} | {:error, any()}
Get geographic names by state (UF).
Parameters
state- The state abbreviation as a string (e.g., "DF") or atom (e.g.,:df).
Examples
iex> ExIbge.Bngb.by_state(:df)
{:ok, [%ExIbge.Bngb.GeographicName{...}, ...]}
iex> ExIbge.Bngb.by_state("RJ")
{:ok, [%ExIbge.Bngb.GeographicName{...}, ...]}See Also
@spec by_state!(atom() | String.t()) :: [ExIbge.Bngb.GeographicName.t()]
Same as by_state/1, but raises on failure.
@spec categories() :: {:ok, [ExIbge.Bngb.Category.t()]} | {:error, any()}
Get the list of categories available in the BNGB (EDGV 3.0).
Examples
iex> ExIbge.Bngb.categories()
{:ok, [%ExIbge.Bngb.Category{name: "Hidrografia"}, ...]}See Also
@spec categories!() :: [ExIbge.Bngb.Category.t()]
Same as categories/0, but raises on failure.
@spec classes() :: {:ok, [ExIbge.Bngb.Class.t()]} | {:error, any()}
Get the list of classes available in the BNGB (EDGV 3.0).
Examples
iex> ExIbge.Bngb.classes()
{:ok, [%ExIbge.Bngb.Class{name: "ilha", description: "...", category: "Hidrografia"}, ...]}See Also
@spec classes!() :: [ExIbge.Bngb.Class.t()]
Same as classes/0, but raises on failure.
@spec dictionary() :: {:ok, [ExIbge.Bngb.DictionaryEntry.t()]} | {:error, any()}
Get the dictionary of API terms with translations to English, Spanish, and Portuguese labels.
Examples
iex> ExIbge.Bngb.dictionary()
{:ok, [%ExIbge.Bngb.DictionaryEntry{term: "Hidrografia", label_pt: "Hidrografia", ...}, ...]}See Also
@spec dictionary!() :: [ExIbge.Bngb.DictionaryEntry.t()]
Same as dictionary/0, but raises on failure.
@spec geo_names() :: {:ok, [ExIbge.Bngb.GeoName.t()]} | {:error, any()}
Get the list of all geographic names in the BNGB.
Examples
iex> ExIbge.Bngb.geo_names()
{:ok, [%ExIbge.Bngb.GeoName{term: "Rio Amazonas"}, ...]}See Also
@spec geo_names!() :: [ExIbge.Bngb.GeoName.t()]
Same as geo_names/0, but raises on failure.
@spec get(integer() | String.t()) :: {:ok, [ExIbge.Bngb.GeographicName.t()]} | {:error, any()}
Get a geographic name by its identifier.
Parameters
id- The BNGB identifier of the geographic name.
Examples
iex> ExIbge.Bngb.get(180379)
{:ok, [%ExIbge.Bngb.GeographicName{name: "Brasília", ...}]}See Also
@spec get!(integer() | String.t()) :: [ExIbge.Bngb.GeographicName.t()]
Same as get/1, but raises on failure.
@spec search(String.t()) :: {:ok, [ExIbge.Bngb.GeographicName.t()]} | {:error, any()}
Search geographic names by a pattern in the name.
Parameters
pattern- The search pattern to match against geographic names.
Examples
iex> ExIbge.Bngb.search("brasilia")
{:ok, [%ExIbge.Bngb.GeographicName{name: "Brasília", ...}, ...]}See Also
@spec search!(String.t()) :: [ExIbge.Bngb.GeographicName.t()]
Same as search/1, but raises on failure.