Add time data to KML output
This commit is contained in:
parent
cb9feea896
commit
52be9f5fe2
1 changed files with 20 additions and 20 deletions
40
main.py
40
main.py
|
@ -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>
|
||||
"""
|
||||
|
||||
|
|
Loading…
Reference in a new issue