NOAA Observations v0.1.8 NOAA.Observations
Fetches a list of weather observations from a US state/territory.
Summary
Functions
Fetches weather observations from a US state
/territory
Fetches the latest observation for a given NOAA station
ID
Fetches a list of station IDs for a US state
/territory
Returns a URL based on the given station
ID or state
code
Types
Functions
Fetches weather observations from a US state
/territory.
Returns a tuple of either {:ok, [observation]}
or {:error, text}
.
Parameters
state
- US state/territory codeoptions
- URL templates (keyword)
Options
:url_templates
- defaults to config value:url_templates
(map)
Examples
alias NOAA.Observations
Observations.fetch("vt")
Fetches the latest observation for a given NOAA station
ID.
Returns a tuple of either {:ok, observation}
or {:error, text}
.
Parameters
station
- NOAA station ID (string)url_templates
- URL templates (map)
Examples
alias NOAA.Observations
app = Mix.Project.config[:app]
url_templates = Application.get_env(app, :url_templates)
Observations.observation("KBTV", url_templates)
Fetches a list of station IDs for a US state
/territory.
Returns a tuple of either {:ok, [station_id]}
or {:error, text}
.
Parameters
state
- US state/territory code (string)url_templates
- URL templates (map)
Examples
alias NOAA.Observations
app = Mix.Project.config[:app]
url_templates = Application.get_env(app, :url_templates)
Observations.stations("vt", url_templates)
Returns a URL based on the given station
ID or state
code.
Parameters
url_template
- URL templatekeyword
- [station:station
] or [state:state
]
Examples
iex> alias NOAA.Observations
iex> app = Mix.Project.config[:app]
iex> %{station: url_template} = Application.get_env(app, :url_templates)
iex> Observations.url(url_template, station: "KBTV")
"http://w1.weather.gov/xml/current_obs/KBTV.xml"
iex> alias NOAA.Observations
iex> app = Mix.Project.config[:app]
iex> %{state: url_template} = Application.get_env(app, :url_templates)
iex> Observations.url(url_template, state: "vt")
"http://w1.weather.gov/xml/current_obs/seek.php?state=vt&Find=Find"
iex> alias NOAA.Observations
iex> url_template = "https://weather.gc.ca/forecast/canada/" <>
...> "index_e.html?id=<st>"
iex> Observations.url(url_template, state: "qc")
"https://weather.gc.ca/forecast/canada/index_e.html?id=qc"