Example #1
0
 def _genkml(self, format=True):
     """Returns the kml as a string or "prettyprinted" if format = True."""
     Kmlable._compiling = True
     self._processedstyles = []
     kml_str = ""
     if self._feature is not None:
         kml_str = self._feature.__str__()
     networklinkcontrol_str = ""
     if self._networklinkcontrol is not None:
         networklinkcontrol_str = self._networklinkcontrol.__str__()
     if self._hint is not None:
         hint = ' hint="{0}"'.format(self._hint)
     else:
         hint = ''
     xml_str = u("<kml {0}{2}>{1}{3}</kml>").format(self._getnamespaces(),
                                                    kml_str, hint,
                                                    networklinkcontrol_str)
     if format:
         KmlElement.patch()
         kml_str = xml.dom.minidom.parseString(xml_str.encode("utf-8"))
         KmlElement.unpatch()
         Kmlable._compiling = False
         return kml_str.toprettyxml(indent="    ",
                                    newl="\n",
                                    encoding="UTF-8").decode("utf-8")
     else:
         Kmlable._compiling = False
         return xml_str
Example #2
0
 def _genkml(self, format=True):
     """Returns the kml as a string or "prettyprinted" if format = True."""
     kml_str = self._feature.__str__()
     xml_str = u("<kml {0}>{1}</kml>").format(Kmlable._getnamespaces(), kml_str)
     if format:
        KmlElement.patch()
        kml_str = xml.dom.minidom.parseString(xml_str.encode("utf-8"))
        KmlElement.unpatch()
        return kml_str.toprettyxml(indent="    ", newl="\n", encoding="UTF-8").decode("utf-8")
     else:
         return xml_str
Example #3
0
 def _genkml(self, format=True):
     """Returns the kml as a string or "prettyprinted" if format = True."""
     kml_str = self._feature.__str__()
     xml_str = u("<kml {0}>{1}</kml>").format(Kmlable._getnamespaces(), kml_str)
     if format:
        KmlElement.patch()
        kml_str = xml.dom.minidom.parseString(xml_str.encode("utf-8"))
        KmlElement.unpatch()
        return kml_str.toprettyxml(indent="    ", newl="\n", encoding="UTF-8").decode("utf-8")
     else:
         return xml_str
    def _genkml(self, format=True):
        """
        Returns the kml as a string or as a single line or formatted.

        Keyword arguments:
        format (bool) -- format the resulting kml "prettyprint" (default True)

        """
        kml_tag = 'xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"'
        xmlstr = u"<kml {0}>{1}</kml>".format(kml_tag, self._feature.__str__())
        if format:
           KmlElement.patch()
           kmlstr = xml.dom.minidom.parseString(xmlstr.encode("utf-8"))
           KmlElement.unpatch()
           return kmlstr.toprettyxml(indent="    ", newl="\n", encoding="UTF-8").decode("utf-8")
        else:
            return xmlstr
Example #5
0
    def _genkml(self, format=True):
        """
        Returns the kml as a string or as a single line or formatted.

        Keyword arguments:
        format (bool) -- format the resulting kml "prettyprint" (default True)

        """
        kml_tag = 'xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"'
        xmlstr = u"<kml {0}>{1}</kml>".format(kml_tag, self._feature.__str__())
        if format:
            KmlElement.patch()
            kmlstr = xml.dom.minidom.parseString(xmlstr.encode("utf-8"))
            KmlElement.unpatch()
            return kmlstr.toprettyxml(indent="    ",
                                      newl="\n",
                                      encoding="UTF-8").decode("utf-8")
        else:
            return xmlstr
Example #6
0
 def _genkml(self, format=True):
     """Returns the kml as a string or "prettyprinted" if format = True."""
     kml_str = ""
     if self._feature is not None:
         kml_str = self._feature.__str__()
     networklinkcontrol_str = ""
     if self._networklinkcontrol is not None:
         networklinkcontrol_str = self._networklinkcontrol.__str__()
     if self._hint is not None:
         hint = ' hint="{0}"'.format(self._hint)
     else:
         hint = ''
     xml_str = u("<kml {0}{2}>{1}{3}</kml>").format(Kmlable._getnamespaces(), kml_str, hint, networklinkcontrol_str)
     if format:
        KmlElement.patch()
        kml_str = xml.dom.minidom.parseString(xml_str.encode("utf-8"))
        KmlElement.unpatch()
        return kml_str.toprettyxml(indent="    ", newl="\n", encoding="UTF-8").decode("utf-8")
     else:
         return xml_str