ó
i4Vdc           @   sE   d  d l  m Z d  d l m Z m Z d d d d d  Z e Z d S(   iĸĸĸĸ(   t   SpatialReference(   t   DEFAULT_DB_ALIASt   connectionst   EPSGc   	      C   s  | s t  } n  t | } t | j d  s: t d   n  | j j sU t d   n  | j j   } t |  t	  s t	 |   }  n  |  j
 d k r  t d   n  i |  j
 d 6| d 6| pĀ |  j
 d 6|  j d 6} d	   | j j   D } d
 | k r|  j | d
 <n  d | k r(| p|  j | d <n  y# | j j |  j d |  j
  Wn- | j k
 rz| j j |  j |   n Xd S(   s  
    This function takes a GDAL SpatialReference system and adds 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').
    t   spatial_versions=   The `add_srs_entry` utility only works with spatial backends.s4   This utility does not support your database backend.sM   Spatial reference requires an SRID to be compatible with the spatial backend.t   sridt	   auth_namet	   auth_sridt	   proj4textc         S   s   h  |  ] } | j   q S(    (   t   name(   t   .0t   f(    (    sj   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/utils/srs.pys	   <setcomp>@   s   	 t   srtextt   ref_sys_nameN(   R   R   t   hasattrt   opst	   Exceptiont   featurest   supports_add_srs_entryt   spatial_ref_syst
   isinstanceR    R   t   Nonet   proj4t   _metat
   get_fieldst   wktR	   t   objectst   usingt   gett   DoesNotExistt   create(	   t   srsR   R   R   t   databaset
   connectiont   SpatialRefSyst   kwargst   srs_field_names(    (    sj   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/utils/srs.pyt   add_srs_entry   s2    	
#N(   t   django.contrib.gis.gdalR    t	   django.dbR   R   R   R%   t   add_postgis_srs(    (    (    sj   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/utils/srs.pyt   <module>   s   	J