Add time data to KML output

This commit is contained in:
Klaus-Uwe Mitterer 2017-12-10 00:45:18 +01:00
parent cb9feea896
commit 52be9f5fe2

14
main.py
View file

@ -98,7 +98,8 @@ def buildGPX(data):
def buildKML(data):
output = """<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<kml xmlns="http://www.opengis.net/kml/2.2"
xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document>
<Placemark>
<ExtendedData>
@ -110,16 +111,15 @@ def buildKML(data):
<Data name="fill"><value>#00ff00</value></Data>
<Data name="fill-opacity"><value>0.4980392156862745</value></Data>
</ExtendedData>
<LineString>
<coordinates>
"""
<gx:Track>"""
for row in data:
output += "%s,%s,%s " % (row["lon"], row["lat"], row["alt"] or "0")
output += """
<when>%s</when>
<gx:coord>%s %s %s</gx:coord>""" % (row["ts"].isoformat(), row["lon"], row["lat"], row["alt"] or "0")
output += """
</coordinates>
</LineString>
</gx:Track>
</Placemark>
</Document>
</kml>