
    g                     N    d Z ddlmZmZ ddlmZ  G d de      Z G d d      Zy)	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y)OGREnvelopez&Represent the OGREnvelope C Structure.MinXMaxXMinYMaxYN)__name__
__module____qualname____doc__r   _fields_     x/var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/site-packages/django/contrib/gis/gdal/envelope.pyr   r      s,    ,					Hr   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y)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                 x   t        |      dk(  rt        |d   t              r|d   | _        nt        |d   t        t
        f      r@t        |d         dk7  rt        dt        |d         z        | j                  |d          nht        dt        |d         z        t        |      dk(  r)| j                  |D cg c]  }t        |       c}       nt        dt        |      z        | j                  | j                  kD  rt        d      | j                  | j                  kD  rt        d      y	c c}w )
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: %s#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floatmin_xmax_xmin_ymax_y)selfargsas      r   __init__zEnvelope.__init__'   s    t9>$q';/!%aDGeT]3tAw<1$'BSa\Q  ''Q0 @4Q= PQQY!^ 4 84aq4 89 ED	 QRR ::

" ABB::

" ABB # !9s   =D7c                    t        |t              rj| j                  |j                  k(  xrO | j                  |j                  k(  xr4 | j                  |j                  k(  xr | j
                  |j
                  k(  S t        |t              r\t        |      dk(  rN| j                  |d   k(  xr: | j                  |d   k(  xr& | j                  |d   k(  xr | 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&u{{* 0ZZ5;;.0ZZ5;;.0 ZZ5;;.	 u%#e*/uQx' -ZZ58+-ZZ58+- ZZ58+	   V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                  _        y)z@Initialize the C OGR Envelope structure from the given sequence.r   r   r.   r/   N)r   r   r   r
   r	   r   )r)   seqs     r   r!   zEnvelope._from_sequenceb   sK    $!!f!!f!!f!!fr   c                    t        |      dk(  rt        |d   t              r| j                  |d   j                        S t        |d   d      rWt        |d   d      rH| j                  |d   j                  |d   j                  |d   j                  |d   j                        S t        |d   t        t        f      rt        |d         dk(  r-| j                  |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                  kD  r|| j                  _        || j                  j                  kD  rF|| j                  _        y
t        dt        |d         z        t        dt!        |d         z        y
t        |      dk(  r!| j                  |d   |d   |d   |d   f      S t        |      dk(  r| j                  |      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yr.   r   r   r   r   N)r   r   r   expand_to_includer   hasattrr9   r:   r    r   r   r
   r	   r   r   r"   r#   )r)   r*   minxminymaxxmaxys         r   r;   zEnvelope.expand_to_includej   s6    t9>$q'8,--d1gmm<<a#&747C+@--GIItAwyy$q'))T!WYY  DGeT]3tAw<1$11aT!WQZaT!WQZH  a\Q&/3Aw,T4tdnn111.2+dnn111.2+dnn111.2+dnn111.2+'BSa\Q    @4Q= PQQ 2 Y!^))47DGT!Wd1g*NOOY!^))$// EDQRG TUUr   c                 .    | j                   j                  S )z-Return the value of the minimum X coordinate.)r   r   r4   s    r   r%   zEnvelope.min_x        ~~"""r   c                 .    | j                   j                  S )z-Return the value of the minimum Y coordinate.)r   r
   r4   s    r   r'   zEnvelope.min_y   rB   r   c                 .    | j                   j                  S )z-Return the value of the maximum X coordinate.)r   r	   r4   s    r   r&   zEnvelope.max_x   rB   r   c                 .    | j                   j                  S )z-Return the value of the maximum Y coordinate.)r   r   r4   s    r   r(   zEnvelope.max_y   rB   r   c                 2    | j                   | j                  fS )z"Return the upper-right coordinate.)r&   r(   r4   s    r   urzEnvelope.ur        

DJJ''r   c                 2    | j                   | j                  fS )z!Return the lower-left coordinate.)r%   r'   r4   s    r   llzEnvelope.ll   rH   r   c                 ^    | j                   | j                  | j                  | j                  fS )z)Return a tuple representing the envelope.)r%   r'   r&   r(   r4   s    r   r   zEnvelope.tuple   s#     

DJJ

DJJ??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&   r4   s    r   wktzEnvelope.wkt   sT    
 JJJJJJJJJJJJJJJJJJJJ
 	
r   N)r   r   r   r   r,   r1   r5   r!   r;   propertyr%   r'   r&   r(   rG   rJ   r   rO   r   r   r   r   r       s    CBX,%.V` # # # # # # # # ( ( ( ( @ @ 
 
r   r   N)r   ctypesr   r   django.contrib.gis.gdal.errorr   r   r   r   r   r   <module>rS      s*    ' 7) l
 l
r   