Make no-fix state of navigationd make more sense (such as not just defaulting to Detroit or some shit).
This commit is contained in:
parent
66d4c64a8a
commit
ff5a2e51e9
|
@ -31,14 +31,16 @@ def disconnectCyberware():
|
|||
except:
|
||||
print("Cannot disconnect Cyberware.")
|
||||
|
||||
gpsdData = None
|
||||
|
||||
def getMapImage(distance):
|
||||
def getMapImage(distance, gpsdData):
|
||||
ox.settings.use_cache = True
|
||||
|
||||
|
||||
# We don't want to send any data if we don't have a fix.
|
||||
if(gpsdData.lat == 0 and gpsdData.lon == 0):
|
||||
point = (42.352593, -83.2640164)
|
||||
return
|
||||
#point = (42.352593, -83.2640164)
|
||||
|
||||
point = (gpsdData.lat, gpsdData.lon)
|
||||
|
||||
try:
|
||||
G = ox.graph_from_point(point, dist=distance, dist_type="bbox", network_type="drive")
|
||||
|
@ -62,17 +64,20 @@ def getMapImage(distance):
|
|||
#
|
||||
# G = ox.graph_from_bbox(bbox=bbox, network_type="drive_service")
|
||||
|
||||
def sendLocation():
|
||||
try:
|
||||
#request = requests.post(urlLocation, json={ 'x': gpsdData.lat, 'y': gpsdData.lon, 'z': gpsdData.alt, 'o': gpsdData.track })
|
||||
request = requests.post(urlLocation, json={ 'x': None, 'y': None, 'z': None, 'o': None, 'uuid': uuid })
|
||||
except:
|
||||
print('Could not contact NightCall')
|
||||
def sendLocation(gpsdData):
|
||||
# We don't want to hit the API if we don't have a fix.
|
||||
if(gpsdData.lat != 0 and gpsdData.lon !=0):
|
||||
try:
|
||||
request = requests.post(urlLocation, json={ 'x': gpsdData.lat, 'y': gpsdData.lon, 'z': gpsdData.alt, 'o': None, 'uuid': uuid })
|
||||
except:
|
||||
print('Could not contact NightCall')
|
||||
|
||||
def sendMapImage():
|
||||
try:
|
||||
files = { 'image': open(uuid+".png", 'rb') }
|
||||
request = requests.post(urlImage, files=files)
|
||||
except FileNotFoundError: # Occurs if we don't have a fix yet.
|
||||
return
|
||||
except:
|
||||
print("Could not contact NightCall")
|
||||
|
||||
|
@ -90,11 +95,10 @@ while continueFlag:
|
|||
try:
|
||||
gpsdData = gpsd.get_current()
|
||||
except gpsd.NoFixError:
|
||||
gpsdData = None
|
||||
print("No GPS fix yet! Using default coordinates.")
|
||||
print("No GPS fix!")
|
||||
|
||||
getMapImage(1000)
|
||||
sendLocation()
|
||||
getMapImage(1000, gpsdData)
|
||||
sendLocation(gpsdData)
|
||||
sendMapImage()
|
||||
|
||||
#print(packet.position())
|
||||
|
@ -106,4 +110,8 @@ print("Removing Cyberware")
|
|||
disconnectCyberware()
|
||||
|
||||
print("Cleaning up")
|
||||
os.remove(uuid+".png")
|
||||
|
||||
try:
|
||||
os.remove(uuid+".png")
|
||||
except:
|
||||
print("No minimap image was ever made. GPS probably never had a fix.")
|
||||
|
|
Loading…
Reference in a new issue