Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
)
for ls in lineStrings:
print 'coordinates=[%s ... %s] (%d)' % (ls[0], ls[len(ls)-1], len(ls))
print 'Have latitude %s' % ls[0].split(',')[1]
if float(ls[0].split(',')[1]) > 50:
geo_name = 'AK-CA Boundary'
else:
geo_name = 'CONUS-CA Boundary'
pm = KML.Placemark(
KML.name('%s' % geo_name),
KML.styleUrl('#stl'),
KML.LineString(
KML.extrude(1),
KML.altitudeMode('clampToGround'),
KML.coordinates(' '.join(ls))
)
)
doc.Document.append(pm)
# For debugging: optionally include the paths of the original source data.
#ns = 100
#for ls in coordx:
# print 'x coordinates=[%s ... %s] (%d)' % (ls[0], ls[len(ls)-1], len(ls))
# pm = KML.Placemark(
# KML.name('%d' % ns),
# KML.styleUrl('#stlx'),
# KML.LineString(
# KML.extrude(1),
# KML.altitudeMode('clampToGround'),
# KML.coordinates(' '.join(ls))
coord_str = str(
linestring_doc.getroot().find(".//{http://www.opengis.net/kml/2.2}coordinates")
).strip()
for vertex in coord_str.split(' '):
(lon,lat,alt) = vertex.split(',')
flyto = GX.FlyTo(
GX.duration(2),
GX.flyToMode("smooth"),
KML.Camera(
KML.longitude(lon),
KML.latitude(lat),
KML.altitude(0),
KML.heading(-129.7),
KML.tilt(90.0),
KML.altitudeMode("relativeToGround"),
)
)
tour_doc[gxns+"Tour"].Playlist.append(flyto)
assert Schema('kml22gx.xsd').validate(tour_doc)
print etree.tostring(tour_doc, pretty_print=True)
# output a KML file (named based on the Python script)
outfile = file(__file__.rstrip('.py')+'.kml','w')
outfile.write(etree.tostring(tour_doc, pretty_print=True))
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)])
print 'Exporting multigeometry for %s' % name
pm = KML.Placemark(
KML.name(name),
KML.styleUrl('#stl'),
KML.MultiGeometry(
)
)
for zone in zones[name]:
coords = zone.exterior.coords
exteriorCoords = []
for c in coords:
exteriorCoords.append('%s,%s,0' % (c[0], c[1]))
p = KML.Polygon(
KML.extrude(1),
KML.altitudeMode('clampToGround'),
KML.outerBoundaryIs(
KML.LinearRing(
KML.coordinates(' '.join(exteriorCoords))
)
)
)
pm.MultiGeometry.append(p)
# TODO: make a better shapely->KML transformer and
# call that. Support interiors. For now, this case
# doesn't use them so skip it.
doc.Document.append(pm)
outputFile = open(os.path.join(ntiaDir, 'protection_zones.kml'), 'w+')
outputFile.write(etree.tostring(doc, pretty_print=True))
KML.extrude(True),
KML.altitudeMode('absolute'),
KML.coordinates(
"{},{},{}".format(gps.lon, gps.lat, gps.alt))
),
KML.name(
str(ii)) if ii % 5 == 0 or ii == 1 else KML.name()
)
)
# create the path
doc.Document.append(
KML.Placemark(
KML.styleUrl('#{0}'.format(style_path)),
KML.LineString(
KML.altitudeMode('absolute'),
KML.coordinates(
' '.join(["{},{},{}".format(gps.lon, gps.lat, gps.alt)
for gps 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
# GX.TourControl(GX.playMode("pause"))
# )
# add a placemark for the feature
tour_doc.Document.Folder.append(
KML.Placemark(
KML.name("?"),
KML.description(
"<h1>{name}</h1><br>{desc}".format(
name=feature['name'],
desc=feature['desc'],
)
),
KML.Point(
KML.extrude(1),
KML.altitudeMode("relativeToGround"),
KML.coordinates("{lon},{lat},{alt}".format(
lon=feature['lon'],
lat=feature['lat'],
alt=50,
)
)
),
id=feature['name'].replace(' ','_')
)
)
# show the placemark balloon
tour_doc.Document[gxns+"Tour"].Playlist.append(
GX.AnimatedUpdate(
GX.duration(2.0),
KML.Update(
KML.targetHref(),
def create_flyto_camera(location):
flyto = GX.FlyTo(
GX.duration(0.5),
GX.flyToMode('smooth'),
)
flyto.append(
KML.Camera(
KML.longitude(location['loc'].longitude),
KML.latitude(location['loc'].latitude),
KML.altitude(location['loc'].altitude),
KML.heading(location['loc'].heading),
KML.tilt(location['loc'].tilt),
KML.roll(location['loc'].roll),
KML.altitudeMode('relativeToGround'),
)
)
return flyto