Get exact gps location within java application

Viewed 16

I currently am working on a Java application that will be run as a Jar on a linux desktop system. I'm wanting to grab my GPS lat and long or the approximate address (current street would be preferable). Is it possible to find this without using a web browser? As in just using bash commands and calls to external web API's.

My current code uses this to get the lat and long but its off by a fair few KM's.

curl ipinfo.io|grep loc|head -n 1|cut -d\" -f4

If I can get the address then I can run this call to find the lat and long

wget -O- -q "https://maps.google.com/maps/api/geocode/json?address=[ADDRESS]&key=[MY_API_KEY]"|grep -A2 '"location"'|tail -n2|cut -d\: -f2|tr '\n' ' ';echo ""

Thanks

0 Answers
Related