-
Notifications
You must be signed in to change notification settings - Fork 1
/
mslRoute.py
executable file
·50 lines (43 loc) · 1.25 KB
/
mslRoute.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
import io
import urllib2
import json
from pykml.factory import KML_ElementMaker as KML
from pykml.factory import GX_ElementMaker as GX
from lxml import etree
URL = 'http://curiosityrover.com/drives'
route = json.loads( urllib2.urlopen(URL).read() )
pList = ''
for point in route:
pList = pList + str(point['lon']) + ',' + str(point['lat']) +',1,'
pm = KML.Placemark(
KML.name('Curiosity traversal'),
KML.LookAt(
KML.longitude(route[0]['lon']),
KML.latitude(route[0]['lat']),
KML.heading('0'),
KML.tilt('40'),
KML.range('2000'),
GX.altitudeMode('relativeToSeaFloor'),
),
KML.LineStyle(
KML.color('#00FFFF'),
KML.width(10)
),
KML.altitudeMode('clampToGround'),
KML.LineString(KML.extrude('1'), GX.altitudeMode('relativeToSeaFloor'), KML.coordinates(pList))
)
folder = KML.Folder()
folder.append(pm)
# create a document element with a single label style
kmlobj = KML.kml(
KML.Document(
KML.Style(
KML.LabelStyle( KML.scale(1) ),
id="big_label"
)
)
)
kmlobj.Document.append(folder)
with io.open('MSLRoute.kml','w') as out:
out.write(unicode(etree.tostring(etree.ElementTree(kmlobj),pretty_print=True)))