ó
i4Vdc           @   s\   d  Z  d d l m Z m Z d d l m Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(	   sÙ  
 The GDAL/OGR library uses an Envelope structure to hold the bounding
 box information for a geometry.  The envelope (bounding box) contains
 two pairs of coordinates, one for the lower left coordinate and one
 for the upper right coordinate:

                           +----------o Upper right; (max_x, max_y)
                           |          |
                           |          |
                           |          |
 Lower left (min_x, min_y) o----------+
iÿÿÿÿ(   t	   Structuret   c_double(   t   GDALExceptiont   OGREnvelopec           B   s8   e  Z d  Z d e f d e f d e f d e f g Z RS(   s'   Represents the OGREnvelope C Structure.t   MinXt   MaxXt   MinYt   MaxY(   t   __name__t
   __module__t   __doc__R   t   _fields_(    (    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyR      s
   			t   Envelopec           B   s³   e  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 RS(   s×   
    The Envelope object is a C structure that contains the minimum and
    maximum X, Y coordinates for a rectangle bounding box.  The naming
    of the variables is compatible with the OGR Envelope structure.
    c         G   sO  t  | ƒ d k r¸ t | d t ƒ r5 | d |  _ q	t | d t t f ƒ r• t  | d ƒ d k r t d t  | d ƒ ƒ ‚ qµ |  j | d ƒ q	t d t	 t
 | d ƒ ƒ ƒ ‚ nQ t  | ƒ d k ró |  j g  | D] } t | ƒ ^ q× ƒ n t d t  | ƒ ƒ ‚ |  j |  j k r*t d ƒ ‚ n  |  j |  j k rKt d ƒ ‚ n  d	 S(
   sŒ   
        The initialization function may take an OGREnvelope structure, 4-element
        tuple or list, or 4 individual arguments.
        i   i    i   s(   Incorrect number of tuple elements (%d).s   Incorrect type of argument: %ss#   Incorrect number (%d) of arguments.s   Envelope minimum X > maximum X.s   Envelope minimum Y > maximum Y.N(   t   lent
   isinstanceR   t	   _envelopet   tuplet   listR   t   _from_sequencet	   TypeErrort   strt   typet   floatt   min_xt   max_xt   min_yt   max_y(   t   selft   argst   a(    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyt   __init__%   s    #)c         C   sÐ   t  | t ƒ rU |  j | j k oT |  j | j k oT |  j | j k oT |  j | j k St  | t ƒ rÀ t | ƒ d k rÀ |  j | d k o¿ |  j | d k o¿ |  j | d k o¿ |  j | d k St d ƒ ‚ d S(   sy   
        Returns True if the envelopes are equivalent; can compare against
        other Envelopes and 4-tuples.
        i   i    i   i   i   s4   Equivalence testing only works with other Envelopes.N(	   R   R   R   R   R   R   R   R   R   (   R   t   other(    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyt   __eq__D   s    $"!&$c         C   s   t  |  j ƒ S(   s-   Returns a string representation of the tuple.(   R   R   (   R   (    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyt   __str__R   s    c         C   sP   t  ƒ  |  _ | d |  j _ | d |  j _ | d |  j _ | d |  j _ d S(   sA   Initializes the C OGR Envelope structure from the given sequence.i    i   i   i   N(   R   R   R   R   R   R   (   R   t   seq(    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyR   V   s
    c         G   sd  t  | ƒ d k rìt | d t ƒ r9 |  j | d j ƒ St | d d ƒ r‘ t | d d ƒ r‘ |  j | d j | d j | d j | d j ƒ St | d t t f ƒ rÉt  | d ƒ d k rù |  j | d d | d d | d d | d d f ƒ St  | d ƒ d k r¬| d \ } } } } | |  j	 j
 k  rF| |  j	 _
 n  | |  j	 j k  rg| |  j	 _ n  | |  j	 j k rˆ| |  j	 _ n  | |  j	 j k rÆ| |  j	 _ qÆqét d t  | d ƒ ƒ ‚ q`t d t t | d ƒ ƒ ƒ ‚ nt t  | ƒ d k r'|  j | d | d | d | d f ƒ St  | ƒ d k rF|  j | ƒ St d	 t  | d ƒ ƒ ‚ d
 S(   s    
        Modifies the envelope to expand to include the boundaries of
        the passed-in 2-tuple (a point), 4-tuple (an extent) or
        envelope.
        i   i    t   xt   yi   i   s(   Incorrect number of tuple elements (%d).s   Incorrect type of argument: %ss#   Incorrect number (%d) of arguments.N(   R   R   R   t   expand_to_includeR   t   hasattrR#   R$   R   R   R   R   R   R   R   R   R   R   (   R   R   t   minxt   minyt   maxxt   maxy(    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyR%   ^   s2    
&29#)c         C   s
   |  j  j S(   s.   Returns the value of the minimum X coordinate.(   R   R   (   R   (    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyR   ˆ   s    c         C   s
   |  j  j S(   s.   Returns the value of the minimum Y coordinate.(   R   R   (   R   (    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyR      s    c         C   s
   |  j  j S(   s.   Returns the value of the maximum X coordinate.(   R   R   (   R   (    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyR   ’   s    c         C   s
   |  j  j S(   s.   Returns the value of the maximum Y coordinate.(   R   R   (   R   (    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyR   —   s    c         C   s   |  j  |  j f S(   s#   Returns the upper-right coordinate.(   R   R   (   R   (    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyt   urœ   s    c         C   s   |  j  |  j f S(   s"   Returns the lower-left coordinate.(   R   R   (   R   (    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyt   ll¡   s    c         C   s   |  j  |  j |  j |  j f S(   s*   Returns a tuple representing the envelope.(   R   R   R   R   (   R   (    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyR   ¦   s    c         C   sD   d |  j  |  j |  j  |  j |  j |  j |  j |  j |  j  |  j f
 S(   s5   Returns WKT representing a Polygon for this envelope.s(   POLYGON((%s %s,%s %s,%s %s,%s %s,%s %s))(   R   R   R   R   (   R   (    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyt   wkt«   s    (   R   R	   R
   R   R    R!   R   R%   t   propertyR   R   R   R   R+   R,   R   R-   (    (    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyR      s   					*N(	   R
   t   ctypesR    R   t   django.contrib.gis.gdal.errorR   R   t   objectR   (    (    (    sn   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/contrib/gis/gdal/envelope.pyt   <module>   s   	