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