本文整理汇总了Python中pykml.factory.KML_ElementMaker.extrude方法的典型用法代码示例。如果您正苦于以下问题:Python KML_ElementMaker.extrude方法的具体用法?Python KML_ElementMaker.extrude怎么用?Python KML_ElementMaker.extrude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pykml.factory.KML_ElementMaker
的用法示例。
在下文中一共展示了KML_ElementMaker.extrude方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: finish
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import extrude [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
示例2: main
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import extrude [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()
示例3: test_to_wkt_list_complex_polygon
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import extrude [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: get_kml_doc
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import extrude [as 别名]
def get_kml_doc(llhs):
"""Generates a KML document from a Pandas table of single point
solutions. Requires columns lat, lon, and height.
"""
from pykml.parser import Schema
from pykml.factory import KML_ElementMaker as KML
from pykml.factory import GX_ElementMaker as GX
center = llhs[['lat', 'lon', 'height']].mean()
elts = lambda e: '%s,%s,%d' % (e['lon'], e['lat'], e['height'])
coords = ' '.join(llhs.apply(elts, axis=1).values)
xml_coords = KML.coordinates(coords)
doc = KML.kml(
KML.Placemark(
KML.name("gx:altitudeMode Example"),
KML.LookAt(
KML.longitude(center.lon),
KML.latitude(center.lat),
KML.heading(center.height),
KML.tilt(70),
KML.range(6300),
GX.altitudeMode("relativeToSeaFloor"),),
KML.LineString(
KML.extrude(1),
GX.altitudeMode("relativeToSeaFloor"),
xml_coords
)
)
)
return doc
示例5: build_test_kml
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import extrude [as 别名]
def build_test_kml():
"""build a simple KML file with a simple LineString, for testing purposes"""
from pykml.factory import KML_ElementMaker as KML
from pykml.factory import GX_ElementMaker as GX
from lxml import etree
from django.http import HttpResponse
kml = KML.kml(
KML.Placemark(
KML.name("build_test_kml output"),
KML.LookAt(
KML.longitude(146.806),
KML.latitude(12.219),
KML.heading(-60),
KML.tilt(70),
KML.range(6300),
GX.altitudeMode("relativeToSeaFloor"),
),
KML.LineString(
KML.extrude(1),
GX.altitudeMode("relativeToSeaFloor"),
KML.coordinates(
"146.825,12.233,400 "
"146.820,12.222,400 "
"146.812,12.212,400 "
"146.796,12.209,400 "
"146.788,12.205,400"
),
),
)
)
kml_str = etree.tostring(kml)
return HttpResponse(kml_str, content_type="application/vnd.google-earth.kml")
示例6: kmlpush
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import extrude [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)
示例7: AddPlacemarkAndZone
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import extrude [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)
示例8: buildKML
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import extrude [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()
示例9: _writerow
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import extrude [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],
))
示例10: task_to_kml_with_pykml
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import extrude [as 别名]
def task_to_kml_with_pykml(df_task, outdir, filename_base, disp):
from lxml import etree
from pykml.parser import Schema
from pykml.factory import KML_ElementMaker as KML
from pykml.factory import GX_ElementMaker as GX
s_coords = task_to_string(df_task)
(lat, lon) = calculate_center(df_task)
#def turn_point_to_placemark(tp):
# placemark = KML.Placemark(
# KML.name(tp['Name']),
# KML.description(tp['Name']),
# KML.Point(
# KML.coordinates(tp['Lon'], tp['Lat'], tp['Altitude'])
# ),
# )
# return(placemark)
#placemarks = [turn_point_to_placemark(tp) for i, tp in df_task.iterrows()]
doc = KML.kml(
KML.Placemark(
KML.name("Condor task '%s'" % filename_base),
KML.LookAt(
KML.longitude(lon),
KML.latitude(lat),
KML.heading(0),
KML.tilt(60),
KML.range(80000),
GX.altitudeMode("relativeToSeaFloor"),
#GX.altitudeMode("absolute"),
),
KML.LineString(
KML.extrude(1),
GX.altitudeMode("relativeToSeaFloor"),
#GX.altitudeMode("absolute"),
KML.coordinates(s_coords),
),
),
#*placemarks
)
if disp:
print(etree.tostring(doc, pretty_print=True))
# output a KML file (named based on the Python script)
filename_out = os.path.join(outdir, filename_base + '.kml')
print("Output '%s'" % filename_out)
outfile = file(filename_out,'w')
outfile.write(etree.tostring(doc, pretty_print=True))
assert Schema('kml22gx.xsd').validate(doc)
示例11: addLine
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import extrude [as 别名]
def addLine(doc,line):
coordinates = "";
for p in line:
coordinates += ("\n" + p.toKMLstr())
pm1 = KML.Placemark(
KML.name("GridLine"),
KML.visibility(1),
KML.LineString(
KML.extrude(1),
#KML.altitudeMode("relativeToGround"),
KML.tesselate(0),
KML.coordinates(coordinates)
)
)
doc.Document.append(pm1)
示例12: bounds_placemark
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import extrude [as 别名]
def bounds_placemark(origin, name, bounds_polygon):
bounds_list = []
for coord in list(bounds_polygon.exterior.coords):
(lon, lat, heading) = srr.util.local_to_global(origin,
coord[0], coord[1])
bounds_list.append("{lon},{lat},{alt}".format(lon=lon, lat=lat, alt=0))
bounds = " ".join(bounds_list)
return KML.Placemark(
KML.name(name),
KML.LineString(
KML.extrude(1.2),
KML.coordinates(bounds)
)
)
示例13: __legend_vertical__
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import extrude [as 别名]
def __legend_vertical__(self, levels=5, origin=(0, 0), vscale=100000):
# Generate a vertical legend for error
elements = []
z = 1
while z <= levels:
# Assumes that 1 unit height (vscale) is the mean error
elements.append(KML.Placemark(
KML.name('+%d z Score' % (z - 1) if z > 1 else 'Mean Error'),
KML.Style(
KML.IconStyle(
KML.Icon(
KML.href('http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png')))),
KML.Point(
KML.extrude(1),
KML.altitudeMode('absolute'),
KML.coordinates(('%d,%d,' % (origin[0] + z,
origin[1])) + str(z * vscale)))))
z += 1
return elements
示例14: addSegment
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import extrude [as 别名]
def addSegment(doc,seg,colorStr):
pm1 = KML.Placemark(
KML.name("OneSegment"),
KML.visibility(1),
#KML.styleUrl("#redLineBluePoly"),
KML.Style(
KML.LineStyle(
KML.color(colorStr),
KML.width(3)
)
),
KML.LineString(
KML.extrude(1),
KML.tesselate(0),
#KML.altitudeMode("relativeToGround"),
KML.coordinates("{}\n{}".format(seg[0].toKMLstr(),seg[1].toKMLstr())
)
)
)
doc.Document.append(pm1)
示例15: create_placemarks
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import extrude [as 别名]
def create_placemarks(location):
pm = KML.Placemark()
pm.append(
KML.description(
'<table border="1">'
'<tr><th>latitude</th><td>{lat}</td>'
'<tr><th>longitude</th><td>{lon}</td>'
'<tr><th>altitude</th><td>{alt}</td>'
'<tr><th>heading</th><td>{head}</td>'
'<tr><th>tilt</th><td>{tilt}</td>'
'<tr><th>roll</th><td>{roll}</td>'
'</table>'.format(
lat=location['loc'].latitude,
lon=location['loc'].longitude,
alt=location['loc'].altitude,
head=location['loc'].heading,
tilt=location['loc'].tilt,
roll=location['loc'].roll,
)
)
)
pm.append(
KML.TimeStamp(
KML.when(location['time'].strftime('%Y-%m-%dT%H:%M:%SZ'))
)
)
coord_list = [
str(location['loc'].longitude),
str(location['loc'].latitude),
]
if location['loc'].altitude != None:
coord_list.append(str(location['loc'].altitude))
pm.append(
KML.Point(
KML.extrude(1),
KML.altitudeMode('relativeToGround'),
KML.coordinates(','.join(coord_list)),
)
)
return pm