NOAA.Observations.Station (NOAA Observations v0.4.34) View Source
Fetches the latest observation for a given NOAA station
.
Link to this section Summary
Functions
Fetches the latest observation for a given NOAA station
.
Link to this section Types
Link to this section Functions
Specs
Fetches the latest observation for a given NOAA station
.
Returns a tuple of either {:ok, obs}
or {:error, text}
.
Parameters
{station, name}
- NOAA stationurl_templates
- URL templates
Examples
iex> alias NOAA.Observations.Station
iex> url_templates = [
...> station:
...> "https://w1.weather.gov/xml/current_obs/display.php?stid=" <>
...> "<%=station%>"
...> ]
iex> {:ok, obs} = Station.obs({"KFSO", "KFSO name"}, url_templates)
iex> is_map(obs) and
...> is_binary(obs["temp_c"]) and is_binary(obs["wind_mph"])
true
iex> alias NOAA.Observations.Station
iex> url_templates = [
...> station:
...> "htp://w1.weather.gov/xml/current_obs/display.php?stid=" <>
...> "<%=station%>"
...> ]
iex> {:error, text} = Station.obs({"KFSO", "KFSO name"}, url_templates)
iex> text
"reason => :nxdomain"
iex> alias NOAA.Observations.Station
iex> url_templates = [
...> station:
...> "https://w1.weather.gov/xml/past_obs/display.php?stid=" <>
...> "<%=station%>"
...> ]
iex> {:error, text} = Station.obs({"KFSO", "KFSO name"}, url_templates)
iex> text
"status code 404 ⇒ Not Found"