
    (&h                         d Z ddlZddlZddlmZ ddlmZmZ ddl	m
Z
 dgZ G d de          Zeej        j        d<   dS )	z#Line strings and related utilities.    N)deprecate_positional)
JOIN_STYLEBaseGeometry)Point
LineStringc                       e Zd ZdZg ZddZed             ZddZed             Z	 e
g de	          d
ej        dfd            Zdd
ej        dfdZdS )r   a  A geometry type composed of one or more line segments.

    A LineString is a one-dimensional feature and has a non-zero length but
    zero area. It may approximate a curve and need not be straight. A LineString may
    be closed.

    Parameters
    ----------
    coordinates : sequence
        A sequence of (x, y, [,z]) numeric coordinate pairs or triples, or
        an array-like with shape (N, 2) or (N, 3).
        Also can be a sequence of Point objects, or combination of both.

    Examples
    --------
    Create a LineString with two segments

    >>> from shapely import LineString
    >>> a = LineString([[0, 0], [1, 0], [1, 1]])
    >>> a.length
    2.0

    Nc                 D   |t          j        d          S t          |t                    r t	          |          t          u r|S |j        }ntt          |d          rt          j        |          }t          |t          j	                  r%t          j
        |j        t          j                  rnd fd|D             }t          |          dk    rt          j        d          S t          j        |          }t          |t                    st          d          |S )z!Create a new LineString geometry.NzLINESTRING EMPTY	__array__c                 ^    t          | t                    r| j        d         S d | D             S )Nr   c                 ,    g | ]}t          |          S  )float.0cs     V/var/www/html/reinick/venv/lib/python3.11/site-packages/shapely/geometry/linestring.py
<listcomp>z7LineString.__new__.<locals>._coords.<locals>.<listcomp>C   s    444Qa444    )
isinstancer   coords)os    r   _coordsz#LineString.__new__.<locals>._coords?   s4    !!U++ 5 x{*44!4444r   c                 &    g | ]} |          S r   r   )r   r   r   s     r   r   z&LineString.__new__.<locals>.<listcomp>E   s!    ???awwqzz???r   r   z/Invalid values passed to LineString constructor)shapelyfrom_wktr   r   typer   hasattrnpasarrayndarray
issubdtypedtypenumberlenlinestrings
ValueError)selfcoordinatesgeomr   s      @r   __new__zLineString.__new__(   s7    #$6777Z00 	@K  J.."" *0{K00 6 j55+rz22 @r}!298 8 @ 5 5 5 @???;???{q   #$6777";//$
++ 	PNOOOr   c                 0    dt          | j                  dS )z9Return a GeoJSON-like mapping of the LineString geometry.r   )r   r(   )tupler   r'   s    r   __geo_interface__zLineString.__geo_interface__Q   s     %U4;5G5GHHHr         ?c           	          | j         rdS || j        rdnd}|d}d                    d | j        D                       }d| d	d
|z   d| d| d	S )a  Return SVG polyline element for the LineString geometry.

        Parameters
        ----------
        scale_factor : float
            Multiplication factor for the SVG stroke-width.  Default is 1.
        stroke_color : str, optional
            Hex string for stroke 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.8

        z<g />Nz#66cc99z#ff3333g? c                 "    g | ]} d j         | S )z{},{})formatr   s     r   r   z"LineString.svg.<locals>.<listcomp>j   s!    GGGa~w~q1GGGr   z<polyline fill="none" stroke="z" stroke-width="g       @z
" points="z" opacity="z" />)is_emptyis_validjoinr   )r'   scale_factorstroke_coloropacity
pnt_formats        r   svgzLineString.svgV   s     = 	7(,D999L?GXXGG4;GGGHH
<\ < < </< <!< <.5< < <	
r   c                     | j         j        S )a  Separate arrays of X and Y coordinate values.

        Examples
        --------
        >>> from shapely import LineString
        >>> x, y = LineString([(0, 0), (1, 1)]).xy
        >>> list(x)
        [0.0, 1.0]
        >>> list(y)
        [0.0, 1.0]

        )r   xyr-   s    r   r=   zLineString.xyq   s     {~r   	quad_segs
join_stylemitre_limit)category   g      @c                     |dk    rt          d          t          j        |          st          d          t          j        | ||||          S )a  Return a (Multi)LineString at a distance from the object.

        The side, left or right, is determined by the sign of the `distance`
        parameter (negative for right side offset, positive for left side
        offset). The resolution of the buffer around each vertex of the object
        increases by increasing the `quad_segs` keyword parameter.

        The join style is for outside corners between line segments. Accepted
        values are JOIN_STYLE.round (1), JOIN_STYLE.mitre (2), and
        JOIN_STYLE.bevel (3).

        The mitre ratio limit is used for very sharp corners. It is the ratio
        of the distance from the corner to the end of the mitred offset corner.
        When two line segments meet at a sharp angle, a miter join will extend
        far beyond the original geometry. To prevent unreasonable geometry, the
        mitre limit allows controlling the maximum length of the join corner.
        Corners with a ratio which exceed the limit will be beveled.

        Note: the behaviour regarding orientation of the resulting line
        depends on the GEOS version. With GEOS < 3.11, the line retains the
        same direction for a left offset (positive distance) or has reverse
        direction for a right offset (negative distance), and this behaviour
        was documented as such in previous Shapely versions. Starting with
        GEOS 3.11, the function tries to preserve the orientation of the
        original line.
        g        z3Cannot compute offset from zero-length line segmentz$offset_curve distance must be finiter>   )r&   r   isfiniter   offset_curve)r'   distancer?   r@   rA   s        r   rF   zLineString.offset_curve   sj    H #RSSSX&& 	ECDDD#!#
 
 
 	
r   rightc                 J    |dk    r|dz  }|                      ||||          S )a  Alternative method to :meth:`offset_curve` method.

        Older alternative method to the :meth:`offset_curve` method, but uses
        ``resolution`` instead of ``quad_segs`` and a ``side`` keyword
        ('left' or 'right') instead of sign of the distance. This method is
        kept for backwards compatibility for now, but is is recommended to
        use :meth:`offset_curve` instead.
        rH   r>   )rF   )r'   rG   side
resolutionr@   rA   s         r   parallel_offsetzLineString.parallel_offset   s?      7??NH   !#	 ! 
 
 	
r   )N)r/   NN)__name__
__module____qualname____doc__	__slots__r*   propertyr.   r;   r=   r   DeprecationWarningr   roundrF   rM   r   r   r   r   r      s         0 I' ' ' 'R I I XI
 
 
 
6   X. 222=O   #+
 +
 +
 +
` #
 
 
 
 
 
r      )rQ   numpyr   r   shapely.decoratorsr   shapely.geometry.baser   r   shapely.geometry.pointr   __all__r   libregistryr   r   r   <module>r^      s    ) )      3 3 3 3 3 3 : : : : : : : : ( ( ( ( ( (.C
 C
 C
 C
 C
 C
 C
 C
L % Q   r   