
    Dvge                         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_        dS )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                 2   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__s        `/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/contrib/gis/geos/collections.pyr   zGeometryCollection.__init__   s     t99>> $q'E4=11 "!!W

!

J 	J''' ,,S__jII
..v.....    c              #   \   K   t          t          |                     D ]}| |         V  dS )z-Iterate over each Geometry in the Collection.N)ranger   )r   is     r   __iter__zGeometryCollection.__iter__&   s<      s4yy!! 	 	Aq'MMMM	 	r   c                     | j         S )z3Return the number of geometries in this Collection.)num_geomr   s    r   __len__zGeometryCollection.__len__+   s
    }r   c                 d    t          |z  d |D              }t          j        | j        ||          S )Nc           	      T    g | ]%}t          j        t          |d |                    &S )ptr)capi
geom_clonegetattr.0gs     r   
<listcomp>z9GeometryCollection._create_collection.<locals>.<listcomp>3   s@         5! 4 455  r   )r   r+   create_collection_typeid)r   lengthitemsgeomss       r   r   z%GeometryCollection._create_collection0   sH    F"  	  
 %dlE6BBBr   c                 6    t          j        | j        |          S N)r+   	get_geomnr*   r   indexs     r   _get_single_internalz'GeometryCollection._get_single_internal<   s    ~dh...r   c                 x    t          t          j        |                     |                    | j                  S )zFReturn the Geometry from this Collection at the given index (0-based).)srid)r   r+   r,   r<   r>   r:   s     r   _get_single_externalz'GeometryCollection._get_single_external?   s:     OD55e<<==DI
 
 
 	
r   c                     | j         }| j        }|                     ||          | _         |r|| _        t          j        |           dS )zJCreate a new collection, and destroy the contents of the previous pointer.N)r*   r>   r   r+   destroy_geom)r   r4   r5   prev_ptrr>   s        r   	_set_listzGeometryCollection._set_listF   sM    8y**6599 	DI(#####r   c                 F    dd                     d | D                       z  S )z,Return the KML for this Geometry Collection.z!<MultiGeometry>%s</MultiGeometry> c              3   $   K   | ]}|j         V  d S r8   )kmlr.   s     r   	<genexpr>z)GeometryCollection.kml.<locals>.<genexpr>U   s$      <Q<QqQU<Q<Q<Q<Q<Q<Qr   )joinr&   s    r   rG   zGeometryCollection.kmlR   s*     3RWW<Q<QD<Q<Q<Q5Q5QQQr   c                 4    t          d | D                       S )zAReturn a tuple of all the coordinates in this Geometry Collectionc              3   $   K   | ]}|j         V  d S r8   r   r.   s     r   rH   z+GeometryCollection.tuple.<locals>.<genexpr>Z   s$      ++QW++++++r   rL   r&   s    r   r   zGeometryCollection.tupleW   s!     ++d++++++r   )__name__
__module____qualname__r3   r   r#   r'   r   r<   r?   rC   r   _set_single_rebuild_set_single_assign_extended_slice_rebuild_assign_extended_slicepropertyrG   r   coords__classcell__)r   s   @r   r   r      s        G/ / / / /*  
  

C 
C 
C/ / /
 
 
$ $ $ 2K)HR R XR , , X, FFFFFr   r   c                       e Zd ZeZdZdS )
MultiPoint   N)rM   rN   rO   r	   _allowedr3    r   r   rX   rX   `   s        HGGGr   rX   c                       e Zd ZeefZdZdS )MultiLineString   N)rM   rN   rO   r   r   rZ   r3   r[   r   r   r]   r]   e   s        J'HGGGr   r]   c                       e Zd ZeZdZdS )MultiPolygon   N)rM   rN   rO   r
   rZ   r3   r[   r   r   r`   r`   j   s        HGGGr   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   rX   r]   r`   rZ   r[   r   r   <module>ri      sh   
 7 6 6 6 6 6 N N N N N N N N 4 4 4 4 4 4 E E E E E E E E / / / / / / 3 3 3 3 3 3N N N N N N N Nd    #   
    )+=   
    %    
    r   