o
    iTte7                     @   s   d Z ddlmZ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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 )zy
 This module houses the Geometry Collection objects:
 GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
    )byrefc_intc_uint)
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__ o/var/www/social.2tendo.club/virtuCedar/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   s2   t | dd |D  }tt| jt|t|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_collectionr   _typeidr   r   )r   lengthitemsgeomsr   r   r    r   1   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)   r8   r9   r6   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'   r9   r   r(   destroy_geom)r   r1   r2   prev_ptrr9   r   r   r    	_set_listB   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 r4   )kmlr+   r   r   r    	<genexpr>Q       z)GeometryCollection.kml.<locals>.<genexpr>)joinr%   r   r   r    r@   N   s   zGeometryCollection.kmlc                 C   s   t dd | D S )zAReturn a tuple of all the coordinates in this Geometry Collectionc                 s   r?   r4   r   r+   r   r   r    rA   V   rB   z+GeometryCollection.tuple.<locals>.<genexpr>rD   r%   r   r   r    r   S   s   zGeometryCollection.tuple)__name__
__module____qualname__r0   r   r#   r&   r   r8   r:   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)rE   rF   rG   r   _allowedr0   r   r   r   r    rP   [       rP   c                   @   s   e Zd ZeefZdZdS )MultiLineString   N)rE   rF   rG   r
   r	   rR   r0   r   r   r   r    rT   `   s    rT   c                   @   rO   )MultiPolygon   N)rE   rF   rG   r   rR   r0   r   r   r   r    rV   e   rS   rV   N)__doc__ctypesr   r   r   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   rP   rT   rV   rR   r   r   r   r    <module>   s    L