本文整理汇总了Python中pykml.factory.KML_ElementMaker.altitudeMode方法的典型用法代码示例。如果您正苦于以下问题:Python KML_ElementMaker.altitudeMode方法的具体用法?Python KML_ElementMaker.altitudeMode怎么用?Python KML_ElementMaker.altitudeMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pykml.factory.KML_ElementMaker
的用法示例。
在下文中一共展示了KML_ElementMaker.altitudeMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: kml_addAnimPoint
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitudeMode [as 别名]
def kml_addAnimPoint(self, pos, tm):
#pos[0] : latitude
#pos[1] : longitude
#pos[2] : altitude
#pos[3] : roll
#pos[4] : pitch
#pos[5] : yaw
if (pos == None):
return
localTimeStr = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.localtime(tm))
#rospy.logerr(localTimeStr)
self.anim_fld.append(KML.Placemark(
KML.TimeStamp(
KML.when(localTimeStr)
),
KML.altitudeMode("absolute"),
KML.styleUrl('#sn_shaded_dot'),
KML.LookAt(
KML.longitude(pos[1]),
KML.latitude(pos[0]),
KML.altitude(pos[2]),
KML.heading(pos[5]),
KML.tilt(0.0),
KML.range(100.0),
KML.altitudeMode("absolute"),
),
KML.Point(
KML.coordinates("{lon},{lat},{alt}".format(lon=pos[1], lat=pos[0], alt=pos[2]))
)
))
示例2: finish
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitudeMode [as 别名]
def finish(self, kmlFilename):
rospy.loginfo("[KMLTourGenerator] finish()")
if (self.hasFinished):
return
self.path_fld.append(KML.Placemark(
KML.name('plan-path'),
KML.extrude("1"),
KML.tessellate("1"),
KML.altitudeMode("absolute"),
KML.Style(
KML.LineStyle(
KML.color('7FFF0000'),
KML.width(5)
),
KML.PolyStyle(
KML.color('7FFFFF00')
)
),
KML.LineString(
KML.tessellate("1"),
KML.altitudeMode("absolute"),
KML.coordinates(self.planCoordListStr)
)
))
self.path_fld.append(KML.Placemark(
KML.name('exec-path'),
KML.altitudeMode("absolute"),
KML.Style(
KML.LineStyle(
KML.color('7F0000FF'),
KML.width(5)
),
KML.PolyStyle(
KML.color('7FFFFFFF')
)
),
KML.LineString(
KML.extrude("1"),
KML.tessellate("1"),
KML.altitudeMode("absolute"),
KML.coordinates(self.execCoordListStr)
)
))
# check that the KML document is valid using the Google Extension XML Schema
#assert(Schema("kml22gx.xsd").validate(self.tour_doc))
#print etree.tostring(self.tour_doc, pretty_print=True)
# output a KML file (named based on the Python script)
outfile = file(kmlFilename,'w')
outfile.write(etree.tostring(self.tour_doc, pretty_print=True))
self.hasFinished = True
示例3: test_to_wkt_list_complex_polygon
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitudeMode [as 别名]
def test_to_wkt_list_complex_polygon(self):
"""Tests the to_wkt_list function for a polygon with inner rings."""
from pykml.util import to_wkt_list
# create a polygon
poly = KML.Polygon(
KML.extrude('1'),
KML.altitudeMode('relativeToGround'),
KML.outerBoundaryIs(
KML.LinearRing(
KML.coordinates(
'-122.366278,37.818844,30 '
'-122.365248,37.819267,30 '
'-122.365640,37.819861,30 '
'-122.366669,37.819429,30 '
'-122.366278,37.818844,30 '
),
),
),
KML.innerBoundaryIs(
KML.LinearRing(
KML.coordinates(
'-122.366212,37.818977,30 '
'-122.365424,37.819294,30 '
'-122.365704,37.819731,30 '
'-122.366212,37.818977,30 '
),
),
),
KML.innerBoundaryIs(
KML.LinearRing(
KML.coordinates(
'-122.366212,37.818977,30 '
'-122.365704,37.819731,30 '
'-122.366488,37.819402,30 '
'-122.366212,37.818977,30 '
),
),
),
)
poly_wkt_list = to_wkt_list(poly)
self.assertEqual(len(poly_wkt_list), 1)
self.assertEqual(
poly_wkt_list[0],
('POLYGON ((-122.366278 37.818844 30, '
'-122.365248 37.819267 30, '
'-122.365640 37.819861 30, '
'-122.366669 37.819429 30, '
'-122.366278 37.818844 30), '
'(-122.366212 37.818977 30, '
'-122.365424 37.819294 30, '
'-122.365704 37.819731 30, '
'-122.366212 37.818977 30), '
'(-122.366212 37.818977 30, '
'-122.365704 37.819731 30, '
'-122.366488 37.819402 30, '
'-122.366212 37.818977 30))')
)
示例4: kml_addPathPoint
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitudeMode [as 别名]
def kml_addPathPoint(self, pos, dt):
#pos[0] : latitude
#pos[1] : longitude
#pos[2] : altitude
#pos[3] : roll
#pos[4] : pitch
#pos[5] : yaw
if (pos == None):
return
#rospy.logerr(pos)
self.tour_doc.Document[self.gxns+"Tour"].Playlist.append(
GX.FlyTo(
GX.duration(dt),
GX.flyToMode("smooth"),
#KML.Camera(
KML.LookAt(
KML.latitude(pos[0]),
KML.longitude(pos[1]),
KML.altitude(pos[2]),
KML.heading(pos[5]),
#KML.tilt(pos[4] + 90.0),
#KML.roll(pos[3]),
KML.tilt(pos[4] + 75.0),
KML.range(20.0),
KML.altitudeMode("absolute"),
),
),
)
auxStr = ' {lon},{lat},{alt}\n'.format(lon=pos[1], lat=pos[0], alt=pos[2])
#rospy.logerr(auxStr)
self.execCoordListStr = self.execCoordListStr + auxStr
示例5: test_basic_kml_document
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitudeMode [as 别名]
def test_basic_kml_document(self):
"""Tests the creation of a basic KML with Google Extensions ."""
doc = KML.kml(
GX.Tour(
GX.Playlist(
GX.SoundCue(
KML.href('http://dev.keyhole.com/codesite/cntowerfacts.mp3')
),
GX.Wait(
GX.duration(10)
),
GX.FlyTo(
GX.duration(5),
GX.flyToMode('bounce'),
KML.LookAt(
KML.longitude(-79.387),
KML.latitude(43.643),
KML.altitude(0),
KML.heading(-172.3),
KML.tilt(10),
KML.range(1200),
KML.altitudeMode('relativeToGround'),
)
)
)
)
)
self.assertTrue(Schema('kml22gx.xsd').validate(doc))
data = etree.tostring(doc, encoding='ascii')
expected = \
b'<kml xmlns:gx="http://www.google.com/kml/ext/2.2" ' \
b'xmlns:atom="http://www.w3.org/2005/Atom" ' \
b'xmlns="http://www.opengis.net/kml/2.2">' \
b'<gx:Tour>' \
b'<gx:Playlist>' \
b'<gx:SoundCue>' \
b'<href>http://dev.keyhole.com/codesite/cntowerfacts.mp3</href>' \
b'</gx:SoundCue>' \
b'<gx:Wait>' \
b'<gx:duration>10</gx:duration>' \
b'</gx:Wait>' \
b'<gx:FlyTo>' \
b'<gx:duration>5</gx:duration>' \
b'<gx:flyToMode>bounce</gx:flyToMode>' \
b'<LookAt>' \
b'<longitude>-79.387</longitude>' \
b'<latitude>43.643</latitude>' \
b'<altitude>0</altitude>' \
b'<heading>-172.3</heading>' \
b'<tilt>10</tilt>' \
b'<range>1200</range>' \
b'<altitudeMode>relativeToGround</altitudeMode>' \
b'</LookAt>' \
b'</gx:FlyTo>' \
b'</gx:Playlist>' \
b'</gx:Tour>' \
b'</kml>'
self.assertXmlEquivalentOutputs(data, expected)
示例6: main
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitudeMode [as 别名]
def main():
kmlobj = KML.kml( KML.Document(KML.Style(KML.LabelStyle(KML.scale(6)),id="big_label")))
data = '<?xml version="1.0" encoding="utf-8"?>\n<kml xmlns="http://www.opengis.net/kml/2.2">\n<Document>\n<name>Balloon with image</name>'
cconn = CloudConn.CloudConn(mav_id)
id = raw_input("flt_?")
stat , vals = cconn.getallfromflt(int(id))
counter = 0
if stat == cons.SUCCESS:
for each in vals:
lat = float(each[0].split(",")[0].split("=")[1])
lon = float(each[0].split(",")[1].split("=")[1])
alt = float(each[0].split(",")[2].split("=")[1])
kmlobj.Document.append(
KML.Placemark(
KML.name("ECE-445-DEMO"),
KML.Point(
KML.extrude(1),
KML.altitudeMode('relativeToGround'),
KML.coordinates('{lon},{lat},{alt}'.format(
lon=lon,
lat=lat,
alt=alt,
),
))))
#pm1 = KML.Placemark(KML.name(str(counter)),KML.Point(KML.coordinates(latlonstr)))
dax = etree.tostring(etree.ElementTree(kmlobj),pretty_print=True)
fd = open(fname+".kml", 'wb')
fd.write(dax)
fd.close()
示例7: _placemark_from_trip_and_track
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitudeMode [as 别名]
def _placemark_from_trip_and_track(trip_info):
coords = ""
for p in trip_info.track:
coords += "{0},{1} ".format(p.longitude, p.latitude)
start_coords = ""
end_coords = ""
if len(trip_info.track) > 0:
start_coords = _start_end_marker_coords_from_point(trip_info.track[0].latitude, trip_info.track[0].longitude)
end_coords = _start_end_marker_coords_from_point(trip_info.track[-1].latitude, trip_info.track[-1].longitude)
return [
KML.Placemark(
KML.name(trip_info.id),
KML.styleUrl("#hikeTrack"),
KML.LineString(
KML.altitudeMode("clampToGround"),
KML.coordinates(coords)
)
),
KML.Placemark(
KML.name(trip_info.id + "-start"),
KML.styleUrl("#hikeStart"),
KML.LineString(
KML.altitudeMode("clampToGround"),
KML.coordinates(start_coords)
)
),
KML.Placemark(
KML.name(trip_info.id + "-end"),
KML.styleUrl("#hikeEnd"),
KML.LineString(
KML.altitudeMode("clampToGround"),
KML.coordinates(end_coords)
)
)
]
示例8: AddPlacemarkAndZone
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitudeMode [as 别名]
def AddPlacemarkAndZone(doc, site):
name = site[0]
lat = float(site[1]) + float(site[2])/60.0 + float(site[3])/3600.0;
if site[4] == 'S':
lat = -lat
lng = float(site[5]) + float(site[6])/60.0 + float(site[7])/3600.0;
if site[8] == 'W':
lng = -lng
print 'Adding placemark for %s at (%f, %f)' % (name, lat, lng)
pm = KML.Placemark(
KML.name(name),
KML.styleUrl('#pm'),
KML.Point(
KML.coordinates('%f,%f,0' % (lng, lat))
)
)
doc.append(pm)
zone = KML.Placemark(
KML.name('%s zone' % name),
KML.styleUrl('#ts'),
KML.Polygon(
KML.extrude(0),
KML.altitudeMode('clampToGround')
)
)
poly = zone.Polygon
d = float(zone_radius) / float(earth_radius)
coords = []
# Note: generate perimeter points every 5 degrees around the circle.
step_degrees = 5
for az in xrange(0, 360, step_degrees):
a = float(az)
lat2 = math.asin(math.sin(math.radians(lat))*math.cos(d) +
math.cos(math.radians(lat))*math.sin(d)*math.cos(math.radians(a)))
lng2 = math.radians(lng) + math.atan2(
math.sin(math.radians(a))*math.sin(d)*math.cos(math.radians(lat)),
math.cos(d) - math.sin(math.radians(lat))*math.sin(lat2))
coords.append([math.degrees(lng2), math.degrees(lat2)])
coords.append(coords[0])
latlngCoords = []
for c in coords:
latlngCoords.append('%f,%f,0' % (c[0], c[1]))
coordinates = ' '.join(latlngCoords)
poly.append(KML.outerBoundaryIs(
KML.LinearRing(
KML.coordinates(coordinates)
)
))
doc.append(zone)
示例9: kmlpush
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitudeMode [as 别名]
def kmlpush(pt,label,stylename="sn_shaded_dot"):
global kmloutput,outkml
from pykml.factory import KML_ElementMaker as KML
if kmloutput is None:
kmloutput = KML.kml(
KML.Document(
KML.Name("Sun Position"),
KML.Style(
KML.IconStyle(
KML.scale(1.0),
KML.Icon(
KML.href("http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png"),
),
id="mystyle"
),
id="pushpin"
),
KML.Style(
KML.IconStyle(
KML.scale(1.0),
KML.Icon(
KML.href("http://maps.google.com/mapfiles/kml/pushpin/red-pushpin.png"),
),
id="redmystyle"
),
id="redpushpin"
),
KML.Style(
KML.IconStyle(
KML.scale(1.2),
KML.Icon(
KML.href("http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png")
),
),
id="sn_shaded_dot",
)
)
)
if pt is None:
from lxml import etree
open(outkml,"wb").write(etree.tostring(kmloutput, pretty_print=True))
return
pt = KML.Placemark(
KML.name(label),
KML.styleUrl('#{0}'.format(stylename)),
KML.Point(
KML.extrude(True),
KML.altitudeMode('relativeToGround'),
KML.coordinates("{0},{1}".format(pt.lon.value,pt.lat.value)),
),
)
kmloutput.Document.append(pt)
示例10: buildKML
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitudeMode [as 别名]
def buildKML():
media_filtered = pickle.load( open( "media_filtered.p", "rb" ) )
kml = open('media_KML.kml', "w")
kmlobj = KML.kml(
KML.Document(
KML.Style(
KML.BalloonStyle(
KML.displayMode('default'),
KML.text('<b>$[name]</b><br/>$[description]')
),
KML.IconStyle(
KML.Icon(
KML.href('http://maps.google.com/mapfiles/kml/paddle/red-circle.png'),
KML.scale('1.0')
),
id='mystyle'
),
id="balloonStyle"
)
)
)
# add placemarks to the Document element
for media in media_filtered:
kmlobj.Document.append(
KML.Placemark(
KML.name(media.location.name),
KML.description("Name: " + media.user.full_name +
"<br>Username: <a href=\"https://instagram.com/" + media.user.username + "/\">" + media.user.username + "</a><br>" +
"<img src=" + media.images['standard_resolution'].url + "><br>" +
media.caption.text),
KML.styleUrl('#balloonStyle'),
KML.TimeStamp(
KML.when(media.created_time.isoformat() + 'Z')
),
KML.Point(
KML.extrude(1),
KML.altitudeMode('relativeToGround'),
KML.coordinates('{lon},{lat},{alt}'.format(
lon=media.location.point.longitude,
lat=media.location.point.latitude,
alt=0,
),
),
),
)
)
kml.write(etree.tostring(etree.ElementTree(kmlobj),pretty_print=True))
kml.close()
示例11: _writerow
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitudeMode [as 别名]
def _writerow(self, row):
desc = map(lambda r: u': '.join(r) + u"<br>", zip(self.opts.fields, row))
self.placemarks.append(KML.Placemark(
KML.name(row[13]),
KML.Point(
KML.extrude(1),
KML.altitudeMode("relativeToGround"),
KML.coordinates(u"{lon},{lat},{alt}".format(lon=row[5],lat=row[4],alt=0)),
),
KML.description(
desc
),
id=row[0],
))
示例12: get_csv_doc
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitudeMode [as 别名]
def get_csv_doc(csv_path, index_name=None, index_lat=None, index_long=None,
altitude=0):
index_name = index_name or CSV_INDEX_NAME
index_lat = index_lat or CSV_INDEX_LAT
index_long = index_long or CSV_INDEX_LONG
print "Indexes: {n}, {l}, {L}".format(
n=index_name,
l=index_lat,
L=index_long
)
print "Reading from '{c}'".format(c=csv_path)
doc = KML.kml(
KML.name("Property List"),
etree.Comment(get_comment(csv_path)),
KML.Style(
KML.IconStyle(
KML.scale(1.0),
KML.Icon(
KML.href("http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png"),
),
id="mystyle"
),
id="pushpin"
),
)
with open(csv_path, 'r') as csvin:
reader = csv.reader(csvin)
for row in reader:
print "'{}' @ ({}, {})".format(
row[index_name],
row[index_lat],
row[index_long]
)
doc.append(KML.Placemark(
KML.name(row[index_name]),
KML.Point(
KML.altitudeMode('relativeToGround'),
KML.styleUrl("#pushpin"),
KML.coordinates("{},{},{}".format(
row[index_long],row[index_lat], altitude
))
)
))
return doc
示例13: addStations
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitudeMode [as 别名]
def addStations(doc,stations):
for value in stations.itervalues():
pm1 = KML.Placemark(
#KML.name(value[]+"-"+value[0]),
KML.name(value[2]),
KML.Point(
KML.altitudeMode("relativeToGround"),
KML.description(str(value)),
KML.coordinates("{},{},{}".format(
value[indiceLongitude],
value[indiceLatitude],
value[indiceAltitude],
)
),
),
)
doc.Document.append(pm1)
示例14: addStations2
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitudeMode [as 别名]
def addStations2(doc,points):
for value in points:
pm1 = KML.Placemark(
#KML.name(value[]+"-"+value[0]),
KML.name(value.val),
KML.Point(
KML.altitudeMode("relativeToGround"),
KML.description(str(value)),
KML.coordinates("{},{},{}".format(
value.x,
value.y,
1000,
)
),
),
)
doc.Document.append(pm1)
示例15: createPlacemark
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitudeMode [as 别名]
def createPlacemark(self, uuid, filetoDAE, center):
node_transformed = self.transformCoorindate(center)
pm1 = KML.Placemark(
KML.name(uuid),
KML.Model(
KML.styleUrl("#transYellowPoly"),
KML.altitudeMode('relativeToGround'),
KML.Location(
KML.longitude(node_transformed.getX()),
KML.latitude(node_transformed.getY()),
),
KML.Link(
KML.href(filetoDAE),
),
),
)
return pm1