B
    ¥0H[B  ã               @   sÒ   d Z ddlmZmZmZ ddlmZ ddlm	Z	 ddl
mZmZ ddlmZ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)ÚGEOSException)ÚGEOSGeometryÚLinearGeometryMixin)ÚGEOM_PTRÚgeos_version_tuple)Ú
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                s`   t |ƒdkr.t|d ttfƒr(|d }q2|}n|}|  |¡ |  t |ƒ|¡}tƒ j|f|Ž dS )zEInitialize a Geometry Collection from a sequence of Geometry objects.é   r   N)ÚlenÚ
isinstanceÚtupleÚlistZ_check_allowedÚ_create_collectionÚsuperÚ__init__)ÚselfÚargsÚkwargsZ
init_geomsZ
collection)Ú	__class__© úgC:\Users\HIRONO~1\AppData\Local\Temp\pip-install-6bm3nxem\django\django\contrib\gis\geos\collections.pyr      s    

zGeometryCollection.__init__c             c   s$   xt t| ƒƒD ]}| | V  qW 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.)Z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>7   s    z9GeometryCollection._create_collection.<locals>.<listcomp>)r	   r$   Zcreate_collectionr   Ú_typeidr   r   )r   ÚlengthÚitemsZgeomsr   r   r   r   2   s    z%GeometryCollection._create_collectionc             C   s   t  | j|¡S )N)r$   Z	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%   r.   r/   )r   r-   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#   r/   r   r$   Zdestroy_geom)r   r+   r,   Zprev_ptrr/   r   r   r   Ú	_set_listC   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   s   | ]}|j V  qd S )N)Úkml)r'   r(   r   r   r   ú	<genexpr>R   s    z)GeometryCollection.kml.<locals>.<genexpr>)Újoin)r   r   r   r   r3   O   s    zGeometryCollection.kmlc             C   s   t dd„ | D ƒƒS )zAReturn a tuple of all the coordinates in this Geometry Collectionc             s   s   | ]}|j V  qd S )N)r   )r'   r(   r   r   r   r4   W   s    z+GeometryCollection.tuple.<locals>.<genexpr>)r   )r   r   r   r   r   T   s    zGeometryCollection.tuple)Ú__name__Ú
__module__Ú__qualname__r*   r   r!   r"   r   r.   r0   r1   r   Z_set_single_rebuildZ_set_singleZ_assign_extended_slice_rebuildZ_assign_extended_sliceÚpropertyr3   r   ZcoordsÚ__classcell__r   r   )r   r   r      s   		r   c               @   s   e Zd ZeZdZdS )Ú
MultiPointé   N)r6   r7   r8   r   Ú_allowedr*   r   r   r   r   r;   \   s   r;   c                   s,   e Zd ZeefZdZe‡ fdd„ƒZ‡  Z	S )ÚMultiLineStringé   c                s   t ƒ dk rtdƒ‚tƒ jS )N)é   r?   z.MultiLineString.closed requires GEOS >= 3.5.0.)r
   r   r   Úclosed)r   )r   r   r   rA   e   s    
zMultiLineString.closed)
r6   r7   r8   r   r   r=   r*   r9   rA   r:   r   r   )r   r   r>   a   s   r>   c               @   s   e Zd ZeZdZdS )ÚMultiPolygoné   N)r6   r7   r8   r   r=   r*   r   r   r   r   rB   l   s   rB   N)Ú__doc__Úctypesr   r   r   Zdjango.contrib.gis.geosr   r$   Zdjango.contrib.gis.geos.errorr   Z django.contrib.gis.geos.geometryr   r   Zdjango.contrib.gis.geos.libgeosr	   r
   Z"django.contrib.gis.geos.linestringr   r   Zdjango.contrib.gis.geos.pointr   Zdjango.contrib.gis.geos.polygonr   r   r;   r>   rB   r=   r   r   r   r   Ú<module>   s   L