
    \ihH                     z    S r SSKrSSKrSSKrSSKrSSKJrJrJ	r	  SSK
JrJr  SSKJr  SSKJr   " S S\5      rg)	a  
Copyright 2011-2018 Kyle Lancaster | 2019 Patrick Eisoldt

Simplekml is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

    N)Kmlable
KmlElementcheck)Document	Container)u)NetworkLinkControlc                   .  ^  \ rS rSrSrU 4S jrS rS rS r\	S 5       r
\	S 5       r\	S	 5       r\	S
 5       r\	S 5       r\	S 5       r\	S 5       r\	S 5       r\	S 5       r\	S 5       r\	S 5       r\R*                  S 5       r\	S 5       r\R*                  \" \S5      S 5       5       rS.S jrS.S jrS.S jrS.S jrS.S jrS rS rS r S r!S r"S  r#S! r$S" r%S# r&S$ r'S% r(S& r)S' r*S( r+S) r,\	S* 5       r-\-R*                  S+ 5       r-\.S, 5       r/S-r0U =r1$ )/Kml   a  The main class that represents a KML file.

This class represents a KML file, and the compilation of the KML file will
be done through this class. The base feature is a document, all arguments
passed to the class on creation are the same as that of a
:class:`simplekml.Document`. To change any properties after creation you can
do so through the :attr:`simplekml.Kml.document` property
(eg. `kml.document.name = "Test"`). For a description of what the
arguments mean see the KML reference documentation published by Google:
http://code.google.com/apis/kml/documentation/kmlreference.html

Simple Example::

    from simplekml import Kml
    kml = Kml(name='KmlUsage')
    kml.newpoint(name="Kirstenbosch", coords=[(18.432314,-33.988862)])  # A simple Point
    kml.save("KmlClass.kml")  # Saving
    kml.savekmz("KmlClass.kmz", format=False)  # Saving as KMZ
    print(kml.kml())  # Printing out the kml to screen
c                    > [         [        U ]  5         [        S0 UD6U l        S U l        S U l        SU l        SU l        / U l	        / U l
        SS/U l        / U l        g )NTFz&xmlns="http://www.opengis.net/kml/2.2"z,xmlns:gx="http://www.google.com/kml/ext/2.2" )superr   __init__r   _feature_networklinkcontrol_hint
_parsetext
_outputkmz_images_foundimages_namespaces_processedstyles)selfkwargs	__class__s     P/var/www/html/kml_chatgpt/mouzaenv/lib/python3.13/site-packages/simplekml/kml.pyr   Kml.__init__4   sa    c4!# *6*#' 
DFtu "    c                     g)Nz<Root KML object>r   r   s    r   __str__Kml.__str__@   s    "r   c                 8    SR                  U R                  5      $ )z"Return the namespaces as a string. )joinr   r!   s    r   _getnamespacesKml._getnamespacesC   s    xx(())r   c                     U R                   R                  U5        [        R                  R	                  S[        R                  R                  U5      S   5      R                  SS5      $ )a  Adds an file to a KMZ and returns the path contained inside of the KMZ (files/...)

This is useful for including images in a KMZ that are referenced from description balloons, as these files
are not automatically included in a KMZ.

Usage::

    import simplekml
    kml = simplekml.Kml()
    path = kml.addfile("a/path/to/somefile.file")
    pnt = pnt.newpoint()
    pnt.description = '<img src="' + path +'" alt="picture" width="400" height="300" align="left" />'

*New in version 1.2.0*
files   \/)r   appendospathr&   splitreplace)r   r0   s     r   addfileKml.addfileG   sJ      	D!ww||GRWW]]4%8%;<DDT3OOr   c                 .    U R                   R                  $ )zUReturns a list of all the features that have been attached to the top level document.)documentfeaturesr!   s    r   r7   Kml.featuresZ   s     }}%%%r   c                 .    U R                   R                  $ )zReturns a list of all the features that have been attached to the top level document, and all sub features.

