OwlCyberSecurity - MANAGER
Edit File: polygon.cpython-39.pyc
a jH�f6 � @ sD d dl mZ d dlmZ d dlmZ d dlmZ G dd� de�Z dS )� )� prototypes)�GEOSGeometry)�GEOM_PTR)� LinearRingc s� e Zd ZdZ� fdd�Zdd� Zdd� Zedd � �Zd d� Z dd � Z d!dd�Zdd� Zdd� Z dd� ZejZejZedd� �Zdd� Zdd� Zeee�ZeZedd� �ZeZedd � �Z� ZS )"�Polygon� c s� |s$t � j| �dd�fi |�� dS |^}}t|�}|dkr�t|d ttf�r�|d s`d}d}n"t|d d t�r�|d }t|�}| �|d |g|��}t � j|fi |�� dS )a� Initialize on an exterior ring and a sequence of holes (both instances may be either LinearRing instances, or a tuple/list that may be constructed into a LinearRing). Examples of initialization, where shell, hole1, and hole2 are valid LinearRing geometries: >>> from django.contrib.gis.geos import LinearRing, Polygon >>> shell = hole1 = hole2 = LinearRing() >>> poly = Polygon(shell, hole1, hole2) >>> poly = Polygon(shell, (hole1, hole2)) >>> # Example where a tuple parameters are used: >>> poly = Polygon(((0, 0), (0, 10), (10, 10), (10, 0), (0, 0)), ... ((4, 4), (4, 6), (6, 6), (6, 4), (4, 4))) r Nr � )�super�__init__�_create_polygon�len� isinstance�tuple�listr )�self�args�kwargsZext_ringZ init_holes�n_holesZpolygon�� __class__r �a/home/gouroczh/virtualenv/test/3.9/lib/python3.9/site-packages/django/contrib/gis/geos/polygon.pyr s zPolygon.__init__c c s t t| ��D ]}| | V qdS )z&Iterate over each ring in the polygon.N)�ranger )r �ir r r �__iter__0 s zPolygon.__iter__c C s | j d S )z+Return the number of rings in this Polygon.r )�num_interior_rings�r r r r �__len__5 s zPolygon.__len__c C sn |\}}}}|D ]6}t |ttf�std||||||||||f � S qt||f||f||f||f||ff�S )z2Construct a Polygon from a bounding box (4-tuple).z,POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s)))r �float�intr r )�clsZbboxZx0Zy0�x1�y1�zr r r � from_bbox9 s �� zPolygon.from_bboxc s� |st �� S g }|D ]*}t|t�r.|�|� q|�� �|�� q� �|�d��}|d }|rxt| � fdd�|D �� }nd }t �|||�S )Nr r c s g | ]}� � |��qS r )�_clone)�.0�rr r r � <listcomp>Y � z+Polygon._create_polygon.<locals>.<listcomp>) �capiZcreate_empty_polygonr r �append�_construct_ringr$ �popZcreate_polygon)r �length�itemsZringsr&