本文整理汇总了Python中pykml.factory.KML_ElementMaker.width方法的典型用法代码示例。如果您正苦于以下问题:Python KML_ElementMaker.width方法的具体用法?Python KML_ElementMaker.width怎么用?Python KML_ElementMaker.width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pykml.factory.KML_ElementMaker
的用法示例。
在下文中一共展示了KML_ElementMaker.width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: colourStyle
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import width [as 别名]
def colourStyle(self,
doc,
colourID,
colour_normal,
width_normal,
colour_highlight,
width_highlight):
"""
Append line style elements to a KML document.
Arguments:
doc: KML document to hold the new styles
colourID: the base ID for the styles
colour_normal: normal colour for the line
width_normal: normal width for the line
colour_highlight: highlighted colour for the line
width_highlight: highlighted width for the line
"""
doc.append(
KML.Style(
KML.IconStyle(
KML.Icon(),
id="no_icon_n"
),
KML.LineStyle(
KML.color(colour_normal),
KML.width(width_normal)
),
id=(colourID + '_n')
)
)
doc.append(
KML.Style(
KML.IconStyle(
KML.Icon(),
id="no_icon_h"
),
KML.LineStyle(
KML.color(colour_highlight),
KML.width(width_highlight)
),
id=(colourID + '_h')
)
)
doc.append(
KML.StyleMap(
KML.Pair(
KML.key('normal'),
KML.styleUrl('#' + colourID + '_n')
),
KML.Pair(
KML.key('highlight'),
KML.styleUrl('#' + colourID + '_h')
),
id=colourID
)
)
示例2: finish
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import width [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: initDocument
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import width [as 别名]
def initDocument():
doc = KML.kml(
KML.Document(
KML.Name("Sun Position"),
KML.Style(
KML.IconStyle(
KML.scale(1.2),
KML.Icon(
KML.href("http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png")
),
),
id="truc"
),
KML.Style(
KML.LineStyle(
KML.color("ff0000ff"),
KML.width(1)
),
KML.PolyStyle(
KML.color("ffff0000")
),
id="redLineBluePoly"
)
)
)
return doc
示例4: TranslateShpFileToKML
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import width [as 别名]
def TranslateShpFileToKML(file):
print 'Translating file %s' % file
basename = os.path.splitext(os.path.basename(file))[0]
doc = KML.kml(
KML.Document(
KML.name('US Census Tracts ' + basename),
KML.Style(
KML.LineStyle(
KML.color('ff00ff00'),
KML.width(2)
),
KML.PolyStyle(
KML.color('66006600')
),
id="ts"
)
)
)
ProcessShpFile(file, basename, doc)
kmlFilename = os.path.join(os.path.dirname(file), basename + '.kml')
print 'Writing output file %s' % kmlFilename
outputFile = open(kmlFilename, 'w+')
outputFile.write(etree.tostring(doc, pretty_print=True))
outputFile.close()
示例5: run
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import width [as 别名]
def run(self):
self.counter = self.counter + 1
self.origin = osr.SpatialReference ()
self.origin.ImportFromEPSG(self.EPSG)
stylename = "export_dm"
doc = KML.kml()
document = KML.Document()
docname = KML.Name("DynaMind Export")
document.append(docname)
doc.append(document)
document.append(
KML.Style(
KML.LineStyle(
KML.width(3),
KML.color(self.rgb_to_hex( 0,255,255,255)),
),
KML.PolyStyle(
KML.color(self.rgb_to_hex( 0,255,255,255)),
),
id="#SWMM",
)
)
fld = KML.Folder()
city = self.getData("City")
uuids = city.getUUIDs(View(self.ViewName, COMPONENT, READ))
objectid_total = 0
for uuid in uuids:
#getLinks
building = city.getComponent(uuid)
objects = []
if self.Type == "COMPONENT":
center = Node(building.getAttribute("centroid_x").getDouble(), building.getAttribute("centroid_y").getDouble(),0.0)
LinkAttributes = building.getAttribute("Geometry").getLinks()
for attribute in LinkAttributes:
objects.append(attribute.uuid)
self.createPlacemarkForSelection(city.getComponent(uuid), uuid, center, fld)
if self.Type == "FACE":
objects.append(uuid)
self.createPlacemarkAsLineRing(city, objects, fld)
document.append(self.create_syles(city, uuid))
if self.Type == "EDGE":
objects.append(uuid)
self.createPlacemarkAsLineString(city, objects, fld)
doc.Document.append(fld)
text_file = open(self.Filename+"_"+str(self.counter)+str(".kml"), "w")
text_file.write(etree.tostring(doc, pretty_print=True))
text_file.close()
示例6: create_style
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import width [as 别名]
def create_style(id_, color, width, scale, icon):
style = KML.Style(id=id_)
if scale is not None:
icon_style = KML.IconStyle(KML.scale(scale))
if icon is not None:
icon_style.append(KML.Icon(KML.href(icon)))
style.append(icon_style)
if (color is not None) and (width is not None):
line_style = KML.LineStyle(KML.color(color), KML.width(width))
style.append(line_style)
return KmlStyle(id_, [style])
示例7: kml_styles
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import width [as 别名]
def kml_styles(self, labels, outlines=False, alpha=1.0):
'''Generates PyKML <Style> instances for each color in the ramp'''
styles = list()
for label, color in zip(labels, self.kml_colors(alpha)):
if outlines:
styles.append(KML.Style(KML.PolyStyle(color), id=(label)))
else:
styles.append(KML.Style(KML.LineStyle(KML.width(0)),
KML.PolyStyle(color), id=(label)))
return styles
示例8: create_kml_placemarks_for_tracks_and_waypoints
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import width [as 别名]
def create_kml_placemarks_for_tracks_and_waypoints(tracks, waypoints, sample=1, description=None, color=None, name=None):
placemarks = []
tracks = tracks or []
waypoints = waypoints or []
for track in tracks:
coordinates = ["%s,%s" % (p.longitude, p.latitude) for i, p in enumerate(track.points) if
i % sample == 0 or len(track.points) < 100]
placemarks.append(
KML.Placemark(
KML.name(name or track.name),
KML.description(description or track.description or ""),
KML.Style(
KML.LineStyle(
KML.color(color) if color else get_random_color(),
KML.width(3)
)
),
KML.MultiGeometry(
KML.LineString(
KML.coordinates(" ".join(coordinates))
)
)
)
)
for waypoint in waypoints:
coordinates = "%s,%s" % (waypoint.long, waypoint.lat)
placemarks.append(
KML.Placemark(
KML.name(name or waypoint.name),
KML.description(description or waypoint.description or ""),
KML.Style(
KML.IconStyle(
KML.color("ffffffff"),
KML.scale(1.0),
KML.Icon(
KML.href(
"http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png")
),
),
KML.LabelStyle(
KML.scale(0.0)
)
),
KML.Point(
KML.coordinates(coordinates)
)
)
)
return placemarks
示例9: write_boundary_grid_kml
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import width [as 别名]
def write_boundary_grid_kml(self, boundary, datetime, boundary_grids):
if self.logger:
self.logger.info("Start write_boundary_grid_kml for boundary: %s Date: %s" % (boundary, datetime))
kml_doc = KML.kml(KML.Document(
KML.Name("Boundary: %s" % (boundary)),
KML.Style(
KML.LineStyle(
KML.color('ffff0000'),
KML.width(3),
),
KML.PolyStyle(
KML.color('800080ff'),
),
id='grid_style'
)
)
)
#doc = etree.SubElement(kml_doc, 'Document')
try:
for polygon, val in boundary_grids:
coords = " ".join("%s,%s,0" % (tup[0],tup[1]) for tup in polygon.exterior.coords[:])
kml_doc.Document.append(KML.Placemark(KML.name('%f' % val),
KML.styleUrl('grid_style'),
KML.Polygon(
KML.outerBoundaryIs(
KML.LinearRing(
KML.coordinates(coords)
)
)
))
)
except (TypeError,Exception) as e:
if self.logger:
self.logger.exception(e)
else:
try:
kml_outfile = "%s%s_%s.kml" % (self.KMLDir, boundary, datetime.replace(':', '_'))
if self.logger:
self.logger.debug("write_boundary_grid_kml KML outfile: %s" % (kml_outfile))
kml_file = open(kml_outfile, "w")
kml_file.write(etree.tostring(kml_doc, pretty_print=True))
kml_file.close()
except (IOError,Exception) as e:
if self.logger:
self.logger.exception(e)
if self.logger:
self.logger.info("End write_boundary_grid_kml for boundary: %s Date: %s" % (boundary, datetime))
return
示例10: visualize_trips
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import width [as 别名]
def visualize_trips(trips, kml_file):
"""Writes KML for the given trips to the given kml_file path."""
kml_doc = KML.Document(
KML.description("Hello, world."),
KML.Style(
KML.LineStyle(
KML.color("1fffffff"),
KML.width("3")
),
id="hikeTrack"
),
KML.Style(
KML.LineStyle(
KML.color("1f00ff00"),
KML.width("10")
),
id="hikeStart"
),
KML.Style(
KML.LineStyle(
KML.color("1f0000ff"),
KML.width("10")
),
id="hikeEnd"
)
)
for trip in trips:
kml_doc.extend(
_placemark_from_trip_and_track(trip)
)
with codecs.open(kml_file, 'w', 'utf-8') as file:
file.write(etree.tostring(KML.kml(kml_doc), encoding='unicode'))
logging.info("Wrote KML for {0} tracks to '{1}'".format(len(trips), kml_file))
示例11: create_syles
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import width [as 别名]
def create_syles(self,city, object):
obj = city.getComponent(object)
r = int( obj.getAttribute("color_r").getDouble() * 255.)
#print r
g = int( obj.getAttribute("color_g").getDouble() * 255.)
b = int( obj.getAttribute("color_b").getDouble() * 255.)
alpha = int( obj.getAttribute("color_alpha").getDouble() * 255.)
sty = KML.Style(
KML.LineStyle(
KML.width(0.5),
),
KML.PolyStyle(
KML.color(self.rgb_to_hex( r,g,b,alpha)),
),
id="style_"+str(object),
)
return sty
示例12: addSegment
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import width [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)
示例13: get_kml_for_queryset
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import width [as 别名]
def get_kml_for_queryset(queryset, filename=_('Geographical objects')):
"""
:param queryset: GeoObject queryset
:return: KML file from GeoObject queryset
"""
kml = KML.kml(KML.Document(KML.open(1)))
geo_objects = queryset.values_list('color', 'title', 'lat', 'lon', 'geometry', 'short_description')
colors = set(items[0] for items in sorted(geo_objects))
colors_dict = {color: convert_color_hex_to_kml(color) for color in colors}
for line_color, polygon_color in colors_dict.values():
kml.Document.append(KML.Style(
KML.PolyStyle(KML.color(polygon_color)),
KML.LineStyle(KML.color(line_color), KML.width(2)),
id=line_color,
))
print(line_color, polygon_color)
for (color, title, lat, lon, polygon, short_description) in geo_objects:
style_id = colors_dict[color][0]
fld = KML.Folder(
KML.name(title),
KML.Placemark(
KML.name(title),
KML.styleUrl('#' + style_id),
KML.description(short_description),
KML.Point(KML.coordinates("{},{},0".format(lon, lat)))
)
)
if polygon:
polygon = parser.fromstring(polygon.kml)
fld.append(KML.Placemark(KML.name(title), KML.styleUrl('#' + style_id),
KML.description(short_description), polygon))
kml.Document.append(fld)
kml_str = '<?xml version="1.0" encoding="UTF-8"?>\n' + etree.tostring(kml, pretty_print=True).decode()
return get_file_response(kml_str, filename)
示例14: create_kml_from_track
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import width [as 别名]
def create_kml_from_track(track):
coordinates = ["%s,%s" % (p.longitude, p.latitude) for p in track.points]
doc = KML.kml(
KML.Document(
KML.Placemark(
KML.name(track.name),
KML.description(track.description if track.description else ""),
KML.Style(
KML.LineStyle(
KML.color('ff78fff0'),
KML.width(3)
)
),
KML.MultiGeometry(
KML.LineString(
KML.coordinates(" ".join(coordinates))
)
)
)
)
)
return doc
示例15: gen_klm
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import width [as 别名]
def gen_klm(self):
_doc = K.kml()
doc = etree.SubElement(_doc, 'Document')
for i, item in enumerate(self.tagged_gps):
doc.append(K.Placemark(
K.name('pl'+str(i+1)),
K.Point(
K.coordinates(
str(item).strip('[]').replace(' ', '')
)
)
)
)
doc.append(K.Placemark(
K.name('path'),
K.LineStyle(
K.color('#00FFFF'),
K.width(10)
),
K.LineString(
K.coordinates(
' '.join([str(item).strip('[]').replace(' ', '') for item in self.tagged_gps])
)
)
))
s = etree.tostring(_doc)
file_path = self.output + 'GoogleEarth_points.kml'
f = open(file_path,'w')
f.write(s)
f.close()
print '[INFO] KML file generated on:', file_path