o
    þÞhc  ã                   @   s®   d Z ddlmZ ddlmZmZ ddlmZ ddl	m
Z
mZ ddlmZ ddlmZ G dd	„ d	eƒZG d
d„ deƒZG dd„ deeƒZG dd„ deƒZeee
eeeefe_dS )zw
This module houses the Geometry Collection objects:
GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
é    )Ú
prototypes)ÚGEOSGeometryÚLinearGeometryMixin)ÚGEOM_PTR)Ú
LinearRingÚ
LineString)ÚPoint)ÚPolygonc                       sx   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
ejZejZedd„ ƒZedd„ ƒZeZ‡  ZS )ÚGeometryCollectioné   c                    sd   t |ƒdkrt|d ttfƒr|d }n|}n|}|  |¡ |  t |ƒ|¡}tƒ j|fi |¤Ž dS )zEInitialize a Geometry Collection from a sequence of Geometry objects.é   r   N)ÚlenÚ
isinstanceÚtupleÚlistÚ_check_allowedÚ_create_collectionÚsuperÚ__init__)ÚselfÚargsÚkwargsÚ
init_geomsÚ
collection©Ú	__class__© úc/var/www/html/premium_crap/venv/lib/python3.10/site-packages/django/contrib/gis/geos/collections.pyr      s   

zGeometryCollection.__init__c                 c   s"   � t t| ƒƒD ]}| | V  qdS )z-Iterate over each Geometry in the Collection.N)Úranger   )r   Úir   r   r   Ú__iter__&   s   €ÿzGeometryCollection.__iter__c                 C   s   | j S )z3Return the number of geometries in this Collection.)Únum_geom©r   r   r   r   Ú__len__+   s   zGeometryCollection.__len__c                 C   s&   t | dd„ |D ƒŽ }t | j||¡S )Nc                 S   s   g | ]}t  t|d |ƒ¡‘qS )Úptr)ÚcapiÚ
geom_cloneÚgetattr©Ú.0Úgr   r   r   Ú
<listcomp>3   s    ÿýz9GeometryCollection._create_collection.<locals>.<listcomp>)r   r%   Úcreate_collectionÚ_typeid)r   ÚlengthÚitemsÚgeomsr   r   r   r   0   s   üÿz%GeometryCollection._create_collectionc                 C   s   t  | j|¡S ©N)r%   Ú	get_geomnr$   ©r   Úindexr   r   r   Ú_get_single_internal<   s   z'GeometryCollection._get_single_internalc                 C   s   t t |  |¡¡| jd�S )zFReturn the Geometry from this Collection at the given index (0-based).)Úsrid)r   r%   r&   r5   r6   r3   r   r   r   Ú_get_single_external?   s   ÿz'GeometryCollection._get_single_externalc                 C   s2   | j }| j}|  ||¡| _ |r|| _t |¡ dS )zJCreate a new collection, and destroy the contents of the previous pointer.N)r$   r6   r   r%   Údestroy_geom)r   r.   r/   Úprev_ptrr6   r   r   r   Ú	_set_listF   s   zGeometryCollection._set_listc                 C   s   dd  dd„ | D ƒ¡ S )z,Return the KML for this Geometry Collection.z!<MultiGeometry>%s</MultiGeometry>Ú c                 s   ó   � | ]}|j V  qd S r1   )Úkmlr(   r   r   r   Ú	<genexpr>U   ó   € z)GeometryCollection.kml.<locals>.<genexpr>)Újoinr"   r   r   r   r=   R   s   zGeometryCollection.kmlc                 C   s   t dd„ | D ƒƒS )zAReturn a tuple of all the coordinates in this Geometry Collectionc                 s   r<   r1   ©r   r(   r   r   r   r>   Z   r?   z+GeometryCollection.tuple.<locals>.<genexpr>rA   r"   r   r   r   r   W   s   zGeometryCollection.tuple)Ú__name__Ú
__module__Ú__qualname__r-   r   r    r#   r   r5   r7   r:   r   Ú_set_single_rebuildÚ_set_singleÚ_assign_extended_slice_rebuildÚ_assign_extended_sliceÚpropertyr=   r   ÚcoordsÚ__classcell__r   r   r   r   r
      s     	

r
   c                   @   ó   e Zd ZeZdZdS )Ú
MultiPointé   N)rB   rC   rD   r   Ú_allowedr-   r   r   r   r   rM   `   ó    rM   c                   @   s   e Zd ZeefZdZdS )ÚMultiLineStringé   N)rB   rC   rD   r   r   rO   r-   r   r   r   r   rQ   e   s    rQ   c                   @   rL   )ÚMultiPolygoné   N)rB   rC   rD   r	   rO   r-   r   r   r   r   rS   j   rP   rS   N)Ú__doc__Údjango.contrib.gis.geosr   r%   Ú django.contrib.gis.geos.geometryr   r   Údjango.contrib.gis.geos.libgeosr   Ú"django.contrib.gis.geos.linestringr   r   Údjango.contrib.gis.geos.pointr   Údjango.contrib.gis.geos.polygonr	   r
   rM   rQ   rS   rO   r   r   r   r   Ú<module>   s&    R
ù