ó
i4Vdc           @   s¨   d  Z  d d l m Z m Z m Z d d l m Z d d l m Z d d l	 m
 Z d d l m Z d d l m Z m Z d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d S(   sh  
  The Spatial Reference class, represents OGR Spatial Reference objects.

  Example:
  >>> from django.contrib.gis.gdal import SpatialReference
  >>> srs = SpatialReference('WGS84')
  >>> print(srs)
  GEOGCS["WGS 84",
      DATUM["WGS_1984",
          SPHEROID["WGS 84",6378137,298.257223563,
              AUTHORITY["EPSG","7030"]],
          TOWGS84[0,0,0,0,0,0,0],
          AUTHORITY["EPSG","6326"]],
      PRIMEM["Greenwich",0,
          AUTHORITY["EPSG","8901"]],
      UNIT["degree",0.01745329251994328,
          AUTHORITY["EPSG","9122"]],
      AUTHORITY["EPSG","4326"]]
  >>> print(srs.proj)
  +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
  >>> print(srs.ellipsoid)
  (6378137.0, 6356752.3142451793, 298.25722356300003)
  >>> print(srs.projected, srs.geographic)
  False True
  >>> srs.import_epsg(32140)
  >>> print(srs.name)
  NAD83 / Texas South Central
iÿÿÿÿ(   t   byreft   c_char_pt   c_int(   t   GDALBase(   t   SRSException(   t   srs(   t   six(   t   force_bytest
   force_textt   SpatialReferencec           B   sÓ  e  Z d  Z d d d „ Z d „  Z d „  Z d „  Z d d „ Z d	 „  Z d
 „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z d  „  Z  d! „  Z! d" „  Z" e d# „  ƒ Z# e d d$ „ ƒ Z$ e d% „  ƒ Z% e d& „  ƒ Z& e d d' „ ƒ Z' RS((   sê   
    A wrapper for the OGRSpatialReference object.  According to the GDAL Web site,
    the SpatialReference object "provide[s] services to represent coordinate
    systems (projections and datums) and to transform between them."
    t    t   userc         C   sv  | d k r5 t  j t d ƒ ƒ |  _ |  j | ƒ d St | t j ƒ rœ t | t j ƒ rk | j	 d ƒ } n  y t
 | ƒ } d | } Wqè t k
 r˜ qè XnL t | t j ƒ r· d } n1 t | |  j ƒ rØ | } d } n t d | ƒ ‚ | d k rý | } n t d ƒ } t  j | ƒ } | s1t d	 | ƒ ‚ n	 | |  _ | d
 k rV|  j | ƒ n | d k rr|  j | ƒ n  d S(   s'  
        Creates a GDAL OSR Spatial Reference object from the given input.
        The input may be string of OGC Well Known Text (WKT), an integer
        EPSG code, a PROJ.4 string, and/or a projection "well known" shorthand
        string (one of 'WGS84', 'WGS72', 'NAD27', 'NAD83').
        t   wktR
   Nt   asciis   EPSG:%dt   epsgt   ogrs   Invalid SRS type "%s"s+   Could not create spatial reference from: %sR   (   t   capit   new_srsR   t   ptrt
   import_wktt
   isinstanceR   t   string_typest	   text_typet   encodet   intt
   ValueErrort   integer_typest   ptr_typet	   TypeErrorR   t   import_user_inputt   import_epsg(   t   selft	   srs_inputt   srs_typet   sridR   t   buf(    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt   __init__-   s:    				c         C   s&   |  j  r" t r" t j |  j  ƒ n  d S(   s    Destroys this spatial reference.N(   t   _ptrR   t   release_srs(   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt   __del__a   s    c         C   s-   t  | t ƒ r |  j | Œ  S|  j | ƒ Sd S(   sˆ  
        Returns the value of the given string attribute node, None if the node
        doesn't exist.  Can also take a tuple as a parameter, (target, child),
        where child is the index of the attribute in the WKT.  For example:

        >>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]'
        >>> srs = SpatialReference(wkt) # could also use 'WGS84', or 4326
        >>> print(srs['GEOGCS'])
        WGS 84
        >>> print(srs['DATUM'])
        WGS_1984
        >>> print(srs['AUTHORITY'])
        EPSG
        >>> print(srs['AUTHORITY', 1]) # The authority value
        4326
        >>> print(srs['TOWGS84', 4]) # the fourth value in this wkt
        0
        >>> print(srs['UNIT|AUTHORITY']) # For the units authority, have to use the pipe symbole.
        EPSG
        >>> print(srs['UNIT|AUTHORITY', 1]) # The authority value for the units
        9122
        N(   R   t   tuplet
   attr_value(   R   t   target(    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt   __getitem__f   s    c         C   s   |  j  S(   s,   The string representation uses 'pretty' WKT.(   t
   pretty_wkt(   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt   __str__‚   s    i    c         C   sH   t  | t j ƒ s# t  | t ƒ r, t ‚ n  t j |  j t | ƒ | ƒ S(   sš   
        The attribute value for the given target node (e.g. 'PROJCS'). The index
        keyword specifies an index of the child node to return.
        (	   R   R   R   R   R   R   t   get_attr_valueR   R   (   R   R*   t   index(    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyR)   ‡   s    #	c         C   s   t  j |  j t | ƒ ƒ S(   s<   Returns the authority name for the given string target node.(   R   t   get_auth_nameR   R   (   R   R*   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt	   auth_name   s    c         C   s   t  j |  j t | ƒ ƒ S(   s<   Returns the authority code for the given string target node.(   R   t   get_auth_codeR   R   (   R   R*   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt	   auth_code”   s    c         C   s   t  t j |  j ƒ ƒ S(   s0   Returns a clone of this SpatialReference object.(   R	   R   t	   clone_srsR   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt   clone˜   s    c         C   s   t  j |  j ƒ d S(   s8   Morphs this SpatialReference from ESRI's format to EPSG.N(   R   t   morph_from_esriR   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt	   from_esriœ   s    c         C   s   t  j |  j ƒ d S(   sš   
        This method inspects the WKT of this SpatialReference, and will
        add EPSG authority nodes where an EPSG identifier is applicable.
        N(   R   t   identify_epsgR   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyR8       s    c         C   s   t  j |  j ƒ d S(   s.   Morphs this SpatialReference to ESRI's format.N(   R   t   morph_to_esriR   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt   to_esri§   s    c         C   s   t  j |  j ƒ d S(   s6   Checks to see if the given spatial reference is valid.N(   R   t   srs_validateR   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt   validate«   s    c         C   sJ   |  j  r |  j d ƒ S|  j r, |  j d ƒ S|  j rB |  j d ƒ Sd Sd S(   s+   Returns the name of this Spatial Reference.t   PROJCSt   GEOGCSt   LOCAL_CSN(   t	   projectedR)   t
   geographict   localt   None(   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt   name°   s    			c         C   s9   y t  |  j d d ƒ ƒ SWn t t f k
 r4 d SXd S(   s>   Returns the SRID of top-level authority, or None if undefined.t	   AUTHORITYi   N(   R   R)   R   R   RC   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyR"   ¼   s    c         C   s(   t  j |  j t t ƒ  ƒ ƒ \ } } | S(   s%   Returns the name of the linear units.(   R   t   linear_unitsR   R    R   (   R   t   unitsRD   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt   linear_nameÅ   s    $c         C   s(   t  j |  j t t ƒ  ƒ ƒ \ } } | S(   s&   Returns the value of the linear units.(   R   RF   R   R    R   (   R   RG   RD   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyRF   Ë   s    $c         C   s(   t  j |  j t t ƒ  ƒ ƒ \ } } | S(   s&   Returns the name of the angular units.(   R   t   angular_unitsR   R    R   (   R   RG   RD   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt   angular_nameÑ   s    $c         C   s(   t  j |  j t t ƒ  ƒ ƒ \ } } | S(   s'   Returns the value of the angular units.(   R   RI   R   R    R   (   R   RG   RD   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyRI   ×   s    $c         C   sš   d \ } } |  j s |  j rE t j |  j t t ƒ  ƒ ƒ \ } } n0 |  j ru t j	 |  j t t ƒ  ƒ ƒ \ } } n  | d k	 r t
 | ƒ } n  | | f S(   s«   
        Returns a 2-tuple of the units value and the units name,
        and will automatically determines whether to return the linear
        or angular units.
        N(   NN(   RC   R@   RB   R   RF   R   R    R   RA   RI   R   (   R   RG   RD   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyRG   Ý   s    '	'c         C   s   |  j  |  j |  j f S(   s€   
        Returns a tuple of the ellipsoid parameters:
         (semimajor axis, semiminor axis, and inverse flattening)
        (   t
   semi_majort
   semi_minort   inverse_flattening(   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt	   ellipsoidî   s    c         C   s   t  j |  j t t ƒ  ƒ ƒ S(   s7   Returns the Semi Major Axis for this Spatial Reference.(   R   RK   R   R    R   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyRK   ö   s    c         C   s   t  j |  j t t ƒ  ƒ ƒ S(   s7   Returns the Semi Minor Axis for this Spatial Reference.(   R   RL   R   R    R   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyRL   û   s    c         C   s   t  j |  j t t ƒ  ƒ ƒ S(   s:   Returns the Inverse Flattening for this Spatial Reference.(   R   t   invflatteningR   R    R   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyRM      s    c         C   s   t  t j |  j ƒ ƒ S(   se   
        Returns True if this SpatialReference is geographic
         (root node is GEOGCS).
        (   t   boolR   t   isgeographicR   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyRA     s    c         C   s   t  t j |  j ƒ ƒ S(   sG   Returns True if this SpatialReference is local (root node is LOCAL_CS).(   RP   R   t   islocalR   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyRB     s    c         C   s   t  t j |  j ƒ ƒ S(   sx   
        Returns True if this SpatialReference is a projected coordinate system
         (root node is PROJCS).
        (   RP   R   t   isprojectedR   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyR@     s    c         C   s   t  j |  j | ƒ d S(   s>   Imports the Spatial Reference from the EPSG code (an integer).N(   R   t	   from_epsgR   (   R   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyR     s    c         C   s   t  j |  j | ƒ d S(   s3   Imports the Spatial Reference from a PROJ.4 string.N(   R   t	   from_projR   (   R   t   proj(    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt   import_proj   s    c         C   s   t  j |  j t | ƒ ƒ d S(   s?   Imports the Spatial Reference from the given user input string.N(   R   t   from_user_inputR   R   (   R   t
   user_input(    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyR   $  s    c         C   s#   t  j |  j t t | ƒ ƒ ƒ d S(   s3   Imports the Spatial Reference from OGC WKT (string)N(   R   t   from_wktR   R    R   (   R   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyR   (  s    c         C   s   t  j |  j | ƒ d S(   s1   Imports the Spatial Reference from an XML string.N(   R   t   from_xmlR   (   R   t   xml(    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt
   import_xml,  s    c         C   s   t  j |  j t t ƒ  ƒ ƒ S(   s9   Returns the WKT representation of this Spatial Reference.(   R   t   to_wktR   R    R   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyR   1  s    c         C   s   t  j |  j t t ƒ  ƒ | ƒ S(   s/   Returns the 'pretty' representation of the WKT.(   R   t   to_pretty_wktR   R    R   (   R   t   simplify(    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyR,   6  s    c         C   s   t  j |  j t t ƒ  ƒ ƒ S(   s=   Returns the PROJ.4 representation for this Spatial Reference.(   R   t   to_projR   R    R   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyRV   ;  s    c         C   s   |  j  S(   s   Alias for proj().(   RV   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt   proj4@  s    c         C   s   t  j |  j t t ƒ  ƒ | ƒ S(   s9   Returns the XML representation of this Spatial Reference.(   R   t   to_xmlR   R    R   (   R   t   dialect(    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyR\   E  s    ((   t   __name__t
   __module__t   __doc__R$   R'   R+   R-   R)   R1   R3   R5   R7   R8   R:   R<   t   propertyRD   R"   RH   RF   RJ   RI   RG   RN   RK   RL   RM   RA   RB   R@   R   RW   R   R   R]   R   R,   RV   Rb   R\   (    (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyR	   &   sN   4																		t   CoordTransformc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s,   The coordinate system transformation object.c         C   sf   t  | t ƒ s  t  | t ƒ r/ t d ƒ ‚ n  t j | j | j ƒ |  _ | j |  _ | j |  _	 d S(   s<   Initializes on a source and target SpatialReference objects.s2   source and target must be of type SpatialReferenceN(
   R   R	   R   R   t   new_ctR%   R   RD   t
   _srs1_namet
   _srs2_name(   R   t   sourceR*   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyR$   N  s
     c         C   s&   |  j  r" t r" t j |  j  ƒ n  d S(   s.   Deletes this Coordinate Transformation object.N(   R%   R   t
   destroy_ct(   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyR'   V  s    c         C   s   d |  j  |  j f S(   Ns   Transform from "%s" to "%s"(   Rk   Rl   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyR-   [  s    (   Re   Rf   Rg   R$   R'   R-   (    (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyRi   K  s   		N(   Rg   t   ctypesR    R   R   t   django.contrib.gis.gdal.baseR   t   django.contrib.gis.gdal.errorR   t"   django.contrib.gis.gdal.prototypesR   R   t   django.utilsR   t   django.utils.encodingR   R   R	   Ri   (    (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/srs.pyt   <module>   s   ÿ &