From 7e4822e4ec2987edc3269f4765b668dc100bec41 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 27 Nov 2024 22:22:19 -0800 Subject: [PATCH] Update locationdata.py --- modules/locationdata.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/locationdata.py b/modules/locationdata.py index 18c0bc7..ba4389f 100644 --- a/modules/locationdata.py +++ b/modules/locationdata.py @@ -325,11 +325,15 @@ def abbreviate_weather(row): return line -def getWeatherAlerts(lat=0, lon=0): +def getWeatherAlerts(lat=0, lon=0, useDefaultLatLon=False): # get weather alerts from NOAA limited to ALERT_COUNT with the total number of alerts found alerts = "" - if float(lat) == 0 and float(lon) == 0: + if float(lat) == 0 and float(lon) == 0 and not useDefaultLatLon: return NO_DATA_NOGPS + else: + if useDefaultLatLon: + lat = latitudeValue + lon = longitudeValue alert_url = "https://api.weather.gov/alerts/active.atom?point=" + str(lat) + "," + str(lon) #alert_url = "https://api.weather.gov/alerts/active.atom?area=WA" @@ -373,7 +377,7 @@ wxAlertCache = "" def alertBrodcast(): # get the latest weather alerts and broadcast them if there are any global wxAlertCache - currentAlert = getWeatherAlerts() + currentAlert = getWeatherAlerts(latitudeValue, longitudeValue) if currentAlert[0] == ERROR_FETCHING_DATA or currentAlert == NO_DATA_NOGPS or currentAlert == NO_ALERTS: wxAlertCache = ""