initial commit, grab osd and osm data and display blurb
This commit is contained in:
commit
963907fcf4
3 changed files with 27 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
secrets
|
||||
23
collector.sh
Executable file
23
collector.sh
Executable 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"
|
||||
3
secrets.example
Normal file
3
secrets.example
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
MMSI=#MMSI of the ship to track
|
||||
KEY=#OpenShipData API key
|
||||
Loading…
Add table
Add a link
Reference in a new issue