get location in grid or lat/long

pull/128/head
alanbjohnston 5 years ago committed by GitHub
parent a9ece0f51f
commit 8729989f6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,9 +4,47 @@
import requests import requests
from os import system from os import system
import re
latitude = 0
longitude = 0
URL = "https://geocode.search.hereapi.com/v1/geocode"
print("\nIn order to upload your satellite telemetry data to the AMSAT servers, we need to know your location\n") print("\nIn order to upload your satellite telemetry data to the AMSAT servers, we need to know your location\n")
print("\nYou can enter:")
print("1. Location name (e.g. country or city, state, etc)")
print("2. Grid square (e.g. FM29)")
print("3. Latitude and Longitude\n")
print("4. No location")
choice = input ("Enter your choice (1 -4):")
if (choice == 2):
regex = '[A-Z]+[A-Z]+[0-9]+[0-9]'
grid = input("Type your 4 character grid square (i.e. FM29): ")
if re.search(regex, grid):
print("grid is valid!")
else
print("grid is not valid!")
elif (choice == 3):
lat = input("Type your latitude: ")
try:
float(lat)
print("Valid number!")
except ValueError:
print("Not a number!")
long = input("Type your longitude: ")
try:
float(long)
print("Valid number!")
except ValueError:
print("Not a number!")
elif (choice == 1):
URL = "https://geocode.search.hereapi.com/v1/geocode"
print("Enter your location including country. \n\n") print("Enter your location including country. \n\n")
location = input("Type your location: ") #taking user input location = input("Type your location: ") #taking user input
api_key = '' # Acquire from developer.here.com api_key = '' # Acquire from developer.here.com
@ -24,6 +62,11 @@ longitude = data['items'][0]['position']['lng']
print(latitude) print(latitude)
print(longitude) print(longitude)
else:
print("You have chosen not to enter your location.")
print("To track satellites and upload telemetry data,")
print("you can set your location in Settings in FoxTelem.")
#file = open(r"/home/pi/CubeSatSim/groundstation/.profile","w+") #file = open(r"/home/pi/CubeSatSim/groundstation/.profile","w+")
latSedStr = 'sed -i "s/latitude=0.0/latitude=' + str(latitude) + '/g" /home/pi/FoxTelemetryData/FoxTelem.properties' latSedStr = 'sed -i "s/latitude=0.0/latitude=' + str(latitude) + '/g" /home/pi/FoxTelemetryData/FoxTelem.properties'

Loading…
Cancel
Save

Powered by TurnKey Linux.