o
    þÞh”  ã                   @   sB   d Z ddlmZmZ ddlmZ G dd„ deƒZG d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                   @   s,   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_© r   r   ú`/var/www/html/premium_crap/venv/lib/python3.10/site-packages/django/contrib/gis/gdal/envelope.pyr      s    ür   c                   @   s˜   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Ze	dd„ ƒZ
e	dd„ ƒZe	dd„ ƒZe	dd„ ƒZe	dd„ ƒZe	dd„ ƒZe	dd„ ƒZe	d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                 G   sÞ   t |ƒdkr@t|d tƒr|d | _nFt|d ttfƒr6t |d ƒdkr.tdt |d ƒ ƒ‚|  |d ¡ n#tdt	|d ƒ ƒ‚t |ƒdkrQ|  dd„ |D ƒ¡ ntdt |ƒ ƒ‚| j
| jkrctd	ƒ‚| j| jkrmt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                 S   s   g | ]}t |ƒ‘qS r   )Úfloat)Ú.0Úar   r   r   Ú
<listcomp>?   s    z%Envelope.__init__.<locals>.<listcomp>ú#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Úargsr   r   r   Ú__init__(   s$   ÿÿzEnvelope.__init__c                 C   s�   t |tƒr| j|jko| j|jko| j|jko| j|jkS t |tƒrDt|ƒdkrD| j|d koC| j|d koC| j|d koC| 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'   Úotherr   r   r   Ú__eq__I   s"   

ÿ
þ
üÿþüzEnvelope.__eq__c                 C   s
   t | jƒS )z,Return a string representation of the tuple.)Ústrr   ©r'   r   r   r   Ú__str___   s   
zEnvelope.__str__c                 C   s<   t ƒ | _|d | j_|d | j_|d | j_|d | j_dS )z@Initialize the C OGR Envelope structure from the given sequence.r   r   r*   r+   N)r   r   r   r   r   r	   )r'   Úseqr   r   r   r    c   s
   zEnvelope._from_sequencec                 G   sº  t |ƒdkr±t|d tƒr|  |d j¡S t|d dƒr7t|d dƒr7|  |d j|d j|d j|d j¡S t|d ttfƒr§t |d ƒdkra|  |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 ƒ ƒ‚tdt|d ƒ ƒ‚t |ƒdkrÈ|  |d |d |d |d f¡S t |ƒdkrÓ|  |¡S td	t |d ƒ ƒ‚)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   Úhasattrr2   r3   r   r   r   r   r   r	   r   r!   r"   )r'   r(   ÚminxÚminyÚmaxxÚmaxyr   r   r   r4   k   s@   
 ÿ*ÿÿÿ"
zEnvelope.expand_to_includec                 C   ó   | j jS )z-Return the value of the minimum X coordinate.)r   r   r/   r   r   r   r#   ›   ó   zEnvelope.min_xc                 C   r:   )z-Return the value of the minimum Y coordinate.)r   r   r/   r   r   r   r%       r;   zEnvelope.min_yc                 C   r:   )z-Return the value of the maximum X coordinate.)r   r   r/   r   r   r   r$   ¥   r;   zEnvelope.max_xc                 C   r:   )z-Return the value of the maximum Y coordinate.)r   r	   r/   r   r   r   r&   ª   r;   zEnvelope.max_yc                 C   ó   | j | jfS )z"Return the upper-right coordinate.)r$   r&   r/   r   r   r   Úur¯   ó   zEnvelope.urc                 C   r<   )z!Return the lower-left coordinate.)r#   r%   r/   r   r   r   Úll´   r>   zEnvelope.llc                 C   s   | j | j| j| jfS )z)Return a tuple representing the envelope.)r#   r%   r$   r&   r/   r   r   r   r   ¹   s   zEnvelope.tuplec                 C   s0   d| j | j| j | j| j| j| j| j| j | jf
 S )z4Return WKT representing a Polygon for this envelope.z(POLYGON((%s %s,%s %s,%s %s,%s %s,%s %s)))r#   r%   r&   r$   r/   r   r   r   Úwkt¾   s   özEnvelope.wktN)r
   r   r   r   r)   r-   r0   r    r4   Úpropertyr#   r%   r$   r&   r=   r?   r   r@   r   r   r   r   r   !   s.    !0






r   N)r   Úctypesr   r   Údjango.contrib.gis.gdal.errorr   r   r   r   r   r   r   Ú<module>   s
    