NOAA Observations v0.2.3 NOAA.Observations View Source
Fetches a list of weather observations from a US state/territory.
Link to this section 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
Link to this section Types
Link to this section Functions
Link to this function
fetch(state, options \\ [])
View Source
fetch(state, Keyword.t) :: {:ok, [observation]} | {:error, String.t}
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 for:url_templates
(map)
Examples
alias NOAA.Observations
Observations.fetch "vt"
Link to this function
observation(station, map)
View Source
observation(station_id, map) :: {:ok, observation} | {:error, String.t}
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
Link to this function
stations(state, map)
View Source
stations(state, map) :: {:ok, [station_id]} | {:error, String.t}
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"