Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
KML.styleUrl('#{0}'.format(style_dot)),
KML.Point(
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()
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(
KML.PolyStyle(
KML.color('00006666')
),
id="stly"
),
)
)
num = 1
for ls in lineStrings:
print 'Have final poly len=%d' % len(ls)
geo_name = '%d' % num
num += 1
pm = KML.Placemark(
KML.name('%s' % geo_name),
KML.styleUrl('#stl'),
KML.Polygon(
KML.extrude(1),
KML.altitudeMode('clampToGround'),
KML.outerBoundaryIs(
KML.LinearRing(
KML.coordinates(' '.join(ls))
)
)
)
)
doc.Document.append(pm)
# For debugging: optionally include the paths of the original source data.
#ns = 10000
#for ls in coordx:
# # print 'x coordinates=[%s ... %s] (%d)' % (ls[0], ls[len(ls)-1], len(ls))
)
),
id='star'
),
)
for network in list_of_networks:
network_folder = KML.Folder(KML.name(
"Network Code: " + str(network.code) +
" reportnum: " + network.reportnum))
for shot_line in network.shot_lines:
folder = KML.Folder(
KML.name("ShotLine " + str(shot_line.name[-3:])))
for shot in shot_line.shots:
place_marker = (KML.Placemark(
KML.styleUrl("#star"),
KML.name(network.code + '.' + str(shot.shot_id)),
KML.description('Shot size: ' +
str(shot.mag) +
' ' +
shot.mag_units +
'\n Shot Time: ' +
shot.start_time +
'\n\n' +
shot.description),
KML.Point(
KML.coordinates(
str(shot.lon) + ',' + str(shot.lat) + ',' +
str(shot.elev))
)
))
folder.append(place_marker)
figname = gauge_pngfile[gaugeno,figno]
elev = 0
coords = "%10.4f %10.4f %10.4f" % (longitude,y1,elev)
# Text for 'Places' panel
snippet = "t1 = %g, t2 = %g\n" % (t1,t2) + \
"x1 = %g, y1 = %g\n" % (x1,y1)
snippet_str = "<b>%s</b>]]>" % snippet
# ExtendedData is used in BalloonStyle.text() fields.
placemark = KML.Placemark(
KML.name("%s %d" % (plotfigure.kml_gauge_name,gaugeno)),
KML.Snippet(snippet_str),
KML.styleUrl(chr(35) + "gauge_style"),
KML.ExtendedData(
KML.Data(KML.value(figname),name="pngfile"),
KML.Data(KML.value("%g" % t1),name="t1"),
KML.Data(KML.value("%g" % t2),name="t2"),
KML.Data(KML.value("%g" % x1),name="x1"),
KML.Data(KML.value("%g" % y1),name="y1")),
KML.Point(
KML.coordinates(coords)))
doc_gauges.Document.append(placemark)
kml_file = open(gauge_kml_file,'wt')
kml_file.write('\n')
kml_text = etree.tostring(etree.ElementTree(doc_gauges),
pretty_print=True).decode()
KML.Document(
KML.name('Climate Simulation Output'),
KML.open(1),
KML.description(description),
KML.snippet(
'<i>Click for metadata!</i>',
maxLines="2",
),
KML.StyleMap(
KML.Pair(
KML.key('normal'),
KML.styleUrl('#style-normal'),
),
KML.Pair(
KML.key('highlight'),
KML.styleUrl('#style-highlight'),
),
id="smap",
),
KML.Style(
KML.LineStyle(
KML.color('ff0000ff'),
KML.width('2'),
),
KML.PolyStyle(
KML.color('400000ff'),
),
id="style-normal",
),
KML.Style(
KML.LineStyle(
KML.color('ff00ff00'),
url_json=url.replace('.kml', '.geojson'),
)
doc = KML.kml(
KML.Document(
KML.name('Climate Simulation Output'),
KML.open(1),
KML.description(description),
KML.snippet(
'<i>Click for metadata!</i>',
maxLines="2",
),
KML.StyleMap(
KML.Pair(
KML.key('normal'),
KML.styleUrl('#style-normal'),
),
KML.Pair(
KML.key('highlight'),
KML.styleUrl('#style-highlight'),
),
id="smap",
),
KML.Style(
KML.LineStyle(
KML.color('ff0000ff'),
KML.width('2'),
),
KML.PolyStyle(
KML.color('400000ff'),
),
id="style-normal",
# TODO: sort values by time to speed loading
values = ['{0},{1}'.format(datetime.strftime(val.time, "%Y-%m-%d %H:%M:%S"),val.value) for val in geom.values]
pm = KML.Placemark(
KML.name('Geometry'),
KML.ExtendedData(
KML.Data(
KML.value('"Date,{param}\\n{data}"'.format(
param=meta.variable.name,
data='\\n'.join(values))
),
name="csv_data",
),
),
KML.description(''),
KML.styleUrl('#smap'),
KML.MultiGeometry(*multigeom_args),
)
geom_fld.append(pm)
doc.Document.append(geom_fld)
# for time in s.query(db.Time).all():
# # create a folder for the time
# timefld = KML.Folder(
## KML.Style(
## KML.ListStyle(
## KML.listItemType('checkHideChildren'),
## KML.bgColor('00ffffff'),
## KML.maxSnippetLines('2'),
## ),
## ),
# KML.name(time.as_xml_date()),