o
    h                     @   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 )CoordinateSequencea.  Access to coordinate tuples from the parent geometry's coordinate sequence.

    Examples
    --------
    >>> from shapely.wkt import loads
    >>> g = loads('POINT (0.0 0.0)')
    >>> list(g.coords)
    [(0.0, 0.0)]
    >>> g = loads('POINT M (1 2 4)')
    >>> g.coords[:]
    [(1.0, 2.0, 4.0)]

    c                 C   s
   || _ dS )zInitialize the CoordinateSequence.

        Parameters
        ----------
        coords : array
            The coordinate array.

        N)_coords)selfcoords r   I/var/www/html/scripts/venv/lib/python3.10/site-packages/shapely/coords.py__init__   s   
	zCoordinateSequence.__init__c                 C   s   | j jd S )zReturn the length of the CoordinateSequence.

        Returns
        -------
        int
            The length of the CoordinateSequence.

        r   )r   shape)r   r   r   r   __len__    s   	zCoordinateSequence.__len__c                 c   s,    t |  D ]}t| j|  V  qdS )z$Iterate over the CoordinateSequence.N)ranger   tupler   tolist)r   ir   r   r   __iter__+   s   zCoordinateSequence.__iter__c                 C   s   |   }t|tr+|| dk s||krtd|dk r || }n|}t| j|  S t|trQg }||\}}}t	|||D ]}|
t| j|   q@|S td)a  Get the item at the specified index or slice.

        Parameters
        ----------
        key : int or slice
            The index or slice.

        Returns
        -------
        tuple or list
            The item at the specified index or slice.

        r   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stopstrider   r   r   __getitem__0   s   


zCoordinateSequence.__getitem__Nc                 C   s(   |du rt d|du r| j S | jS )a  Return a copy of the coordinate array.

        Parameters
        ----------
        dtype : data-type, optional
            The desired data-type for the array.
        copy : bool, optional
            If None (default) or True, a copy of the array is always returned.
            If False, a ValueError is raised as this is not supported.

        Returns
        -------
        array
            The coordinate array.

        Raises
        ------
        ValueError
            If `copy=False` is specified.

        Fz7`copy=False` isn't supported. A copy is always created.T)
ValueErrorr   copy)r   dtyper    r   r   r   	__array__P   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'   m   s   zCoordinateSequence.xy)NN)__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    