o
    ó<âg  ã                   @   sx   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ zd dl	Z	W n e
y-   dZ	Y nw dd„ Zd	d
„ Zdd„ ZdS )é    N)ÚBytesIO)Úsettings)ÚHttpResponse)ÚloaderFc                 C   s\   t ƒ }t |dtj¡}| d|  tj¡¡ W d  ƒ n1 s w   Y  | d¡ | 	¡ S )z0Return compressed KMZ from the given KML string.Úazdoc.kmlNr   )
r   ÚzipfileÚZipFileÚZIP_DEFLATEDÚwritestrÚencoder   ÚDEFAULT_CHARSETÚseekÚread)ÚkmlÚkmzÚzf© r   úO/var/www/html/venv/lib/python3.10/site-packages/django/contrib/gis/shortcuts.pyÚcompress_kml   s   ÿ
r   c                  O   s   t tj| i |¤ŽddS )z9Render the response as KML (using the correct MIME type).z$application/vnd.google-earth.kml+xml©Úcontent_type)r   r   Úrender_to_string©ÚargsÚkwargsr   r   r   Úrender_to_kml   s   þr   c                  O   s   t ttj| i |¤ŽƒddS )zW
    Compress the KML content and return as KMZ (using the correct
    MIME type).
    z application/vnd.google-earth.kmzr   )r   r   r   r   r   r   r   r   Úrender_to_kmz    s   þr   )r   Úior   Údjango.confr   Údjango.httpr   Údjango.templater   ÚnumpyÚImportErrorr   r   r   r   r   r   r   Ú<module>   s    ÿ	