
    ge                         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	e      Z G d
 de      Z G d dee      Z G d de      Zeee
eeeefe_        y)zy
 This module houses the Geometry Collection objects:
 GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
    )
prototypes)GEOSGeometryLinearGeometryMixin)GEOM_PTR)
LinearRing
LineString)Point)Polygonc                        e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
ej                  Zej                  Zed	        Zed
        ZeZ xZS )GeometryCollection   c                     t        |      dk(  r"t        |d   t        t        f      r|d   }n|}n|}| j	                  |       | j                  t        |      |      }t        |   |fi | y)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__s        {/var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/site-packages/django/contrib/gis/geos/collections.pyr   zGeometryCollection.__init__   sq     t9> $q'E4=1!!W
!
J 	J' ,,S_jI
.v.    c              #   L   K   t        t        |             D ]	  }| |     yw)z-Iterate over each Geometry in the Collection.N)ranger   )r   is     r   __iter__zGeometryCollection.__iter__&   s"     s4y!Aq'M "s   "$c                     | j                   S )z3Return the number of geometries in this Collection.)num_geomr   s    r   __len__zGeometryCollection.__len__+   s    }}r   c                     t        |z  |D cg c]"  }t        j                  t        |d|            $ c} }t        j                  | j
                  ||      S c c}w )Nptr)r   capi
geom_clonegetattrcreate_collection_typeid)r   lengthitemsggeomss        r   r   z%GeometryCollection._create_collection0   sb    F"
 	 A 5! 45	
 %%dllE6BBs   'Ac                 B    t        j                  | j                  |      S N)r*   	get_geomnr)   r   indexs     r   _get_single_internalz'GeometryCollection._get_single_internal<   s    ~~dhh..r   c                 t    t        t        j                  | j                  |            | j                        S )zFReturn the Geometry from this Collection at the given index (0-based).)srid)r   r*   r+   r8   r:   r6   s     r   _get_single_externalz'GeometryCollection._get_single_external?   s.     OOD55e<=DII
 	
r   c                     | j                   }| j                  }| j                  ||      | _         |r|| _        t        j                  |       y)zJCreate a new collection, and destroy the contents of the previous pointer.N)r)   r:   r   r*   destroy_geom)r   r/   r0   prev_ptrr:   s        r   	_set_listzGeometryCollection._set_listF   s@    88yy**659DI(#r   c                 8    ddj                  d | D              z  S )z,Return the KML for this Geometry Collection.z!<MultiGeometry>%s</MultiGeometry> c              3   4   K   | ]  }|j                     y wr4   )kml.0r1   s     r   	<genexpr>z)GeometryCollection.kml.<locals>.<genexpr>U   s     <QDqQUUD   )joinr&   s    r   rC   zGeometryCollection.kmlR   s     3RWW<QD<Q5QQQr   c                 &    t        d | D              S )zAReturn a tuple of all the coordinates in this Geometry Collectionc              3   4   K   | ]  }|j                     y wr4   r   rD   s     r   rF   z+GeometryCollection.tuple.<locals>.<genexpr>Z   s     +dQWWdrG   rK   r&   s    r   r   zGeometryCollection.tupleW   s     +d+++r   )__name__
__module____qualname__r.   r   r#   r'   r   r8   r;   r?   r   _set_single_rebuild_set_single_assign_extended_slice_rebuild_assign_extended_slicepropertyrC   r   coords__classcell__)r   s   @r   r   r      st    G/*


C/
$ 22K)HHR R , , Fr   r   c                       e Zd ZeZdZy)
MultiPoint   N)rL   rM   rN   r	   _allowedr.    r   r   rW   rW   `   s    HGr   rW   c                       e Zd ZeefZdZy)MultiLineString   N)rL   rM   rN   r   r   rY   r.   rZ   r   r   r\   r\   e   s    J'HGr   r\   c                       e Zd ZeZdZy)MultiPolygon   N)rL   rM   rN   r
   rY   r.   rZ   r   r   r_   r_   j   s    HGr   r_   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   rW   r\   r_   rY   rZ   r   r   <module>rh      sy   
 7 N 4 E / 3N Nd# 
)+= 
%  
  r   