How to use the fastkml.config.etree.SubElement 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 / geometry.py View on Github external
def _set_extrude(self, element):
        if self.extrude and self.altitude_mode in [
            'relativeToGround',
            # 'relativeToSeaFloor',
            'absolute'
        ]:
            et_element = etree.SubElement(element, "%sextrude" % self.ns)
            et_element.text = '1'
github cleder / fastkml / fastkml / geometry.py View on Github external
def _etree_linestring(self, linestring):
        element = etree.Element("%sLineString" % self.ns)
        self._set_extrude(element)
        self._set_altitude_mode(element)
        if self.tessellate and self.altitude_mode in [
            'clampToGround',
            'clampToSeaFloor'
        ]:
            ts_element = etree.SubElement(element, "%stessellate" % self.ns)
            ts_element.text = '1'
        coords = list(linestring.coords)
        element.append(self._etree_coordinates(coords))
        return element
github cleder / fastkml / fastkml / geometry.py View on Github external
def _etree_polygon(self, polygon):
        element = etree.Element("%sPolygon" % self.ns)
        self._set_extrude(element)
        self._set_altitude_mode(element)
        outer_boundary = etree.SubElement(
            element, "%souterBoundaryIs" % self.ns
        )
        outer_boundary.append(self._etree_linearring(polygon.exterior))
        for ib in polygon.interiors:
            inner_boundary = etree.SubElement(
                element, "%sinnerBoundaryIs" % self.ns
            )
            inner_boundary.append(self._etree_linearring(ib))
        return element
github cleder / fastkml / fastkml / atom.py View on Github external
def etree_element(self):
        element = etree.Element(self.ns + self.__name__.lower())
        if self.name:
            name = etree.SubElement(element, "%sname" % self.ns)
            name.text = self.name
        # else:
        #    logger.critical('No Name for person defined')
        #    raise TypeError
        if self.uri:
            # XXX validate uri
            uri = etree.SubElement(element, "%suri" % self.ns)
            uri.text = self.uri
        if self.email:
            if check_email(self.email):
                email = etree.SubElement(element, "%semail" % self.ns)
                email.text = self.email
        return element
github cleder / fastkml / fastkml / styles.py View on Github external
def etree_element(self):
        element = super(BalloonStyle, self).etree_element()
        if self.bgColor is not None:
            elem = etree.SubElement(element, "%sbgColor" % self.ns)
            elem.text = self.bgColor
        if self.textColor is not None:
            elem = etree.SubElement(element, "%stextColor" % self.ns)
            elem.text = self.textColor
        if self.text is not None:
            elem = etree.SubElement(element, "%stext" % self.ns)
            elem.text = self.text
        if self.displayMode is not None:
            elem = etree.SubElement(element, "%sdisplayMode" % self.ns)
            elem.text = self.displayMode
        return element
github cleder / fastkml / fastkml / styles.py View on Github external
def etree_element(self):
        element = super(IconStyle, self).etree_element()
        if self.scale is not None:
            scale = etree.SubElement(element, "%sscale" % self.ns)
            scale.text = str(self.scale)
        if self.heading:
            heading = etree.SubElement(element, "%sheading" % self.ns)
            heading.text = str(self.heading)
        if self.icon_href:
            icon = etree.SubElement(element, "%sIcon" % self.ns)
            href = etree.SubElement(icon, "%shref" % self.ns)
            href.text = self.icon_href
        return element
github cleder / fastkml / fastkml / kml.py View on Github external
altitudeMode = etree.SubElement(
                    element, "%saltitudeMode" % self.ns
                )
                altitudeMode.text = self._altitudeMode
        if all([self._north, self._south, self._east, self._west]):
            latLonBox = etree.SubElement(element, '%slatLonBox' % self.ns)
            north = etree.SubElement(latLonBox, '%snorth' % self.ns)
            north.text = self._north
            south = etree.SubElement(latLonBox, '%ssouth' % self.ns)
            south.text = self._south
            east = etree.SubElement(latLonBox, '%seast' % self.ns)
            east.text = self._east
            west = etree.SubElement(latLonBox, '%swest' % self.ns)
            west.text = self._west
            if self._rotation:
                rotation = etree.SubElement(latLonBox, '%srotation' % self.ns)
                rotation.text = self._rotation

        return element