NOAA.Observations.State (NOAA Observations v0.4.75)
View SourceFetches the stations of a US state/territory.
Summary
Functions
Fetches the stations for a state_code.
Types
@type code() :: <<_::16>>
US state/territory code
@type error() :: map()
State error
@type error_code() :: pos_integer() | atom()
State error code
Functions
@spec stations(code()) :: {:ok, [NOAA.Observations.Station.t()]} | {:error, error_code(), String.t()}
Fetches the stations for a state_code.
Returns a tuple of either {:ok, [station]} or {:error, error_code, text}.
Parameters
state_code- US state/territory code
Examples
iex> alias NOAA.Observations.{State, TemplatesAgent}
iex> :ok = TemplatesAgent.reset()
iex> {:ok, stations} = State.stations("VT")
iex> %{"KFSO" => name} = Map.new(stations)
iex> name
"Franklin County State Airport"
iex> alias NOAA.Observations.{State, TemplatesAgent}
iex> template =
...> "http://forecast.weather.gov/xml/current_obs" <>
...> "/seek.php?state=<%=state_code%>&Find=Find"
iex> :ok = TemplatesAgent.update_state_template(template)
iex> State.stations("VT")
{:error, 301, "Moved Permanently"}
iex> alias NOAA.Observations.{State, TemplatesAgent}
iex> template =
...> "htp://forecast.weather.gov/xml/current_obs" <>
...> "/seek.php?state=<%=state_code%>&Find=Find"
iex> :ok = TemplatesAgent.update_state_template(template)
iex> State.stations("VT")
{:error, :nxdomain, "Non-Existent Domain"}