How to use the fastkml.styles.LineStyle function in fastkml

To help you get started, we’ve selected a few fastkml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cleder / fastkml / fastkml / test_main.py View on Github external
"""
        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.Style))
        self.assertEqual(len(list(sm.normal.styles())), 1)
        self.assertTrue(isinstance(list(sm.normal.styles())[0], styles.LabelStyle))
        self.assertTrue(isinstance(sm.highlight, styles.Style))
        self.assertTrue(isinstance(sm.highlight, styles.Style))
        self.assertEqual(len(list(sm.highlight.styles())), 2)
        self.assertTrue(isinstance(list(sm.highlight.styles())[0], styles.LineStyle))
        self.assertTrue(isinstance(list(sm.highlight.styles())[1], styles.PolyStyle))
        k2 = kml.KML()
        k2.from_string(k.to_string())
        self.assertEqual(k.to_string(), k2.to_string())
github cleder / fastkml / fastkml / test_main.py View on Github external
def test_style(self):
        lstyle = styles.LineStyle(color='red', width=2.0)
        style = styles.Style(styles=[lstyle])
        f = kml.Document(styles=[style])
        f2 = kml.Document()
        f2.from_string(f.to_string(prettyprint=True))
        self.assertEqual(f.to_string(), f2.to_string())
github projecthorus / radiosonde_auto_rx / auto_rx / utils / log_to_kml.py View on Github external
# Handle selection of absolute altitude mode
    if absolute:
        _alt_mode = 'absolute'
    else:
        _alt_mode = 'clampToGround'

    # Convert the flight path array [time, lat, lon, alt, comment] into a LineString object.
    track_points = []
    for _point in flight_path:
        # 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,
github cleder / fastkml / fastkml / styles.py View on Github external
def from_element(self, element):
        super(Style, self).from_element(element)
        style = element.find('%sIconStyle' % self.ns)
        if style is not None:
            thestyle = IconStyle(self.ns)
            thestyle.from_element(style)
            self.append_style(thestyle)
        style = element.find('%sLineStyle' % self.ns)
        if style is not None:
            thestyle = LineStyle(self.ns)
            thestyle.from_element(style)
            self.append_style(thestyle)
        style = element.find('%sPolyStyle' % self.ns)
        if style is not None:
            thestyle = PolyStyle(self.ns)
            thestyle.from_element(style)
            self.append_style(thestyle)
        style = element.find('%sLabelStyle' % self.ns)
        if style is not None:
            thestyle = LabelStyle(self.ns)
            thestyle.from_element(style)
            self.append_style(thestyle)
        style = element.find('%sBalloonStyle' % self.ns)
        if style is not None:
            thestyle = BalloonStyle(self.ns)
            thestyle.from_element(style)
github cleder / fastkml / fastkml / styles.py View on Github external
def from_element(self, element):
        super(LineStyle, self).from_element(element)
        width = element.find('%swidth' % self.ns)
        if width is not None:
            self.width = float(width.text)