ó
E()Qc           @   s/   d  d l  m Z d d d d d  Z e Z d S(   i˙˙˙˙(   t   SpatialReferencet   EPSGc         C   s  d d l  m } m } | s% | } n  | | } t | j d  sP t d   n  | j j sh | j j rw 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}	 | j j r|  j |	 d <n  | j j r1| p'|  j |	 d <n  y% | j j |  j d |  j  }
 Wn/ | j k
 r| 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 -- for example, the so-called "Google Maps Mercator Projection"
    is excluded in PostGIS 1.3 and below, and the following adds it to the
    `spatial_ref_sys` table:

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

    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, it's value
      is 'default').
    i˙˙˙˙(   t   connectionst   DEFAULT_DB_ALIASt   spatial_versions=   The `add_srs_entry` utility only works with spatial backends.sC   This utility does not support the Oracle or MySQL spatial backends.sM   Spatial reference requires an SRID to be compatible with the spatial backend.t   sridt	   auth_namet	   auth_sridt	   proj4textt   srtextt   ref_sys_nameN(   t	   django.dbR   R   t   hasattrt   opst	   Exceptiont   oraclet   mysqlt   spatial_ref_syst
   isinstanceR    R   t   Nonet   proj4t   postgist   wktt
   spatialitet   namet   objectst   usingt   gett   DoesNotExistt   create(   t   srsR   R   R
   t   databaseR   R   t
   connectiont   SpatialRefSyst   kwargst   sr(    (    s5   ../Django//lib/python/django/contrib/gis/utils/srs.pyt   add_srs_entry   s2     	
%N(   t   django.contrib.gis.gdalR    R   R$   t   add_postgis_srs(    (    (    s5   ../Django//lib/python/django/contrib/gis/utils/srs.pyt   <module>   s   	L