*New in version 1.1.0*
)r6   allfeaturesr!   s    r   r:   Kml.allfeatures_   s     }}(((r   c                 .    U R                   R                  $ )zpReturns a list of all the geometries that have been attached to the top level document.

*New in version 1.1.0*
)r6   
geometriesr!   s    r   r=   Kml.geometriesg        }}'''r   c                 .    U R                   R                  $ )zReturns a list of all the geometries that have been attached to the top level document, and all sub geometries.

*New in version 1.1.0*
)r6   allgeometriesr!   s    r   rA   Kml.allgeometrieso        }}***r   c                 .    U R                   R                  $ )zsReturns a list of all the containers that have been attached to to the top level document.

*New in version 1.1.0*
)r6   
containersr!   s    r   rE   Kml.containersw   r?   r   c                 .    U R                   R                  $ )zReturns a list of all the containers that have been attached to the top level document, and all sub containers.

*New in version 1.1.0*
)r6   allcontainersr!   s    r   rH   Kml.allcontainers   rC   r   c                 .    U R                   R                  $ )zlReturns a list of all the styles that have been attached to the top level document.

*New in version 1.1.0*
)r6   stylesr!   s    r   rK   
Kml.styles   s     }}###r   c                 .    U R                   R                  $ )zReturns a list of all the styles that have been attached to the top level document, and all sub styles.

*New in version 1.1.0*
)r6   	allstylesr!   s    r   rN   Kml.allstyles        }}&&&r   c                 .    U R                   R                  $ )zoReturns a list of all the stylemaps that have been attached to the top level document.

*New in version 1.1.0*
)r6   	stylemapsr!   s    r   rR   Kml.stylemaps   rP   r   c                 .    U R                   R                  $ )zReturns a list of all the stylemaps that have been attached to the top level document, and all sub stylemaps.

*New in version 1.1.0*
)r6   allstylemapsr!   s    r   rU   Kml.allstylemaps   s     }})))r   c                     U R                   $ )a  Assign a hint attribute to the KML tag.

Possible values to use are:
  * target=moon
  * target=sky
  * target=mars

Usage::

    from simplekml import Kml
    kml = Kml()
    kml.hint = 'target=moon'
    print(kml.kml())

Result:

.. code-block:: xml

    <?xml version="1.0" encoding="UTF-8"?>
    <kml hint="target=moon" xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
        <Document id="feat_1"/>
    </kml>

*New in version 1.1.0*
r   r!   s    r   hintKml.hint   s    6 zzr   c                     Xl         g NrX   )r   rY   s     r   rY   rZ      s    
r   c                 R    U R                   c  [        5       U l         U R                   $ )a  
The top level item in the kml document.

0 or 1 top level document is required for a kml document, the default is an
instance of :class:`simplekml.Document`. This property can be set to an
instance of :class:`simplekml.Document` or :class:`simplekml.Folder` or to
remove it completely set it to None

Example::

    import simplekml
    kml = simplekml.Kml()
    kml.document = simplekml.Folder(name = "Top Level Folder")
    kml.save('Document Replacement.kml')
)r   r   r!   s    r   r6   Kml.document   s!    " == $JDM}}r   Tc                     Xl         g r\   )r   )r   docs     r   r6   r^      s	     r   c                    S[         l        / U l        SnU R                  b  U R                  R	                  5       nSnU R
                  b  U R
                  R	                  5       nU R                  b  SR                  U R                  5      nOSn[        S5      R                  U R                  5       X$U5      nU(       a  [        R                  " 5         [        R                  R                  R                  UR!                  S5      5      n[        R"                  " 5         S[         l        UR%                  SSS	S
9R'                  S5      $ S[         l        U$ )z@Returns the kml as a string or "prettyprinted" if format = True.T z hint="{0}"z<kml {0}{2}>{1}{3}</kml>utf-8Fz    
zUTF-8)indentnewlencoding)r   
_compilingr   r   r"   r   r   formatr   r'   r   patchxmldomminidomparseStringencodeunpatchtoprettyxmldecode)r   ri   kml_strnetworklinkcontrol_strrY   xml_strs         r   _genkmlKml._genkml   s   ! "==$mm++-G!###/%)%=%=%E%E%G"::! ''

3DD./66t7J7J7Lg]stWW__001HI7 %7%%V$%QXXY`aa!&GNr   c                     Xl         g)a"  Sets the behavior of how text tags are parsed.

If True the values of the text tags (<name>, <description> and <text>)
are escaped, so that the values are rendered properly. If False, the
values are left as is. In both cases the CDATA element is left unchanged.

*Changed in version 1.1.0*
N)r   )r   parses     r   	parsetextKml.parsetext   s	      r   c                 H    U [         l        SU l        U R                  U5      $ )a  Returns the kml as a string or "prettyprinted" if `format = True`.

.. note::
    Setting `format = False` will produce smaller files, as well as
    decrease the memory required while processing the kml.

PrettyPrinted Example (default)::

    import simplekml
    kml = simplekml.Kml()
    pnt = kml.newpoint(name='A Point')
    pnt.coords = [(1.0, 2.0)]
    print(kml.kml())

PrettyPrinted Result:

.. code-block:: xml

    <?xml version="1.0" encoding="UTF-8"?>
    <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
        <Document id="feat_1">
            <Placemark id="feat_2">
                <name>A Point</name>
                <Point id="geom_0">
                    <coordinates>1.0,2.0,0.0</coordinates>
                </Point>
            </Placemark>
        </Document>
    </kml>

Single Line Example::

    import simplekml
    kml = simplekml.Kml()
    pnt = kml.newpoint(name='A Point')
    pnt.coords = [(1.0, 2.0)]
    print(kml.kml(False))

Single Line Result:

.. code-block:: xml

    <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"><Document id="feat_1"><Placemark id="feat_2"><name>A Point</name><Point id="geom_0"><coordinates>1.0,2.0,0.0</coordinates></Point></Placemark></Document></kml>

F)r   _currentrootr   rv   )r   ri   s     r   kmlKml.kml  s#    \  $||F##r   c                     U [         l        SU l        U R                  U5      n[        R
                  " USS5      n UR                  U5        UR                  5         g! UR                  5         f = f)a  Save the kml to the given file supplied by `path`.

The KML is saved to a file in one long string if `format=False` else it
gets saved "prettyprinted" (as formatted xml). This works the same as :func:`simplekml.Kml.kml`

.. note::
    Setting `format = False` will produce smaller files, as well as
    decrease the memory required while processing the kml.

Usage::

    import simplekml
    kml = simplekml.Kml()
    kml.save("Saving.kml")
    #kml.save("Saving.kml", False)  # or this
Fwbrc   N)r   r}   r   rv   codecsopenwriteclose)r   r0   ri   outfs        r   saveKml.save8  sV    "  $ll6"KKdG,	GGCLGGIAGGIs   A A1c           
         U [         l        SU l        U R                  U5      R	                  S5      n[
        R                  " US[
        R                  5      nUR                  SU5        U R                   HS  nUR                  U[        R                  R                  S[        R                  R                  U5      S   5      5        MU     U R                   HS  nUR                  U[        R                  R                  S[        R                  R                  U5      S   5      5        MU     UR!                  5         g)aX  Save the kml as a kmz to the given file supplied by `path`.

The KML is saved to a file in a long string if `format=False` else it
gets saved "prettyprinted". This works the same as :func:`simplekml.Kml.kml`

Usage::

    import simplekml
    kml = simplekml.Kml()
    kml.savekmz("Saving.kml")
    #kml.savekmz("Saving.kml", False)  # or this
Trc   wzdoc.kmlr*   r+   N)r   r}   r   rv   ro   zipfileZipFileZIP_DEFLATEDwritestrr   r   r/   r0   r&   r1   r   r   )r   r0   ri   r   kmzimages         r   savekmzKml.savekmzR  s      $ll6"))'2oodC)=)=>Y$\\EIIeRWW\\'277==3G3JKL "&&EIIeRWW\\'277==3G3JKL '		r   c                 :    U R                   R                  " S0 UD6$ )z
Creates a new :class:`simplekml.Document`.

The document is attached to this KML document. The arguments are the same as for :class:`simplekml.Document`.
See :class:`simplekml.Document` for usage.
r   )r6   newdocumentr   r   s     r   r   Kml.newdocumentj  s     }}((2622r   c                 :    U R                   R                  " S0 UD6$ )z
Creates a new :class:`simplekml.Folder`.

The folder is attached to this KML document. The arguments are the same as those for :class:`simplekml.Folder`
See :class:`simplekml.Folder` for usage.
r   )r6   	newfolderr   s     r   r   Kml.newfolders       }}&&000r   c                 :    U R                   R                  " S0 UD6$ )z
Creates a new :class:`simplekml.Point`.

The point is attached to this KML document. The arguments are the same as those for :class:`simplekml.Point`
See :class:`simplekml.Point` for usage.
r   )r6   newpointr   s     r   r   Kml.newpoint|       }}%%///r   c                 :    U R                   R                  " S0 UD6$ )z
Creates a new :class:`simplekml.LineString`.

The linestring is attached to this KML document. The arguments are the same as for :class:`simplekml.LineString`
See :class:`simplekml.LineString` for usage.
r   )r6   newlinestringr   s     r   r   Kml.newlinestring  s     }}**4V44r   c                 :    U R                   R                  " S0 UD6$ )z
Creates a new :class:`simplekml.Polygon`.

The polygon is attached to this KML document. The arguments are the same as those for :class:`simplekml.Polygon`
See :class:`simplekml.Polygon` for usage.
r   )r6   
newpolygonr   s     r   r   Kml.newpolygon       }}''1&11r   c                 :    U R                   R                  " S0 UD6$ )z
Creates a new :class:`simplekml.MultiGeometry`.

The multigeometry is attached to this KML document. The arguments are the same as
for :class:`simplekml.MultiGeometry`. See :class:`simplekml.MultiGeometry` for usage.
r   )r6   newmultigeometryr   s     r   r   Kml.newmultigeometry       }}--777r   c                 :    U R                   R                  " S0 UD6$ )z
Creates a new :class:`simplekml.GroundOverlay`.

The groundoverlay is attached to this KML document. The arguments are the same as those
for :class:`simplekml.GroundOverlay`. See :class:`simplekml.GroundOverlay` for usage.
r   )r6   newgroundoverlayr   s     r   r   Kml.newgroundoverlay  r   r   c                 :    U R                   R                  " S0 UD6$ )z
Creates a new :class:`simplekml.ScreenOverlay`.

The screenoverlay is attached to this KML document. The arguments are the same as those
for :class:`simplekml.ScreenOverlay`. See :class:`simplekml.ScreenOverlay` for usage.
r   )r6   newscreenoverlayr   s     r   r   Kml.newscreenoverlay  r   r   c                 :    U R                   R                  " S0 UD6$ )z
Creates a new :class:`simplekml.PhotoOverlay`.

The photooverlay is attached to this KML document. The arguments are the same as those
for :class:`simplekml.PhotoOverlay`. See :class:`simplekml.PhotoOverlay` for usage.
r   )r6   newphotooverlayr   s     r   r   Kml.newphotooverlay       }},,6v66r   c                 :    U R                   R                  " S0 UD6$ )z
Creates a new :class:`simplekml.NetworkLink`.

The networklink is attached to this KML document. The arguments are the same as those
for :class:`simplekml.NetworkLink`. See :class:`simplekml.NetworkLink` for usage.
r   )r6   newnetworklinkr   s     r   r   Kml.newnetworklink  s     }}++5f55r   c                 :    U R                   R                  " S0 UD6$ )z
Creates a new :class:`simplekml.Model`.

The model is attached to this KML document. The arguments are the
same as those for :class:`simplekml.Model`
r   )r6   newmodelr   s     r   r   Kml.newmodel  r   r   c                 :    U R                   R                  " S0 UD6$ )z
Creates a new :class:`simplekml.Schema`.

The schem is attached to this KML document. The arguments are the
same as those for :class:`simplekml.Schema`
r   )r6   	newschemar   s     r   r   Kml.newschema  r   r   c                 :    U R                   R                  " S0 UD6$ )z
Creates a new :class:`simplekml.GxTrack`.

The gxtrack is attached to this KML document. The arguments are the same as those for :class:`simplekml.GxTrack`
See :class:`simplekml.GxTrack` for usage.
r   )r6   
newgxtrackr   s     r   r   Kml.newgxtrack  r   r   c                 :    U R                   R                  " S0 UD6$ )z
Creates a new :class:`simplekml.GxMultiTrack`.

The gxmultitrack is attached to this KML document. The arguments are the same as those
for :class:`simplekml.GxMultiTrack`. See :class:`simplekml.GxMultiTrack` for usage.
r   )r6   newgxmultitrackr   s     r   r   Kml.newgxmultitrack  r   r   c                 :    U R                   R                  " S0 UD6$ )z
Creates a new :class:`simplekml.GxTour`.

The tour is attached to this KML document. The arguments are the same as those for :class:`simplekml.GxTour`
See :class:`simplekml.GxTour` for usage.
r   )r6   	newgxtourr   s     r   r   Kml.newgxtour  r   r   c                 R    U R                   c  [        5       U l         U R                   $ )zAccesses/Creates the :class:`simplekml.NetworkLinkControl`.

See :class:`simplekml.NetworkLinkControl` for usage example.

*New in version 1.1.1*
)r   r	   r!   s    r   networklinkcontrolKml.networklinkcontrol  s'     ##+'9';D$'''r   c                     Xl         g r\   )r   )r   r   s     r   r   r     s    #5 r   c                      S[         l        g)zHResets the id counter so that ids count from 0.

*New in version 1.3.1*
r   N)r   	_globalidr   r   r   resetidcounterKml.resetidcounter  s     r   )	r   r   r   r   r   r   r   r   r   )T)2__name__
__module____qualname____firstlineno____doc__r   r"   r'   r3   propertyr7   r:   r=   rA   rE   rH   rK   rN   rR   rU   rY   setterr6   r   r   rv   rz   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   staticmethodr   __static_attributes____classcell__)r   s   @r   r   r      s   *
##*P& & & ) ) ( ( + + ( ( + + $ $ ' ' ' ' * *  8 
[[   ( __
9d  2	 0$d40310528887601271 	( 	( 6 6  r   r   )r   xml.dom.minidomrk   r   r   r/   simplekml.baser   r   r   simplekml.featgeomr   r   simplekml.makeunicoder   simplekml.networklinkcontrolr	   r   r   r   r   <module>r      s5   $    	 5 5 2 # ;i' ir   