o
    þÞh1	  ã                   @   s‚   d dl mZ d dlmZ d dlmZmZ d dlmZm	Z	 d dl
mZ d dlmZmZ d dlmZ dd	efd
d„Zdefdd„ZdS )é    )Úapps)ÚGeometryField)ÚAsKMLÚ	Transform)Úrender_to_kmlÚrender_to_kmz)ÚFieldDoesNotExist)ÚDEFAULT_DB_ALIASÚconnections)ÚHttp404NFc                 C   s"  g }zt  ||¡}W n ty   td||f ƒ‚w |r7z|j |¡}t|tƒs*t‚W n ty6   tdƒ‚w t	| }	|	j
jrL|j |¡jt|ƒd�}n7g }|	j
jrj|j |¡jd
i d| t|dƒi¤Ž}
|d7 }n|j |¡ ¡ }
|
D ]}t||ƒj|_| |¡ qt|rˆt}nt}|dd|iƒS )z‰
    This view generates KML for the given app label, model, and field name.

    The field name must be that of a geographic field.
    z?You must supply a valid app label and module name.  Got "%s.%s"zInvalid geometry field.©Úkmlz%s_4326iæ  Ú_4326zgis/kml/placemarks.kmlÚplacesN© )r   Ú	get_modelÚLookupErrorr   Ú_metaÚ	get_fieldÚ
isinstancer   r   r
   ÚfeaturesÚhas_AsKML_functionÚ_default_managerÚusingÚannotater   Úhas_Transform_functionr   ÚallÚgetattrr   Úappendr   r   )ÚrequestÚlabelÚmodelÚ
field_nameÚcompressr   Ú
placemarksÚklassÚfieldÚ
connectionÚqsÚmodÚrenderr   r   úa/var/www/html/premium_crap/venv/lib/python3.10/site-packages/django/contrib/gis/sitemaps/views.pyr   
   sH   ÿÿÿ
ÿÿÿ
r   c                 C   s   t | |||d|d�S )zD
    Return KMZ for the given app label, model, and field name.
    T)r#   r   r   )r   r    r!   r"   r   r   r   r+   Úkmz=   s   r,   )Údjango.appsr   Údjango.contrib.gis.db.modelsr   Ú&django.contrib.gis.db.models.functionsr   r   Údjango.contrib.gis.shortcutsr   r   Údjango.core.exceptionsr   Ú	django.dbr	   r
   Údjango.httpr   r   r,   r   r   r   r+   Ú<module>   s    3