From e30ae3eee86a45eb87a691f165f4175d4315c5f3 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 26 Jun 2024 13:28:16 -0700 Subject: [PATCH] Update locationdata.py --- locationdata.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/locationdata.py b/locationdata.py index cfba686..9bbf638 100644 --- a/locationdata.py +++ b/locationdata.py @@ -80,7 +80,14 @@ def get_weather(lat=0, lon=0, unit=0): weather = "" if float(lat) == 0 and float(lon) == 0: return NO_DATA_NOGPS - weather_url = "https://forecast.weather.gov/MapClick.php?FcstType=text&lat=" + str(lat) + "&lon=" + str(lon) + "&unit=" + str(unit) + + if unit == 0: + # default to imperial units + weather_url = "https://forecast.weather.gov/MapClick.php?FcstType=text&lat=" + str(lat) + "&lon=" + str(lon) + else: + # metric units + weather_url = "https://forecast.weather.gov/MapClick.php?FcstType=text&unit=1&lat=" + str(lat) + "&lon=" + str(lon) + try: weather_data = requests.get(weather_url, timeout=URL_TIMEOUT) if not weather_data.ok: