fix a few bugs..
git-svn-id: http://www.neo1973-germany.de/svn@166 46df4e5c-bc4e-4628-a0fc-830ba316316d
This commit is contained in:
parent
e2ba31e402
commit
614de06019
2 changed files with 27 additions and 7 deletions
|
@ -95,11 +95,17 @@ class TrackClient:
|
||||||
|
|
||||||
def StartTrack(self):
|
def StartTrack(self):
|
||||||
self.SendData(self.__username, self.__pwhash, action="START")
|
self.SendData(self.__username, self.__pwhash, action="START")
|
||||||
|
|
||||||
# call self.UpdatePosition() when a dbus signal "PositionChanged" comes along the system bus
|
# call self.UpdatePosition() when a dbus signal "PositionChanged" comes along the system bus
|
||||||
|
# if an event handler has already been set, delete it!
|
||||||
|
try:
|
||||||
if self.terminator:
|
if self.terminator:
|
||||||
self.terminator.delete()
|
self.terminator.delete()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
self.terminator = self.pos_iface.connect_to_signal("PositionChanged", self.UpdateData)
|
self.terminator = self.pos_iface.connect_to_signal("PositionChanged", self.UpdateData)
|
||||||
|
|
||||||
|
|
||||||
def StopTrack(self):
|
def StopTrack(self):
|
||||||
self.SendData(self.__username, self.__pwhash, action="STOP")
|
self.SendData(self.__username, self.__pwhash, action="STOP")
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ This is a Class to create *.gpx Files
|
||||||
Usage:
|
Usage:
|
||||||
open new file: file = WriteGPX(filename)
|
open new file: file = WriteGPX(filename)
|
||||||
write trackpint: file.write(lat, lon, alt, utctime)
|
write trackpint: file.write(lat, lon, alt, utctime)
|
||||||
|
get status: file.GetStatus()
|
||||||
close file: file.close()
|
close file: file.close()
|
||||||
The file musst be closed, otherwise the file will be incomplete
|
The file musst be closed, otherwise the file will be incomplete
|
||||||
'''
|
'''
|
||||||
|
@ -15,6 +16,7 @@ from __future__ import with_statement
|
||||||
class WriteGPX:
|
class WriteGPX:
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
|
self.status = 'started'
|
||||||
self.header = '<?xml version="1.0" encoding="UTF-8"?>\n\
|
self.header = '<?xml version="1.0" encoding="UTF-8"?>\n\
|
||||||
<gpx version="1.1"\n\
|
<gpx version="1.1"\n\
|
||||||
creator="WriteGPX - Python Class used in PyTracker.py"\n\
|
creator="WriteGPX - Python Class used in PyTracker.py"\n\
|
||||||
|
@ -25,17 +27,29 @@ class WriteGPX:
|
||||||
<trkseg>\n'
|
<trkseg>\n'
|
||||||
self.footer = '</trkseg>\n</trk>\n</gpx>\n'
|
self.footer = '</trkseg>\n</trk>\n</gpx>\n'
|
||||||
|
|
||||||
with open(self.filename,'a') as file:
|
with open(self.filename,'w') as file:
|
||||||
file.write(self.header)
|
file.write(self.header)
|
||||||
|
self.status = 'active'
|
||||||
|
print "file started!"
|
||||||
|
|
||||||
def write(self, lat, lon, ele, time):
|
def write(self, lat, lon, ele, time):
|
||||||
self.trackpoint = '<trkpt lat="%s" lon="%s">\n\
|
self.trackpoint = '<trkpt lat="%s" lon="%s">\n\
|
||||||
<ele>%s</ele>\n\
|
<ele>%s</ele>\n\
|
||||||
<time>%s</time>\n\
|
<time>%s</time>\n\
|
||||||
</trkpt>\n' % (lat, lon, ele, time)
|
</trkpt>\n' % (lat, lon, ele, time)
|
||||||
|
if self.status != 'closed':
|
||||||
with open(self.filename,'a') as file:
|
with open(self.filename,'a') as file:
|
||||||
file.write(self.trackpoint)
|
file.write(self.trackpoint)
|
||||||
|
print "file updated!"
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
with open(self.filename,'a') as file:
|
with open(self.filename,'a') as file:
|
||||||
|
if self.status != 'closed':
|
||||||
file.write(self.footer)
|
file.write(self.footer)
|
||||||
|
self.status = 'closed'
|
||||||
|
print "file closed successfully"
|
||||||
|
else:
|
||||||
|
print "file closed already!"
|
||||||
|
|
||||||
|
def GetStatus():
|
||||||
|
print self.status
|
||||||
|
|
Loading…
Reference in a new issue