Update locationdata.py

This commit is contained in:
SpudGunMan
2024-06-19 17:17:43 -07:00
parent 805bcb68c0
commit 3dd2df175e

View File

@@ -3,6 +3,7 @@
from geopy.geocoders import Nominatim # pip install geopy
import maidenhead as mh # pip install maidenhead
import requests # pip install requests
def where_am_i(lat=0, lon=0):
whereIam = ""
@@ -28,4 +29,16 @@ def where_am_i(lat=0, lon=0):
grid = mh.to_maiden(float(lat), float(lon))
whereIam += " Grid:" + grid
return whereIam
return whereIam
def get_tide(lat=0, lon=0):
station_lookup_url = "https://api.tidesandcurrents.noaa.gov/mdapi/prod/webapi/stations.json?lat=" + lat + "&lon=" + lon + "&radius=30"
station_data = requests.get(station_lookup_url, timeout=5)
if(station_data.ok):
station_json = station_data.json()
print(station_json)
station_id = station_json['stationList'][0]['stationId']
else:
return "error fetching station data"
return "tide data"