
    h7                         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
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
    )byrefc_intc_uint)
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        f/var/www/html/ranktracker/api/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                  t        | j                        t        |      t        |            S c c}w )Nptr)	r	   capi
geom_clonegetattrcreate_collectionr   _typeidr   r   )r   lengthitemsggeomss        r!   r   z%GeometryCollection._create_collection1   si    F" <A&
 78DOOGAua01&
 
 %%eDLL&95<PVXX&
s   'A4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.   r;   r=   r9   s     r!   _get_single_externalz'GeometryCollection._get_single_external=   s,     DOOD,E,Ee,LMTXT]T]^^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   r2   r3   prev_ptrr=   s        r!   	_set_listzGeometryCollection._set_listB   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r7   )kml.0r4   s     r!   	<genexpr>z)GeometryCollection.kml.<locals>.<genexpr>Q   s     <QqQUU<Q   )joinr)   s    r!   rF   zGeometryCollection.kmlN   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r7   r   rG   s     r!   rI   z+GeometryCollection.tuple.<locals>.<genexpr>V   s     +QWW+rJ   rN   r)   s    r!   r   zGeometryCollection.tupleS   s     +d+++r"   )__name__
__module____qualname__r1   r   r&   r*   r   r;   r>   rB   r   _set_single_rebuild_set_single_assign_extended_slice_rebuild_assign_extended_slicepropertyrF   r   coords__classcell__)r    s   @r!   r   r      su    G/*

Y/_
$ 22K)HHR R , , Fr"   r   c                       e Zd ZeZdZy)
MultiPoint   N)rO   rP   rQ   r   _allowedr1    r"   r!   rZ   rZ   [   s    HGr"   rZ   c                       e Zd ZeefZdZy)MultiLineString   N)rO   rP   rQ   r   r
   r\   r1   r]   r"   r!   r_   r_   `   s    J'HGr"   r_   c                       e Zd ZeZdZy)MultiPolygon   N)rO   rP   rQ   r   r\   r1   r]   r"   r!   rb   rb   e   s    HGr"   rb   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   rZ   r_   rb   r\   r]   r"   r!   <module>rl      sy    ( ' 6 N 4 E / 3H HX# 
)+= 
%   %j*gzSbdpq  r"   