What is the (easiest) way to get current location or information about last known location using cli-command or python script? I am trying to write my first app for phones, so help is needed
J
Best posts made by Jarsa
-
Get GPS coordinates via terminal or python?
Latest posts made by Jarsa
-
RE: Get GPS coordinates via terminal or python?
Thank you both! This was more like a pre-app planning and testing ideas thing
I didn't know if there is a whoami type of command to location. So I checked the Utrack and quickly writed my own whereami-script.
Here is the code if someone needs it.
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import subprocess def whereami(): print('Searching...') latitude = '' longitude = '' for line in get_data(): if 'latitude' in line.decode("utf-8").lower(): latitude = line.decode("utf-8") if 'longtide' in line.decode("utf-8").lower(): longitude = line.decode("utf-8") if latitude and longitude: print('Location:\n {}\n {}'.format(latitude, longitude)) break def get_data(): cmd = "sudo test_gps" gps_data = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE) while True: line = gps_data.stdout.readline().rstrip() if not line: break yield line if __name__=='__main__': whereami()
-
Get GPS coordinates via terminal or python?
What is the (easiest) way to get current location or information about last known location using cli-command or python script? I am trying to write my first app for phones, so help is needed