diff --git a/modules/locationdata.py b/modules/locationdata.py index ebcea58..bb7cd82 100644 --- a/modules/locationdata.py +++ b/modules/locationdata.py @@ -13,16 +13,21 @@ trap_list_location = ("whereami", "tide", "moon", "wx", "wxc", "wxa", "wxalert") def where_am_i(lat=0, lon=0): whereIam = "" + grid = mh.to_maiden(float(lat), float(lon)) + if float(lat) == 0 and float(lon) == 0: return NO_DATA_NOGPS + + if float(lat) == latitudeValue and float(lon) == longitudeValue: + return "Grid: " + grid + # initialize Nominatim API geolocator = Nominatim(user_agent="mesh-bot") - + # Nomatim API call to get address location = geolocator.reverse(lat + ", " + lon) address = location.raw['address'] address_components = ['house_number', 'road', 'city', 'state', 'postcode', 'county', 'country'] whereIam += ' '.join([address.get(component, '') for component in address_components if component in address]) - grid = mh.to_maiden(float(lat), float(lon)) whereIam += " Grid: " + grid return whereIam @@ -263,4 +268,4 @@ def getActiveWeatherAlertsDetail(lat=0, lon=0): alerts = "\n".join(alerts) - return alerts \ No newline at end of file + return alerts