Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
highlight
#highlightState
"""
k = kml.KML()
k.from_string(doc)
self.assertEqual(len(list(k.features())), 1)
self.assertTrue(
isinstance(list(list(k.features())[0].styles())[0], styles.StyleMap)
)
sm = list(list(list(k.features())[0].styles()))[0]
self.assertTrue(isinstance(sm.normal, styles.StyleUrl))
self.assertEqual(sm.normal.url, '#normalState')
self.assertTrue(isinstance(sm.highlight, styles.StyleUrl))
self.assertEqual(sm.highlight.url, '#highlightState')
k2 = kml.KML()
k2.from_string(k.to_string())
self.assertEqual(k.to_string(), k2.to_string())
normal
#normalState
highlight
#highlightState
"""
k = kml.KML()
k.from_string(doc)
self.assertEqual(len(list(k.features())), 1)
self.assertTrue(
isinstance(list(list(k.features())[0].styles())[0], styles.StyleMap)
)
sm = list(list(list(k.features())[0].styles()))[0]
self.assertTrue(isinstance(sm.normal, styles.StyleUrl))
self.assertEqual(sm.normal.url, '#normalState')
self.assertTrue(isinstance(sm.highlight, styles.StyleUrl))
self.assertEqual(sm.highlight.url, '#highlightState')
k2 = kml.KML()
k2.from_string(k.to_string())
self.assertEqual(k.to_string(), k2.to_string())
# Flight path array is in lat,lon,alt order, needs to be in lon,lat,alt
track_points.append([_point[2],_point[1],_point[3]])
_flight_geom = LineString(track_points)
# Define the Line and Polygon styles, which are used for the flight path, and the extrusions (if enabled)
flight_track_line_style = fastkml.styles.LineStyle(
ns=ns,
color=track_color,
width=track_width)
flight_extrusion_style = fastkml.styles.PolyStyle(
ns=ns,
color=poly_color)
flight_track_style = fastkml.styles.Style(
ns=ns,
styles=[flight_track_line_style, flight_extrusion_style])
# Generate the Placemark which will contain the track data.
flight_line = fastkml.kml.Placemark(
ns=ns,
id=placemark_id,
name=name,
styles=[flight_track_style])
# Add the track data to the Placemark
flight_line.geometry = fastkml.geometry.Geometry(
ns=ns,
geometry=_flight_geom,
altitude_mode=_alt_mode,
extrude=extrude,
def new_placemark(lat, lon, alt,
placemark_id="Placemark ID",
name="Placemark Name",
absolute = False,
icon = "http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png",
scale = 1.0):
""" Generate a generic placemark object """
if absolute:
_alt_mode = 'absolute'
else:
_alt_mode = 'clampToGround'
flight_icon_style = fastkml.styles.IconStyle(
ns=ns,
icon_href=icon,
scale=scale)
flight_style = fastkml.styles.Style(
ns=ns,
styles=[flight_icon_style])
flight_placemark = fastkml.kml.Placemark(
ns=ns,
id=placemark_id,
name=name,
description="",
styles=[flight_style])
flight_placemark.geometry = fastkml.geometry.Geometry(