NOAA.Observations (NOAA Observations v0.4.75)

View Source

Fetches weather observations of a US state/territory.

Summary

Types

Groups of station observations/errors/timeouts

Group of station timeouts

Functions

Fetches weather observations for a state_code.

Types

groups()

@type groups() :: %{
  optional(:ok) => [NOAA.Observations.Station.observation()],
  optional(:error) => [NOAA.Observations.Station.error()],
  optional(:timeout) => [NOAA.Observations.Station.time_out()]
}

Groups of station observations/errors/timeouts

timeout_group()

@type timeout_group() :: %{
  optional(:timeout) => [NOAA.Observations.Station.time_out()]
}

Group of station timeouts

Functions

fetch(state_code)

Fetches weather observations for a state_code.

Parameters

  • state_code - US state/territory code

Examples

iex> alias NOAA.Observations
iex> alias NOAA.Observations.TemplatesAgent
iex> :ok = TemplatesAgent.reset()
iex> %{ok: observations} = Observations.fetch("VT")
iex> Enum.all?(observations, &is_map/1) and length(observations) > 0
true

iex> alias NOAA.Observations
iex> alias NOAA.Observations.TemplatesAgent
iex> template = "http://localhost:65535"
iex> :ok = TemplatesAgent.update_state_template(template)
iex> {:error,
...>  %{
...>    state_code: "VT",
...>    state_name: "Vermont",
...>    state_url: url,
...>    error_code: :econnrefused,
...>    error_text: "Connection Refused By Server"
...>  }} = Observations.fetch("VT")
iex> url
"http://localhost:65535"