Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+197
@@ -0,0 +1,197 @@
|
||||
import datetime
|
||||
|
||||
# wandelt die Zeit um
|
||||
def timer(mydata,num):
|
||||
|
||||
sm_since_1970 = ''
|
||||
sm_since_1970 = mydata[num][-4]
|
||||
sm_since_1970 = float(sm_since_1970)
|
||||
sec_since_1970 = sm_since_1970 / 1000.0
|
||||
sec_since_1970 = float(sec_since_1970)
|
||||
moment = datetime.datetime.fromtimestamp(sec_since_1970)
|
||||
moment = str(moment)
|
||||
|
||||
moment = moment.replace(' ','T')
|
||||
|
||||
if len(moment) < 20:
|
||||
moment += '.00'
|
||||
else:
|
||||
stripper(moment)
|
||||
|
||||
return moment
|
||||
# entfernt die letzten 4 Zeichen
|
||||
def stripper(text):
|
||||
result = text[:-4]
|
||||
return result
|
||||
|
||||
# einstellen der Farben
|
||||
def extensions():
|
||||
|
||||
outfile = ' <trk>\n'
|
||||
outfile += ' <extensions>\n'
|
||||
outfile += ' <line xmlns="http://www.topografix.com/GPX/gpx_style/0/2">\n'
|
||||
outfile += ' <color>FF0000</color>\n'
|
||||
outfile += ' </line>\n'
|
||||
outfile += ' </extensions>\n'
|
||||
outfile += ' <name></name>\n'
|
||||
outfile += ' <trkseg>\n'
|
||||
|
||||
return outfile
|
||||
# erstellt Trackpunkte
|
||||
def trkpt(mydata,num):
|
||||
|
||||
outfile = ' <trkpt lat="'
|
||||
var = mydata[num][-2]
|
||||
var = float(var)
|
||||
var = var*180/3.14159265359
|
||||
var = str(var)
|
||||
outfile += var
|
||||
outfile += '" lon="'
|
||||
var = mydata[num][-3]
|
||||
var = float(var)
|
||||
var = var*180/3.14159265359
|
||||
var = str(var)
|
||||
outfile += var
|
||||
outfile += '">\n'
|
||||
outfile += ' <time>'
|
||||
outfile += timer(mydata,num)
|
||||
outfile += 'Z</time>\n' #Z
|
||||
outfile += ' </trkpt>\n'
|
||||
|
||||
return outfile
|
||||
# Abschluss des Tracks
|
||||
def end():
|
||||
|
||||
outfile = ' </trkseg>\n'
|
||||
outfile += ' </trk>\n'
|
||||
|
||||
return outfile
|
||||
# Anfang der Datei
|
||||
def start():
|
||||
outfile = '<?xml version="1.0" encoding="UTF-8"?>\n'
|
||||
outfile += '<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.1" creator="OkMap 10.11.4" xmlns="http://www.topografix.com/GPX/1/1">\n' #<gpx version="1.1" creator="someone"
|
||||
|
||||
#outfile +='<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="Wikipedia" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">\n'
|
||||
|
||||
return outfile
|
||||
# Anfang des Informationsteils
|
||||
def header(mydata):
|
||||
|
||||
outfile = start()
|
||||
outfile += extensions()
|
||||
outfile += end()
|
||||
outfile += extensions()
|
||||
outfile += trkpt(mydata,0)
|
||||
outfile += end()
|
||||
|
||||
return outfile
|
||||
# Hauptteil der Informationen
|
||||
def converter(mydata):
|
||||
|
||||
outfile = ''
|
||||
for num in range(len(mydata)):
|
||||
|
||||
num_2 = num + 1
|
||||
if num_2 < len(mydata):
|
||||
outfile += extensions()
|
||||
outfile += trkpt(mydata,num)
|
||||
outfile += trkpt(mydata,num_2)
|
||||
outfile += end()
|
||||
else:
|
||||
pass
|
||||
|
||||
return outfile
|
||||
# Hauptteil der event Informationen
|
||||
def event_conv(mydata):
|
||||
|
||||
outfile = ''
|
||||
for num in range(len(mydata)):
|
||||
if mydata[num][-2] != '0' or mydata[num][-3] != '0':
|
||||
|
||||
'''
|
||||
outfile += ' <extensions>\n'
|
||||
outfile += ' <line xmlns="http://www.topografix.com/GPX/gpx_style/0/2">\n'
|
||||
outfile += ' <color>FF0000</color>\n'
|
||||
outfile += ' </line>\n'
|
||||
outfile += ' </extensions>\n'
|
||||
outfile += ' <name></name>\n'
|
||||
'''
|
||||
|
||||
outfile += ' <wpt lat="'
|
||||
var = mydata[num][-2]
|
||||
var = float(var)
|
||||
var = var*180/3.14159265359
|
||||
var = str(var)
|
||||
outfile += var
|
||||
outfile += '" lon="'
|
||||
var = mydata[num][-3]
|
||||
var = float(var)
|
||||
var = var*180/3.14159265359
|
||||
var = str(var)
|
||||
outfile += var
|
||||
outfile += '">\n <time>'
|
||||
outfile += timer(mydata,num)
|
||||
outfile += 'Z</time>\n <name></name>\n <desc>' #Z
|
||||
var = num
|
||||
var = str(var)
|
||||
outfile += var
|
||||
outfile += " Date: "
|
||||
outfile += timer(mydata,num)
|
||||
outfile += '</desc>\n </wpt>\n'
|
||||
outfile += ' <trk>\n'
|
||||
outfile += ' <trkseg>\n'
|
||||
outfile += trkpt(mydata,num)
|
||||
outfile += trkpt(mydata,num)
|
||||
outfile += end()
|
||||
|
||||
return outfile
|
||||
# verzweigung für das editieren eine gpx Datei
|
||||
def file_editor(datalist,e_en):
|
||||
|
||||
try:
|
||||
with open('Salchau/mydata.gpx','r') as datei:
|
||||
text = datei.read()
|
||||
|
||||
text = text.replace("</gpx>\n","")
|
||||
|
||||
if e_en == '1': # result.txt
|
||||
|
||||
full_file = text + converter(datalist) + '</gpx>\n'
|
||||
|
||||
elif e_en == '2': # event_result.txt
|
||||
|
||||
full_file = text + event_conv(datalist) + '</gpx>\n'
|
||||
|
||||
|
||||
with open('Salchau/mydata.gpx','w') as datei:#Salchau/
|
||||
|
||||
datei.write(full_file)
|
||||
|
||||
except Exception as error:
|
||||
print(error)
|
||||
# Erstellen einer gpx Datei
|
||||
def file_creator(datalist,e_en):
|
||||
|
||||
try:
|
||||
if e_en == '1': # result.txt
|
||||
|
||||
full_file = header(datalist) + converter(datalist) + '</gpx>\n'
|
||||
|
||||
elif e_en == '2': # event_result.txt
|
||||
|
||||
full_file = start() + event_conv(datalist) + '</gpx>\n'
|
||||
|
||||
except Exception as error:
|
||||
print(error)
|
||||
|
||||
with open('Salchau/mydata.gpx','w') as datei: #Salchau/
|
||||
|
||||
datei.write(full_file)
|
||||
# Entscheidung der verzweigung
|
||||
def file_typ(datalist,num,e_en):
|
||||
|
||||
if num == '1':
|
||||
file_creator(datalist,e_en)
|
||||
elif num == '2':
|
||||
file_editor(datalist,e_en)
|
||||
|
||||
Reference in new issue
Block a user