예제 #1
0
 def writetrack(self,track,latitude=0,longitude=0,altitude=0,append=True,coordlist=[],log=True):
     """Append a track  or display a coordinate list in Google Earth"""
     #Track is a string key for the self.tracks dictionary (i.e. "balloon")
     track = track.lower()
     #Check to see if the track is currently being plotted (checkboxes on GUI)
     if self.tracks[track]["active"]==True:
         #Determine where the kml files are stored from the dict
         filepath = self.tracks[track]["file"]
         #Default for the function unless the user specifically indicates otherwise
         if append:
             #User must also specify the current long, lat, or altitude, default (0,0,0)
             position = (longitude, latitude, altitude)                
             #Log the new coordinate to file if currently saving logs
             if log==True:
                 logfile = self.tracks[track]["log"]
                 self.writelog([position],logfile)
             #Use writetoKML to append the position into the Google Earth KML
             writetoKML.writeonce(position,filepath)
         #If Append is false, and the user has defined a coordinate list
         else:
             #Log the list to file if currently saving logs
             if log==True:
                 logfile = self.tracks[track]["log"]
                 savetime = datetime.datetime.now().date()
                 #Rename the old log before overwriting
                 if self.renamelog(logfile,savetime):
                     self.writelog(coordlist,logfile)
             #Completely rewrite the coordinate list with the current data
             writetoKML.rewrite(coordlist,filepath)
예제 #2
0
 def writetrack(self,track,latitude=0,longitude=0,altitude=0,append=True,coordlist=None):
     if self.tracks[track]["active"]==True:
         filepath = self.tracks[track]["file"]
         if append:                
             position = (longitude, latitude, altitude)                
             writetoKML.writeonce(position,filepath)
         else:
             writetoKML.rewrite(coordlist,filepath)
예제 #3
0
 def writetrack(self,
                track,
                latitude=0,
                longitude=0,
                altitude=0,
                append=True,
                coordlist=None):
     if self.tracks[track]["active"] == True:
         filepath = self.tracks[track]["file"]
         if append:
             position = (longitude, latitude, altitude)
             writetoKML.writeonce(position, filepath)
         else:
             writetoKML.rewrite(coordlist, filepath)
예제 #4
0
 def writetrack(self,
                track,
                latitude=0,
                longitude=0,
                altitude=0,
                append=True,
                coordlist=[],
                log=True):
     """Append a track  or display a coordinate list in Google Earth"""
     #Track is a string key for the self.tracks dictionary (i.e. "balloon")
     track = track.lower()
     #Check to see if the track is currently being plotted (checkboxes on GUI)
     if self.tracks[track]["active"] == True:
         #Determine where the kml files are stored from the dict
         filepath = self.tracks[track]["file"]
         #Default for the function unless the user specifically indicates otherwise
         if append:
             #User must also specify the current long, lat, or altitude, default (0,0,0)
             position = (longitude, latitude, altitude)
             #Log the new coordinate to file if currently saving logs
             if log == True:
                 logfile = self.tracks[track]["log"]
                 self.writelog([position], logfile)
             #Use writetoKML to append the position into the Google Earth KML
             writetoKML.writeonce(position, filepath)
         #If Append is false, and the user has defined a coordinate list
         else:
             #Log the list to file if currently saving logs
             if log == True:
                 logfile = self.tracks[track]["log"]
                 savetime = datetime.datetime.now().date()
                 #Rename the old log before overwriting
                 if self.renamelog(logfile, savetime):
                     self.writelog(coordlist, logfile)
             #Completely rewrite the coordinate list with the current data
             writetoKML.rewrite(coordlist, filepath)
