ExIbge.Bngb (ex_ibge v0.4.0)

Copy Markdown View Source

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.

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.

Same as get/1, but raises on failure.

Search geographic names by a pattern in the name.

Same as search/1, but raises on failure.

Functions

by_bounding_box(lon_w, lat_s, lon_e, lat_n)

@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

IBGE API: Nomes Geográficos por enquadramento

by_bounding_box!(lon_w, lat_s, lon_e, lat_n)

@spec by_bounding_box!(number(), number(), number(), number()) :: [
  ExIbge.Bngb.GeographicName.t()
]

Same as by_bounding_box/4, but raises on failure.

by_category(category)

@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

IBGE API: Nomes Geográficos por categoria

by_category!(category)

@spec by_category!(String.t()) :: [ExIbge.Bngb.GeographicName.t()]

Same as by_category/1, but raises on failure.

by_class(class)

@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

IBGE API: Nomes Geográficos por classe

by_class!(class)

@spec by_class!(String.t()) :: [ExIbge.Bngb.GeographicName.t()]

Same as by_class/1, but raises on failure.

by_municipality(geocode)

@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

IBGE API: Nomes Geográficos por município

by_municipality!(geocode)

@spec by_municipality!(integer() | String.t()) :: [ExIbge.Bngb.GeographicName.t()]

Same as by_municipality/1, but raises on failure.

by_proximity(lat, lon, km)

@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

IBGE API: Nomes Geográficos por proximidade

by_proximity!(lat, lon, km)

@spec by_proximity!(number(), number(), number()) :: [ExIbge.Bngb.GeographicName.t()]

Same as by_proximity/3, but raises on failure.

by_state(state)

@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

IBGE API: Nomes Geográficos por UF

by_state!(state)

@spec by_state!(atom() | String.t()) :: [ExIbge.Bngb.GeographicName.t()]

Same as by_state/1, but raises on failure.

categories()

@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

IBGE API: Lista de categorias

categories!()

@spec categories!() :: [ExIbge.Bngb.Category.t()]

Same as categories/0, but raises on failure.

classes()

@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

IBGE API: Lista de classes

classes!()

@spec classes!() :: [ExIbge.Bngb.Class.t()]

Same as classes/0, but raises on failure.

dictionary()

@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

IBGE API: Dicionário

dictionary!()

@spec dictionary!() :: [ExIbge.Bngb.DictionaryEntry.t()]

Same as dictionary/0, but raises on failure.

geo_names()

@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

IBGE API: Lista dos nomes geográficos

geo_names!()

@spec geo_names!() :: [ExIbge.Bngb.GeoName.t()]

Same as geo_names/0, but raises on failure.

get(id)

@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

IBGE API: Nome Geográfico

get!(id)

@spec get!(integer() | String.t()) :: [ExIbge.Bngb.GeographicName.t()]

Same as get/1, but raises on failure.

search(pattern)

@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

IBGE API: Nomes Geográficos por padrão

search!(pattern)

@spec search!(String.t()) :: [ExIbge.Bngb.GeographicName.t()]

Same as search/1, but raises on failure.