View Source NOAA.Observations.Station (NOAA Observations v0.4.60)
Fetches the latest observation for a given NOAA station.
Summary
Functions
Fetches the latest observation for a given NOAA station
.
Types
Functions
@spec observation(t(), NOAA.Observations.State.code()) :: {:ok, observation()} | {:error, error()}
Fetches the latest observation for a given NOAA station
.
Returns either tuple {:ok, observation}
or tuple {:error, error}
.
Parameters
{station_id, station_name}
- NOAA stationstate_code
- US state/territory code
Examples
iex> alias NOAA.Observations.{Station, TemplatesAgent}
iex> :ok = TemplatesAgent.refresh()
iex> {:ok, observation} =
...> Station.observation({"KFSO", "KFSO name"}, "VT")
iex> is_map(observation) and is_binary(observation["wind_mph"])
true
iex> alias NOAA.Observations.{Station, TemplatesAgent}
iex> template =
...> "htp://forecast.weather.gov/xml/current_obs" <>
...> "/display.php?stid=<%=station_id%>"
iex> TemplatesAgent.update_station_template(template)
iex> {:error, %{error_text: text, error_code: code, station_id: id}} =
...> Station.observation({"KFSO", "KFSO name"}, "VT")
iex> {text, code, id}
{"Non-Existent Domain", :nxdomain, "KFSO"}
iex> alias NOAA.Observations.{Station, TemplatesAgent}
iex> template =
...> "https://forecast.weather.gov/xml/past_obs" <>
...> "/display.php?stid=<%=station_id%>"
iex> TemplatesAgent.update_station_template(template)
iex> {:error, %{error_text: text, error_code: code, station_id: id}} =
...> Station.observation({"KFSO", "KFSO name"}, "VT")
iex> {text, code, id}
{"Not Found", 404, "KFSO"}