예제 #5
0
    def main(self):
        try:
            savedtime = 0
            if self.localonly == False:
                server = socket.socket()
                server.connect((self.ip, self.port))
            else:
                if os.name == "nt":
                    filepath = os.path.expanduser("~") + "\\tnclogs\\tnc.log"
                    print filepath
                elif os.name == "posix":
                    filepath = os.path.expanduser("~/Documents/tnc.log")
                else:
                    print "UNKNOWN OPERATING SYSTEM. GET A LIFE."
                f = open(filepath)
                savedtime = os.stat(filepath).st_mtime
            print "Successfully Connected"
            while not done:
                incoming = ""
                if self.localonly == True:
                    time = os.stat(filepath).st_mtime
                    print "Initial " + str(time)
                    while time == savedtime:
                        time = os.stat(filepath).st_mtime
                    ##                                        print time
                    savedtime = time
                    f.close()
                    f = open(filepath, "r")
                    print "Retrieving data"
                    # find last line
                    allLines = f.readlines()
                    lastline = allLines[len(allLines) - 1]
                    print lastline
                    try:
                        compatible, listento = decodeTNC.determineCompatability(lastline, self.acceptedSigns)
                        if compatible == True:
                            if "PKWDPOS" in listento:
                                listento = "d710"
                            lon, lat = decodeTNC.latlong(lastline)
                            incoming = {listento: {"latitude": lat, "longitude": lon}}
                            print incoming

                    except TypeError:
                        print "Unsolved TypeError, sucks to be you!"
                ##                                    except TypeError:

                else:
                    incoming = server.recv(1000)
                    if incoming == "":
                        break
                    ##                                print incoming
                    try:
                        incoming = json.loads(incoming)
                    except ValueError:
                        print "BAD JSON"
                        print incoming
                        continue
                    print incoming
                if incoming != "":
                    for sign in self.acceptedSigns:
                        write = False
                        for callsign in incoming:
                            if sign.lower() in callsign.lower():
                                write = True
                                ##                                                        print "Found Balloon Signature"
                                afile = "Balloon Track.kml"
                            elif "d710" in callsign.lower():
                                write = True
                                ##                                                        print "Found D710 Signature"
                                afile = "D710 Track.kml"
                            elif "port change notification" in callsign.lower():
                                newport = incoming[callsign]
                                server.close()
                                print "Closing old port"
                                del (server)
                                server = socket.socket()
                                server.connect((self.ip, newport))
                                print "Opened new port: " + str(newport)
                            if write == True:
                                try:
                                    lat = incoming[callsign]["latitude"]
                                    lon = incoming[callsign]["longitude"]
                                    print lat
                                    print lon
                                    writetoKML.writeonce((str(lon) + "," + str(lat)), afile)
                                except KeyError:
                                    print "No Latitude or Longitude"
                        if write == True:
                            break

        except KeyboardInterrupt:
            if self.localonly != True:
                server.close()
                print "Closed"

        except socket.herror:
            print "Invalid address"
        finally:
            if self.localonly != True:
                server.close()
                print "Closed"
