o
    þÞh’  ã                   @   s,   d dl mZ d dlmZmZ 	ddd„ZdS )é    )ÚSpatialReference)ÚDEFAULT_DB_ALIASÚconnectionsÚEPSGNc           	      C   s  |pt }t| }t|jdƒstdƒ‚|jjstdƒ‚|j ¡ }t| t	ƒs(t	| ƒ} | j
du r1tdƒ‚| j
||p8| j
| jdœ}dd„ |j ¡ D ƒ}d	|v rP| j|d	< d
|v r[|pX| j|d
< z|j |¡j| j
d� W dS  |jy€   |j |¡jdi |¤Ž Y dS w )a  
    Take a GDAL SpatialReference system and add its information to the
    `spatial_ref_sys` table of the spatial backend. Doing this enables
    database-level spatial transformations for the backend.  Thus, this utility
    is useful for adding spatial reference systems not included by default with
    the backend:

    >>> from django.contrib.gis.utils import add_srs_entry
    >>> add_srs_entry(3857)

    Keyword Arguments:
     auth_name:
       This keyword may be customized with the value of the `auth_name` field.
       Defaults to 'EPSG'.

     auth_srid:
       This keyword may be customized with the value of the `auth_srid` field.
       Defaults to the SRID determined by GDAL.

     ref_sys_name:
       For SpatiaLite users only, sets the value of the `ref_sys_name` field.
       Defaults to the name determined by GDAL.

     database:
      The name of the database connection to use; the default is the value
      of `django.db.DEFAULT_DB_ALIAS` (at the time of this writing, its value
      is 'default').
    Úspatial_versionz=The `add_srs_entry` utility only works with spatial backends.z4This utility does not support your database backend.NzMSpatial reference requires an SRID to be compatible with the spatial backend.)ÚsridÚ	auth_nameÚ	auth_sridÚ	proj4textc                 S   s   h | ]}|j ’qS © )Úname)Ú.0Úfr   r   ú\/var/www/html/premium_crap/venv/lib/python3.10/site-packages/django/contrib/gis/utils/srs.pyÚ	<setcomp>A   s    z add_srs_entry.<locals>.<setcomp>ÚsrtextÚref_sys_name)r   r   )r   r   ÚhasattrÚopsÚ	ExceptionÚfeaturesÚsupports_add_srs_entryÚspatial_ref_sysÚ
isinstancer   r   Úproj4Ú_metaÚ
get_fieldsÚwktr   ÚobjectsÚusingÚgetÚDoesNotExistÚcreate)	Úsrsr   r	   r   ÚdatabaseÚ
connectionÚSpatialRefSysÚkwargsÚsrs_field_namesr   r   r   Úadd_srs_entry   s8   


ÿü
ÿr)   )r   NNN)Údjango.contrib.gis.gdalr   Ú	django.dbr   r   r)   r   r   r   r   Ú<module>   s    ÿ