本文整理汇总了Python中pykml.factory.KML_ElementMaker.name方法的典型用法代码示例。如果您正苦于以下问题:Python KML_ElementMaker.name方法的具体用法?Python KML_ElementMaker.name怎么用?Python KML_ElementMaker.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pykml.factory.KML_ElementMaker
的用法示例。
在下文中一共展示了KML_ElementMaker.name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: kml
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import name [as 别名]
def kml(locations):
"""KML file for the locations
"""
# create document
document = KML.kml(KML.Document(KML.name("Layer example")))
# bullets
for layer_code,layer_name in categories(locations):
style = KML.Style(
KML.IconStyle(
KML.scale(1.0),
KML.Icon(
KML.href('%slocations/%s.png' % (settings.MEDIA_URL, layer_code)),
),
id='icon-%s' % layer_code
),
id=layer_code
)
document.append(style)
# locations
folder = KML.Folder()
for location in locations:
placemark = KML.Placemark(
KML.name(location['title']),
KML.description('<![CDATA[ %s ]]>' % location['description']),
KML.styleUrl('#%s' % location['category']),
KML.Point(
KML.coordinates(','.join([location['lng'],location['lat']]))
),
)
folder.append(placemark)
document.append(folder)
# rettsugo!
return etree.tostring(document)
示例2: test_basic_kml_document_2
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import name [as 别名]
def test_basic_kml_document_2(self):
"""Tests the creation of a basic OGC KML document."""
doc = KML.kml(
KML.Document(
KML.name('KmlFile'),
KML.Placemark(
KML.name('Untitled Placemark'),
KML.Point(
KML.coordinates('-95.265,38.959,0')
)
)
)
)
# validate against a local schema
self.assertTrue(Schema('ogckml22.xsd').validate(doc))
# validate against a remote schema
self.assertTrue(Schema('http://schemas.opengis.net/kml/2.2.0/ogckml22.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'<Document>' \
b'<name>KmlFile</name>' \
b'<Placemark>' \
b'<name>Untitled Placemark</name>' \
b'<Point>' \
b'<coordinates>-95.265,38.959,0</coordinates>' \
b'</Point>' \
b'</Placemark>' \
b'</Document>' \
b'</kml>'
self.assertXmlEquivalentOutputs(data, expected)
示例3: plot_kml
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import name [as 别名]
def plot_kml(galaxy):
"""
Hacky function to dump a galaxy to a kml. Be sure pykml is installed before using.
"""
from pykml.factory import KML_ElementMaker as KML
from lxml import etree
fld = KML.kml()
for system in galaxy:
a = KML.Placemark(
KML.name('foo'),
KML.Point(
KML.coordinates('%f,%f' % (galaxy[system]["position_x"],galaxy[system]["position_y"]))
)
)
fld.append(a)
for dest in galaxy[system]['destinations']:
a = KML.Placemark(
KML.name("foo"),
KML.LineString(
KML.coordinates(
"%s,%s %s,%s" % (galaxy[system]["position_x"],galaxy[system]["position_y"], galaxy[dest]["position_x"],galaxy[dest]["position_y"])
)
)
)
fld.append(a)
f = open("test.kml", 'wa')
f.write(etree.tostring(fld, pretty_print=True))
f.close()
示例4: createAdditionalGeometry
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import name [as 别名]
def createAdditionalGeometry(self, type, name='blank', coordin='0,0'):
"""
`Author`: Bill Clark
This method allows for a user to create new point, linestrings, and linearrings. It will default the
name and coordinates for the object if they aren't provided, but every call requires a type, one of the
above three. This method appends the created kml to the additions folder which needs to be produced beforehand.
`type`: String, reading Point, LineString, or LinearRing.
`name`: The name tag for the element. Simply for identification. Must be a String.
`coordin`: The coordinates for the kml. Must be a String.
`return`:
"""
if type == "Point":
pm1 = KML.Placemark(KML.name(name),KML.Point(KML.coordinates(coordin)))
elif type == "LineString":
pm1 = KML.Placemark(KML.name(name),KML.LineString(KML.coordinates(coordin)))
elif type == "LinearRing":
pm1 = KML.Placemark(KML.name(name),KML.LinearRing(KML.coordinates(coordin)))
else:
print 'Derp.'
self.additionfolder.append(pm1)
示例5: generateKML
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import name [as 别名]
def generateKML(ids, spotList):
km = KML.kml()
doc = KML.Document(KML.name("Aires camping car info"))
icones = glob.glob(LOGOS_FOLDER+"A*")
for icone in icones:
icone = icone.replace(DESC_FOLDER, "")
type = os.path.basename(icone).replace("40.gif", "")
style = KML.Style(
KML.IconStyle(
KML.scale(1.0),
KML.Icon(
KML.href(icone),
),
),
id=type.lower()
)
doc.append(style)
for id in ids:
idStr = str(id)
with codecs.open(DESC_FOLDER+"/"+idStr+".html",'r',encoding='utf-8') as f:
place = KML.Placemark(
KML.name(spotList[id]["name"]),
KML.description(f.read()),
KML.styleUrl("#"+spotList[id]["type"].lower()),
KML.Point(
KML.coordinates(spotList[id]["lat"]+","+spotList[id]["long"])
)
)
doc.append(place)
km.append(doc)
print(etree.tostring(km))
示例6: test_basic_kml_document_2
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import name [as 别名]
def test_basic_kml_document_2(self):
"""Tests the creation of a basic OGC KML document."""
doc = KML.kml(
KML.Document(
KML.name("KmlFile"),
KML.Placemark(
KML.name("Untitled Placemark"),
KML.Point(
KML.coordinates("-95.265,38.959,0")
)
)
)
)
self.assertTrue(Schema("kml22gx.xsd").validate(doc))
self.assertEquals(
etree.tostring(doc),
'<kml xmlns:gx="http://www.google.com/kml/ext/2.2" '
'xmlns:atom="http://www.w3.org/2005/Atom" '
'xmlns="http://www.opengis.net/kml/2.2">'
'<Document>'
'<name>KmlFile</name>'
'<Placemark>'
'<name>Untitled Placemark</name>'
'<Point>'
'<coordinates>-95.265,38.959,0</coordinates>'
'</Point>'
'</Placemark>'
'</Document>'
'</kml>'
)
示例7: to_kml
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import name [as 别名]
def to_kml(self, filename):
"""
Export the group to a kml file
"""
if not self.sights:
print('This group does not have sights. Aborting export.')
return
document = KML.Document()
document.append(KML.title(self.name))
if self.description:
document.append(KML.description(self.description))
country_folders = {}
place_folders = {}
for sight in self.sights.all():
if not sight.geoposition:
continue
placemark = KML.Placemark(
KML.name(u'{0.name}'.format(sight)),
KML.description(sight.get_long_description()),
KML.Point(KML.coordinates('{0[0]}, {0[1]}, 0.0'.format(
sight.geoposition.coords,
))),
)
placemark.append(KML.ExtendedData(
KML.Data(
name='gx_media_links',
value=u'{name}.jpg'.format(name=sight.name),
)
))
place_folder_id = sight.thplace.id
country_folder_id = sight.thplace.thcountry.id
country_folder = country_folders.setdefault(
country_folder_id,
KML.Folder(KML.name(sight.thplace.thcountry.name)),
)
place_folder = place_folders.setdefault(
place_folder_id,
KML.Folder(KML.name(sight.thplace.name)),
)
place_folder.append(placemark)
country_folder.append(place_folder)
document.append(country_folder)
file_obj = open(filename, 'w')
file_obj.write(
etree.tostring(
document,
pretty_print=True,
encoding='utf8'))
示例8: finish
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import name [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
示例9: __init__
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import name [as 别名]
def __init__(self, poseTopicName, utmZoneNumber):
rospy.loginfo("[KMLTourGenerator] init()")
self.prevLinVel = 0.0
self.prevAngVel = 0.0
self.hasFinished = False
self.hasOdom = False
self.currOdom = None
self.prevOdom = None
self.subPose = rospy.Subscriber(poseTopicName, Odometry, self.poseHandler)
self.utmZoneNumber = utmZoneNumber
self.utmZoneLetter = 'U'
self.zOffset = 2.0
self.planCoordListStr = ''
self.execCoordListStr = ''
self.totalTime = 0.0
# define a variable for the Google Extensions namespace URL string
self.gxns = '{' + nsmap['gx'] + '}'
# start with a base KML tour and playlist
self.anim_fld = KML.Folder(
KML.name('Animations'),
id='animations',
)
self.path_fld = KML.Folder(
KML.name('Paths'),
id='paths',
)
self.tour_doc = KML.kml(
KML.Document(
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',
),
GX.Tour(
KML.name("Play me!"),
GX.Playlist(),
),
self.anim_fld,
self.path_fld
)
)
示例10: AddPlacemarkAndZone
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import name [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)
示例11: create_kml_placemarks_for_tracks_and_waypoints
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import name [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
示例12: get_csv_doc
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import name [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: build_test_kml
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import name [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")
示例14: debugging
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import name [as 别名]
def debugging(latitude, longitude) :
global initLat, initLon, me, ne, lat, lon, carryY, carryX, fld, filebool, angles
lat=latitude
lon=longitude
#lat=filt(lat, a)
#lon=filt(lon, a)
#print lat, lon
lat_rad = lat *math.pi/180.0
lon_rad = lon *math.pi/180.0
if(filebool == True) :
pm = KML.Placemark(KML.name("Placemark %d" % count), KML.Point(KML.coordinates("%f,%f" % (lat, lon))))
fld.append(pm)
count = count + 1
try :
#print angles[2]
if(initLat == 0) :
br.sendTransform((0, 0, 0), tf.transformations.quaternion_from_euler(0, 0, carryYaw, "sxyz"), rospy.Time.now(), 'base_link', 'dummy')
(trans, rot) = listener.lookupTransform('map', 'base_link', rospy.Time())
angles = tf.transformations.euler_from_quaternion(rot)
initLat = lat_rad
initLon = lon_rad
me = earth_radius*(1-earth_ecc*earth_ecc)/((1-earth_ecc*earth_ecc*math.sin(lat_rad)*math.sin(lat_rad))**1.5)
ne = earth_radius/((1-earth_ecc*earth_ecc*math.sin(lat_rad)*math.sin(lat_rad))**0.5)
br.sendTransform((0, 0, 0), tf.transformations.quaternion_from_euler(0, 0, -(carryYaw + angles[2])), rospy.Time.now(), 'map', 'world')
#br.sendTransform((0, 0, 0), tf.transformations.quaternion_from_euler(0, 0, carryYaw), rospy.Time.now(), 'world', 'map')
else :
carryY=(lon_rad - initLon)*(ne+h)*math.cos(lat_rad)
carryX=(lat_rad - initLat)*(me+h)
print carryYaw
#br.sendTransform((carryX -trans[0], carryY -trans[1], 0), tf.transformations.quaternion_from_euler(0, 0, carryYaw -angles[2], "sxyz"), rospy.Time.now(), 'base_link', 'world')
br.sendTransform((-carryX, -carryY, 0), tf.transformations.quaternion_from_euler(0, 0, carryYaw, "sxyz"), rospy.Time.now(), 'base_link', 'dummy')
except(tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException) :
print "exception"
示例15: create_network_link_element
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import name [as 别名]
def create_network_link_element(name, kml_file, ts_obj):
lats, lons = flatten_lalos(None, ts_obj)
network_link = KML.NetworkLink(
KML.name(name),
KML.visibility(1),
KML.Region(
KML.Lod(
KML.minLodPixels(0),
KML.maxLodPixels(1800)
),
KML.LatLonAltBox(
KML.north(lats[-1] + 0.5),
KML.south(lats[0] - 0.5),
KML.east(lons[-1] + 0.5),
KML.west(lons[0] - 0.5)
)
),
KML.Link(
KML.href(kml_file),
KML.viewRefreshMode('onRegion')
)
)
return network_link