summaryrefslogtreecommitdiffstats
path: root/weather/weather.go
diff options
context:
space:
mode:
Diffstat (limited to 'weather/weather.go')
-rw-r--r--weather/weather.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/weather/weather.go b/weather/weather.go
index 2eb2bf7..c3f48a3 100644
--- a/weather/weather.go
+++ b/weather/weather.go
@@ -21,6 +21,7 @@ type Weather struct {
Q2HTimeline WeatherTimeline // Q2H forecast of the next 12 hours.
BiDailyTimeline WeatherTimeline // BiDaily forecast for the next 3 days.
SearchEnabled bool
+ Alerts []Alert
}
type WeatherNow struct {
@@ -43,6 +44,13 @@ type WeatherTimeline struct {
Periods []WeatherPeriod
}
+type Alert struct {
+ Event string
+ Severity string
+ Description string
+ Instruction string
+}
+
func NewWeather(lat, lng float32) (*Weather, error, int) {
fBundle, nwsErr := nws.GetForecastBundle(lat, lng)
if nwsErr != nil {
@@ -110,5 +118,19 @@ func NewWeather(lat, lng float32) (*Weather, error, int) {
}
w.SearchEnabled = photon.Enabled()
+ // Add alerts if they exist.
+ if len(fBundle.Alerts.Features) > 0 {
+ w.Alerts = make([]Alert, 0)
+ for _, f := range fBundle.Alerts.Features {
+ a := Alert{
+ Event: f.Properties.Event,
+ Severity: f.Properties.Severity,
+ Description: f.Properties.Description,
+ Instruction: f.Properties.Instruction,
+ }
+ w.Alerts = append(w.Alerts, a)
+ }
+ }
+
return w, nil, 200
}