Remove spaces from track string since newest Google Earth appears to hate them. Made modes_kml a child class of SQL while I was at it.

This commit is contained in:
Nick Foster 2012-06-14 15:45:01 -07:00
parent 1be63eba0a
commit 3515c4d4a9

View File

@ -23,14 +23,15 @@ import sqlite3
import string, math, threading, time import string, math, threading, time
from air_modes.modes_sql import modes_output_sql from air_modes.modes_sql import modes_output_sql
class modes_kml(threading.Thread): class modes_kml(threading.Thread, modes_output_sql):
def __init__(self, filename, localpos, timeout=5): def __init__(self, filename, localpos, timeout=5):
threading.Thread.__init__(self) threading.Thread.__init__(self)
self._dbname = 'adsb.db'
modes_output_sql.__init__(localpos, self._dbname) #write to the db
self._db = sqlite3.connect(self._dbname) #read from the db
self._filename = filename self._filename = filename
self.my_coords = localpos self.my_coords = localpos
self._timeout = timeout self._timeout = timeout
self._dbname = 'adsb.db'
self._sqlobj = modes_output_sql(self.my_coords, self._dbname)
self.done = False self.done = False
self.setDaemon(1) self.setDaemon(1)
@ -38,22 +39,17 @@ class modes_kml(threading.Thread):
def run(self): def run(self):
while self.done is False: while self.done is False:
self.write() self.writekml()
time.sleep(self._timeout) time.sleep(self._timeout)
self.done = True self.done = True
def output(self, string): def writekml(self):
self._sqlobj.insert(string)
def write(self):
self._db = sqlite3.connect(self._dbname)
kmlstr = self.genkml() kmlstr = self.genkml()
if kmlstr is not None: if kmlstr is not None:
f = open(self._filename, 'w') f = open(self._filename, 'w')
f.write(kmlstr) f.write(kmlstr)
f.close() f.close()
self._db.close()
def draw_circle(self, center, rng): def draw_circle(self, center, rng):
retstr = "" retstr = ""
@ -119,7 +115,7 @@ class modes_kml(threading.Thread):
trackstr = "" trackstr = ""
for pos in track: for pos in track:
trackstr += " %f, %f, %f" % (pos[4], pos[3], pos[2]*0.3048) trackstr += " %f,%f,%f" % (pos[4], pos[3], pos[2]*0.3048)
trackstr = string.lstrip(trackstr) trackstr = string.lstrip(trackstr)
else: else: