File: //lib/python3/dist-packages/django/contrib/gis/gdal/__pycache__/envelope.cpython-310.pyc
o
�a> � @ sB d Z ddlmZmZ ddlmZ G dd� de�ZG dd� d�ZdS ) 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 Zd ZdZdefdefdefdefgZdS )�OGREnvelopez&Represent the OGREnvelope C Structure.�MinX�MaxX�MinY�MaxYN)�__name__�
__module__�__qualname__�__doc__r �_fields_� r r �B/usr/lib/python3/dist-packages/django/contrib/gis/gdal/envelope.pyr s �r c @ s� e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Ze dd
� �Z
e dd� �Ze dd� �Ze dd� �Z
e dd� �Ze dd� �Ze dd� �Ze dd� �ZdS )�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 |�dkr@t|d t�r|d | _nFt|d ttf�r6t |d �dkr.tdt |d � ��| �|d � n#tdt |d � ��t |�dkrQ| �dd� |D �� ntdt |� ��| j
| jkrctd ��| j| j
krmtd
��dS )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 |��qS r )�float)�.0�ar r r �
<listcomp>: s z%Envelope.__init__.<locals>.<listcomp>�#Incorrect number (%d) of arguments.zEnvelope minimum X > maximum X.zEnvelope 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 �zEnvelope.__init__c C s� t |t�r| j|jko| j|jko| j|jko| j|jkS t |t�rDt|�dkrD| j|d koC| j|d koC| j|d koC| j|d kS td��)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&