예제 #6
0
<marker lat="40.22030" lng="-110.03380" phz="Descent" hgt=" 16523" tim="104845" ftm="108.75"/>
<marker lat="40.22029" lng="-110.03423" phz="Descent" hgt=" 15948" tim="104858" ftm="108.98"/>
<marker lat="40.22028" lng="-110.03466" phz="Descent" hgt=" 15372" tim="104912" ftm="109.21"/>
<marker lat="40.22028" lng="-110.03513" phz="Descent" hgt=" 14796" tim="104927" ftm="109.46"/>
<marker lat="40.22015" lng="-110.03567" phz="Descent" hgt=" 14255" tim="104940" ftm="109.68"/>
<marker lat="40.22002" lng="-110.03623" phz="Descent" hgt=" 13713" tim="104954" ftm="109.91"/>
<marker lat="40.21990" lng="-110.03679" phz="Descent" hgt=" 13172" tim="105008" ftm="110.14"/>
<marker lat="40.21976" lng="-110.03739" phz="Descent" hgt=" 12631" tim="105023" ftm="110.39"/>
<marker lat="40.21959" lng="-110.03788" phz="Descent" hgt=" 12118" tim="105036" ftm="110.61"/>
<marker lat="40.21942" lng="-110.03838" phz="Descent" hgt=" 11605" tim="105050" ftm="110.84"/>
<marker lat="40.21925" lng="-110.03888" phz="Descent" hgt=" 11093" tim="105104" ftm="111.07"/>
<marker lat="40.21907" lng="-110.03941" phz="Descent" hgt=" 10580" tim="105118" ftm="111.31"/>
<marker lat="40.21884" lng="-110.03960" phz="Descent" hgt=" 10094" tim="105131" ftm="111.53"/>
<marker lat="40.21860" lng="-110.03979" phz="Descent" hgt=" 9607" tim="105145" ftm="111.76"/>
<marker lat="40.21836" lng="-110.03999" phz="Descent" hgt=" 9121" tim="105159" ftm="111.99"/>
<marker lat="40.21811" lng="-110.04020" phz="Descent" hgt=" 8635" tim="105213" ftm="112.23"/>
<marker lat="40.21789" lng="-110.04005" phz="Descent" hgt=" 8175" tim="105227" ftm="112.45"/>
<marker lat="40.21766" lng="-110.03990" phz="Descent" hgt=" 7714" tim="105240" ftm="112.67"/>
<marker lat="40.21744" lng="-110.03976" phz="Descent" hgt=" 7254" tim="105253" ftm="112.89"/>
<marker lat="40.21720" lng="-110.03960" phz="Descent" hgt=" 6794" tim="105307" ftm="113.12"/>
<marker lat="40.21509" lng="-110.03690" phz="Touchdown" hgt=" 6679" tim="105633" ftm="116.55"/>"""

newarray1 = newdata.split("\n")
newarray2 = []
for marker in newarray1:
    newarray2.append(marker.split('"'))

for marker in newarray2:
    writetoKML.writeonce(
        "%s,%s,%s" % (marker[3], marker[1], marker[7].strip(" ")), "./NSV.kml")
예제 #7
0
filepath = '/Users/Ian/Documents/My Dropbox/saved_tnc.log/testTNC.log'
print "Monitoring "+str(filepath)
FILE = open(filepath,'r')
savedtime = os.stat(filepath).st_mtime
lastline = ''
while 1:
    time = os.stat(filepath).st_mtime
##    print "Waiting..."
    if time!=savedtime:
        savedtime=time
        print "Updated"
        FILE.close()
        FILE = open(filepath,'r')
        print "Retrieving data"
        #find last line
        linecount = 0
        seekbit = []
        offset = 0
        for line in FILE:
            linecount+=1
            seekbit.append(offset)
            offset+=len(line)
        print str(linecount)+" lines"
        print seekbit
        FILE.seek(seekbit[linecount-1])
        lastline = FILE.read()
        print lastline
        longlat = decodeTNC.latlong(lastline)
        writetoKML.writeonce(longlat)
        print "Map Updated"
예제 #8
0
<marker lat="40.22030" lng="-110.03338" phz="Descent" hgt=" 17099" tim="104831" ftm="108.52"/>
<marker lat="40.22030" lng="-110.03380" phz="Descent" hgt=" 16523" tim="104845" ftm="108.75"/>
<marker lat="40.22029" lng="-110.03423" phz="Descent" hgt=" 15948" tim="104858" ftm="108.98"/>
<marker lat="40.22028" lng="-110.03466" phz="Descent" hgt=" 15372" tim="104912" ftm="109.21"/>
<marker lat="40.22028" lng="-110.03513" phz="Descent" hgt=" 14796" tim="104927" ftm="109.46"/>
<marker lat="40.22015" lng="-110.03567" phz="Descent" hgt=" 14255" tim="104940" ftm="109.68"/>
<marker lat="40.22002" lng="-110.03623" phz="Descent" hgt=" 13713" tim="104954" ftm="109.91"/>
<marker lat="40.21990" lng="-110.03679" phz="Descent" hgt=" 13172" tim="105008" ftm="110.14"/>
<marker lat="40.21976" lng="-110.03739" phz="Descent" hgt=" 12631" tim="105023" ftm="110.39"/>
<marker lat="40.21959" lng="-110.03788" phz="Descent" hgt=" 12118" tim="105036" ftm="110.61"/>
<marker lat="40.21942" lng="-110.03838" phz="Descent" hgt=" 11605" tim="105050" ftm="110.84"/>
<marker lat="40.21925" lng="-110.03888" phz="Descent" hgt=" 11093" tim="105104" ftm="111.07"/>
<marker lat="40.21907" lng="-110.03941" phz="Descent" hgt=" 10580" tim="105118" ftm="111.31"/>
<marker lat="40.21884" lng="-110.03960" phz="Descent" hgt=" 10094" tim="105131" ftm="111.53"/>
<marker lat="40.21860" lng="-110.03979" phz="Descent" hgt=" 9607" tim="105145" ftm="111.76"/>
<marker lat="40.21836" lng="-110.03999" phz="Descent" hgt=" 9121" tim="105159" ftm="111.99"/>
<marker lat="40.21811" lng="-110.04020" phz="Descent" hgt=" 8635" tim="105213" ftm="112.23"/>
<marker lat="40.21789" lng="-110.04005" phz="Descent" hgt=" 8175" tim="105227" ftm="112.45"/>
<marker lat="40.21766" lng="-110.03990" phz="Descent" hgt=" 7714" tim="105240" ftm="112.67"/>
<marker lat="40.21744" lng="-110.03976" phz="Descent" hgt=" 7254" tim="105253" ftm="112.89"/>
<marker lat="40.21720" lng="-110.03960" phz="Descent" hgt=" 6794" tim="105307" ftm="113.12"/>
<marker lat="40.21509" lng="-110.03690" phz="Touchdown" hgt=" 6679" tim="105633" ftm="116.55"/>"""

newarray1 = newdata.split("\n")
newarray2 = []
for marker in newarray1:
    newarray2.append(marker.split('"'))

for marker in newarray2:
    writetoKML.writeonce("%s,%s,%s" % (marker[3],marker[1],marker[7].strip(" ")),"./NSV.kml")