
    Dvg                     \    d Z ddlmZmZ ddlmZ  G d de          Z G d d          ZdS )	a  
 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----------+
    )	Structurec_double)GDALExceptionc                   .    e Zd ZdZdefdefdefdefgZdS )OGREnvelopez&Represent the OGREnvelope C Structure.MinXMaxXMinYMaxYN)__name__
__module____qualname____doc__r   _fields_     ]/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/contrib/gis/gdal/envelope.pyr   r      s;        ,,					HHHr   r   c                       e 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dS )Envelopez
    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                    t          |          dk    rt          |d         t                    r|d         | _        nt          |d         t          t
          f          rZt          |d                   dk    r%t          dt          |d                   z            |                     |d                    nwt          dt          |d                   z            t          |          dk    r |                     d |D                        nt          dt          |          z            | j
        | j        k    rt          d          | j        | j        k    rt          d	          d
S )z
        The initialization function may take an OGREnvelope structure, 4-element
        tuple or list, or 4 individual arguments.
           r      (Incorrect number of tuple elements (%d).Incorrect type of argument: %sc                 ,    g | ]}t          |          S r   )float).0as     r   
<listcomp>z%Envelope.__init__.<locals>.<listcomp>>   s     8 8 8aq 8 8 8r   #Incorrect number (%d) of arguments.zEnvelope minimum X > maximum X.zEnvelope minimum Y > maximum Y.N)len
isinstancer   	_envelopetuplelistr   _from_sequence	TypeErrortypemin_xmax_xmin_ymax_y)selfargss     r   __init__zEnvelope.__init__'   s]    t99>>$q';// R!%aDGeT]33 	RtAw<<1$$'BSa\\Q   ''Q0000 @4Q== PQQQYY!^^  8 84 8 8 89999 ED		 QRRR :
"" ABBB:
"" ABBB #"r   c                    t          |t                    r@| j        |j        k    o/| j        |j        k    o| j        |j        k    o| j        |j        k    S t          |t                    rWt          |          dk    rD| j        |d         k    o2| j        |d         k    o!| j        |d         k    o| j        |d         k    S t          d          )zx
        Return True if the envelopes are equivalent; can compare against
        other Envelopes and 4-tuples.
        r   r   r         z4Equivalence testing only works with other Envelopes.)	r"   r   r)   r+   r*   r,   r$   r!   r   )r-   others     r   __eq__zEnvelope.__eq__H   s    
 eX&& 	Xu{* 0Z5;.0Z5;.0 Z5;.	 u%% 	X#e**//uQx' -Z58+-Z58+- Z58+	   VWWWr   c                 *    t          | j                  S )z,Return a string representation of the tuple.)strr$   r-   s    r   __str__zEnvelope.__str__^   s    4:r   c                     t                      | _        |d         | j        _        |d         | j        _        |d         | j        _        |d         | j        _        dS )z@Initialize the C OGR Envelope structure from the given sequence.r   r   r1   r2   N)r   r#   r   r
   r	   r   )r-   seqs     r   r&   zEnvelope._from_sequenceb   sK    $!!f!!f!!f!!fr   c                 t   t          |          dk    rt          |d         t                    r |                     |d         j                  S t          |d         d          rZt          |d         d          rD|                     |d         j        |d         j        |d         j        |d         j                  S t          |d         t          t          f          r!t          |d                   dk    rI|                     |d         d         |d         d         |d         d         |d         d         f          S t          |d                   dk    r|d         \  }}}}|| j	        j
        k     r|| j	        _
        || j	        j        k     r|| j	        _        || j	        j        k    r|| j	        _        || j	        j        k    r|| j	        _        d
S d
S t          dt          |d                   z            t          dt!          |d                   z            t          |          dk    r1|                     |d         |d         |d         |d         f          S t          |          dk    r|                     |          S t          d	t          |d                   z            )z
        Modify the envelope to expand to include the boundaries of
        the passed-in 2-tuple (a point), 4-tuple (an extent) or
        envelope.
        r   r   xyr1   r   r   r   r    N)r!   r"   r   expand_to_includer$   hasattrr<   r=   r%   r#   r   r
   r	   r   r   r'   r(   )r-   r.   minxminymaxxmaxys         r   r>   zEnvelope.expand_to_includej   s    t99>>$q'8,, R--d1gm<<<a#&& R747C+@+@ R--GItAwy$q')T!WY   DGeT]33 RtAw<<1$$11aT!WQZaT!WQZH   a\\Q&&/3Aw,T4tdn111.2+dn111.2+dn111.2+dn111.2+++ 21 (BSa\\Q     @4Q== PQQQYY!^^))47DGT!Wd1g*NOOOYY!^^))$/// EDQRG TUUUr   c                     | j         j        S )z-Return the value of the minimum X coordinate.)r#   r   r7   s    r   r)   zEnvelope.min_x        ~""r   c                     | j         j        S )z-Return the value of the minimum Y coordinate.)r#   r
   r7   s    r   r+   zEnvelope.min_y   rE   r   c                     | j         j        S )z-Return the value of the maximum X coordinate.)r#   r	   r7   s    r   r*   zEnvelope.max_x   rE   r   c                     | j         j        S )z-Return the value of the maximum Y coordinate.)r#   r   r7   s    r   r,   zEnvelope.max_y   rE   r   c                     | j         | j        fS )z"Return the upper-right coordinate.)r*   r,   r7   s    r   urzEnvelope.ur        
DJ''r   c                     | j         | j        fS )z!Return the lower-left coordinate.)r)   r+   r7   s    r   llzEnvelope.ll   rK   r   c                 6    | j         | j        | j        | j        fS )z)Return a tuple representing the envelope.)r)   r+   r*   r,   r7   s    r   r$   zEnvelope.tuple   s     
DJ
DJ??r   c                     d| j         d| j        d| j         d| j        d| j        d| j        d| j        d| j        d| j         d| j        dS )z4Return WKT representing a Polygon for this envelope.z	POLYGON(( ,z)))r)   r+   r,   r*   r7   s    r   wktzEnvelope.wkt   sj     
 JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
 	
r   N)r   r   r   r   r/   r4   r8   r&   r>   propertyr)   r+   r*   r,   rJ   rM   r$   rR   r   r   r   r   r       sO        C C CBX X X,  % % %.V .V .V` # # X# # # X# # # X# # # X# ( ( X( ( ( X( @ @ X@ 
 
 X
 
 
r   r   N)r   ctypesr   r   django.contrib.gis.gdal.errorr   r   r   r   r   r   <module>rV      s     ' & & & & & & & 7 7 7 7 7 7    )   l
 l
 l
 l
 l
 l
 l
 l
 l
 l
r   