initial commit, grab osd and osm data and display blurb

This commit is contained in:
grizzly 2025-07-11 22:45:18 -04:00
commit 963907fcf4
3 changed files with 27 additions and 0 deletions

23
collector.sh Executable file
View file

@ -0,0 +1,23 @@
# Collects and logs data from the OpenShipData API and the OSM API
#
source ./secrets
# get ship data
osd_response=$(curl -s -G -d "key=$KEY" -d "ship=$MMSI" https://ais.marineplan.com/location/2/ship.json)
# get relevant data
lat=$(echo "$osd_response" | jq --raw-output .point.latitude)
lon=$(echo "$osd_response" | jq --raw-output .point.longitude)
bearing=$(echo "$osd_response" | jq --raw-output .bearingDeg)
speed=$(echo "$osd_response" | jq --raw-output .speedKmh)
echo "Le bateau est a $lat,$lon orientation $bearing a une vitesse de $speed km/h"
# get osm data
osm_response=$(curl -s -G -d "format=json" -d "lat=$lat" -d "lon=$lon" -d "accept-language=fr" https://nominatim.openstreetmap.org/reverse?)
town=$(echo "$osm_response" | jq --raw-output .address.town)
province=$(echo "$osm_response" | jq --raw-output .address.province)
country=$(echo "$osm_response" | jq --raw-output .address.country)
echo "La ville la plus proche est $town dans la province de $province, $country"