commit 963907fcf48d824db4f556dc319b320bc4b00e4f Author: grizzly Date: Fri Jul 11 22:45:18 2025 -0400 initial commit, grab osd and osm data and display blurb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..db2fc0d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +secrets diff --git a/collector.sh b/collector.sh new file mode 100755 index 0000000..020dea6 --- /dev/null +++ b/collector.sh @@ -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" diff --git a/secrets.example b/secrets.example new file mode 100644 index 0000000..cb53f4a --- /dev/null +++ b/secrets.example @@ -0,0 +1,3 @@ +#!/bin/bash +MMSI=#MMSI of the ship to track +KEY=#OpenShipData API key