a
    ßÁdW  ã                   @   sR   d Z ddlZddlZddlmZ ddlmZ dgZG dd„ deƒZ	e	ej
jd< dS )zPoints and related utilities
é    N)ÚDimensionError)ÚBaseGeometryÚPointc                   @   sb   e Zd ZdZg Zdd„ Zedd„ ƒZedd„ ƒZedd	„ ƒZ	ed
d„ ƒZ
ddd„Zedd„ ƒZdS )r   aq  
    A geometry type that represents a single coordinate with
    x,y and possibly z values.

    A point is a zero-dimensional feature and has zero length and zero area.

    Parameters
    ----------
    args : float, or sequence of floats
        The coordinates can either be passed as a single parameter, or as
        individual float values using multiple parameters:

        1) 1 parameter: a sequence or array-like of with 2 or 3 values.
        2) 2 or 3 parameters (float): x, y, and possibly z.

    Attributes
    ----------
    x, y, z : float
        Coordinate values

    Examples
    --------
    Constructing the Point using separate parameters for x and y:

    >>> p = Point(1.0, -1.0)

    Constructing the Point using a list of x, y coordinates:

    >>> p = Point([1.0, -1.0])
    >>> print(p)
    POINT (1 -1)
    >>> p.y
    -1.0
    >>> p.x
    1.0
    c                 G   sà   t |ƒdkrt d¡S t |ƒdkr8tdt |ƒ› d�ƒ‚nRt |ƒdkr||d }t|tƒrZ|S t|dƒslt|ƒ}t 	|¡ 
¡ }nt |¡ 
¡ }|jdkr¢td|› �ƒ‚t |jtj¡sÀd	d
„ |D ƒ}t |¡}t|tƒsÜtdƒ‚|S )Nr   zPOINT EMPTYé   z#Point() takes at most 3 arguments (z given)é   Ú__getitem__z:Point() takes only scalar or 1-size vector arguments, got c                 S   s   g | ]}t |ƒ‘qS © )Úfloat)Ú.0Úcr   r   úY/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/shapely/geometry/point.pyÚ
<listcomp>M   ó    z!Point.__new__.<locals>.<listcomp>z*Invalid values passed to Point constructor)ÚlenÚshapelyZfrom_wktÚ	TypeErrorÚ
isinstancer   ÚhasattrÚlistÚnpZasarrayZsqueezeÚarrayÚndimÚ
ValueErrorZ
issubdtypeZdtypeÚnumberZpoints)ÚselfÚargsÚcoordsZgeomr   r   r   Ú__new__4   s,    



ÿ

zPoint.__new__c                 C   s
   t  | ¡S )zReturn x coordinate.)r   Zget_x©r   r   r   r   ÚxU   s    zPoint.xc                 C   s
   t  | ¡S )zReturn y coordinate.)r   Zget_yr   r   r   r   ÚyZ   s    zPoint.yc                 C   s    t  | ¡stdƒ‚| jd d S )zReturn z coordinate.zThis point has no z coordinate.r   é   )r   Zhas_zr   r   r   r   r   r   Úz_   s    
zPoint.zc                 C   s   d| j d dœS )Nr   r   )ÚtypeZcoordinates)r   r   r   r   r   Ú__geo_interface__g   s    zPoint.__geo_interface__ç      ð?Nc                 C   sF   | j r
dS |du r | jrdnd}|du r,d}d | d| d| ||¡S )	aØ  Returns SVG circle element for the Point geometry.

        Parameters
        ==========
        scale_factor : float
            Multiplication factor for the SVG circle diameter.  Default is 1.
        fill_color : str, optional
            Hex string for fill color. Default is to use "#66cc99" if
            geometry is valid, and "#ff3333" if invalid.
        opacity : float
            Float number between 0 and 1 for color opacity. Default value is 0.6
        z<g />Nz#66cc99z#ff3333g333333ã?ze<circle cx="{0.x}" cy="{0.y}" r="{1}" stroke="#555555" stroke-width="{2}" fill="{3}" opacity="{4}" />g      @r%   )Zis_emptyZis_validÚformat)r   Zscale_factorZ
fill_colorZopacityr   r   r   Úsvgk   s    ÿýz	Point.svgc                 C   s   | j jS )z·Separate arrays of X and Y coordinate values

        Example:
          >>> x, y = Point(0, 0).xy
          >>> list(x)
          [0.0]
          >>> list(y)
          [0.0]
        )r   Úxyr   r   r   r   r(   ƒ   s    zPoint.xy)r%   NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   Úpropertyr   r    r"   r$   r'   r(   r   r   r   r   r      s   %!




)r,   Únumpyr   r   Zshapely.errorsr   Zshapely.geometry.baser   Ú__all__r   ÚlibÚregistryr   r   r   r   Ú<module>   s    