Advertisement
metalx1000

GPS is a location north or south of a set location

Mar 22nd, 2016
661
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.54 KB | None | 0 0
  1. #!/bin/bash
  2. #Script which determinesif a location is north or south
  3. #of another location
  4.  
  5. if [ "$#" -lt 1 ]
  6. then
  7.   echo "input error"
  8.   echo "usage: $0 <adderss>"
  9.   echo "example usage: $0 '123 5th Ave S Naples FL'"
  10.   exit 1
  11. fi
  12.  
  13. #set station's Lat
  14. s="26.181617"
  15.  
  16. #Get Call's Lat
  17. address=$1
  18. c="$(wget -O- -q "https://maps.googleapis.com/maps/api/geocode/json?address=$address"|\
  19.  grep '"lat"'|head -n1|awk '{print $3}'|cut -d\, -f1)"
  20.  
  21. #Determine
  22. if (( $(bc <<< "$s < $c") ));
  23. then
  24.   echo "North";
  25. else
  26.   echo "Greater";
  27. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement