#!/usr/bin/env bash # Ankara & Eskisehir are about 200kms away long/lat wise; # # Ank: 39.925533, 32.866287 # Esk: 39.766193, 30.526714. # # That's about 2.34 diff in longitude (much less in latitude), multiply by 100, # get rid of the floating part (round down aggressively), 200 seems like a good # margin, that's probably within Ankara borders # # The API recommends calling every 5 seconds (not more frequently, please!), 30 # seems fine # # Coords below are from the METU hoodie :) LEEWAY=200 response=$(curl -s http://api.open-notify.org/iss-now.json) lat=$(echo "${response}"| jq '.iss_position.latitude') long=$(echo "${response}"| jq '.iss_position.longitude') distlat=$(perl -e "print int(100 * abs(${lat} - 39.885833))") distlong=$(perl -e "print int(100 * abs(${long} - 32.779444))") if [ $distlat -lt $LEEWAY ] && [ $distlong -lt $LEEWAY ]; then echo "" else echo fi