a
    ŠJ5d"  ã                   @   s"   d Z ddlmZ G dd„ dƒZdS )zCoordinate sequence utilities
é    )Úarrayc                   @   sF   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zddd„Ze	dd„ ƒZ
d
S )ÚCoordinateSequencezî
    Iterative access to coordinate tuples from the parent geometry's coordinate
    sequence.

    Example:

      >>> from shapely.wkt import loads
      >>> g = loads('POINT (0.0 0.0)')
      >>> list(g.coords)
      [(0.0, 0.0)]

    c                 C   s
   || _ d S ©N©Ú_coords)ÚselfZcoords© r   úJ/var/www/html/django/DPS/env/lib/python3.9/site-packages/shapely/coords.pyÚ__init__   s    zCoordinateSequence.__init__c                 C   s   | j jd S )Nr   )r   Úshape)r   r   r   r	   Ú__len__   s    zCoordinateSequence.__len__c                 c   s*   t |  ¡ ƒD ]}t| j|  ¡ ƒV  qd S r   )Úranger   Útupler   Útolist)r   Úir   r   r	   Ú__iter__   s    zCoordinateSequence.__iter__c                 C   s®   |   ¡ }t|tƒrV|| dk s&||kr.tdƒ‚|dk r@|| }n|}t| j|  ¡ ƒS t|tƒr¢g }| |¡\}}}t	|||ƒD ]}| 
t| j|  ¡ ƒ¡ q€|S tdƒ‚d S )Nr   zindex out of rangezkey must be an index or slice)r   Ú
isinstanceÚintÚ
IndexErrorr   r   r   ÚsliceÚindicesr   ÚappendÚ	TypeError)r   ÚkeyÚmr   ÚresÚstartÚstopZstrider   r   r	   Ú__getitem__   s    


zCoordinateSequence.__getitem__Nc                 C   s   | j S r   r   )r   Zdtyper   r   r	   Ú	__array__1   s    zCoordinateSequence.__array__c                 C   sX   |   ¡ }tdƒ}tdƒ}t|ƒD ].}| j|  ¡ }| |d ¡ | |d ¡ q ||fS )zX and Y arraysÚdr   é   )r   r   r   r   r   r   )r   r   ÚxÚyr   Úxyr   r   r	   r$   4   s    zCoordinateSequence.xy)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   r   r   r   r   Úpropertyr$   r   r   r   r	   r      s   
r   N)r(   r   r   r   r   r   r	   Ú<module>   s   