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

40
main.py
View file

@ -98,30 +98,30 @@ def buildGPX(data):
def buildKML(data):
output = """<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<ExtendedData>
<Data name="styleUrl"><value>#style</value></Data>
<Data name="styleHash"><value>1a1ac94e</value></Data>
<Data name="stroke"><value>#ffff00</value></Data>
<Data name="stroke-opacity"><value>0.4980392156862745</value></Data>
<Data name="stroke-width"><value>4</value></Data>
<Data name="fill"><value>#00ff00</value></Data>
<Data name="fill-opacity"><value>0.4980392156862745</value></Data>
</ExtendedData>
<LineString>
<coordinates>
"""
<kml xmlns="http://www.opengis.net/kml/2.2"
xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document>
<Placemark>
<ExtendedData>
<Data name="styleUrl"><value>#style</value></Data>
<Data name="styleHash"><value>1a1ac94e</value></Data>
<Data name="stroke"><value>#ffff00</value></Data>
<Data name="stroke-opacity"><value>0.4980392156862745</value></Data>
<Data name="stroke-width"><value>4</value></Data>
<Data name="fill"><value>#00ff00</value></Data>
<Data name="fill-opacity"><value>0.4980392156862745</value></Data>
</ExtendedData>
<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>
</Placemark>
</Document>
</gx:Track>
</Placemark>
</Document>
</kml>
"""