o
    Zqi                     @   sZ   d Z ddlZddlZdd Zdd Zdd Z							dd
dZdddZdddZ	dS )zPlot single geometries using Matplotlib.

Note: this module is experimental, and mainly targeting (interactive)
exploration, debugging and illustration purposes.

    Nc                  C   s,   dd l m}  |  }|d |d |S )Nr   Tequal)Zmatplotlib.pyplotZpyplotZgcagridZ
set_aspect)Zpltax r   W/home/app/PaddleOCR-VL/.venv_paddleocr/lib/python3.10/site-packages/shapely/plotting.py_default_ax   s
   

r   c                    s   ddl m  ddlm} t| tjr jdd | jD  S || }  j t	
| jjd d d df g fdd| jD R  S )Nr   Path)orientc                 S   s   g | ]}t |qS r   )_path_from_polygon).0Zpolyr   r   r   
<listcomp>   s    z&_path_from_polygon.<locals>.<listcomp>   c                    ,   g | ]} t |jd d d df qS Nr   npasarraycoords)r   ringr   r   r   r   #      , )matplotlib.pathr	   Zshapely.opsr
   
isinstanceshapelyZMultiPolygonmake_compound_pathgeomsr   r   Zexteriorr   Z	interiors)polygonr
   r   r   r   r      s    r   c                 K   s    ddl m} |t| fi |S )a  Get a Matplotlib patch from a (Multi)Polygon.

    Note: this function is experimental, and mainly targeting (interactive)
    exploration, debugging and illustration purposes.

    Parameters
    ----------
    polygon : shapely.Polygon or shapely.MultiPolygon
        The polygon to convert to a Matplotlib Patch.
    **kwargs
        Additional keyword arguments passed to the matplotlib Patch.

    Returns
    -------
    Matplotlib artist (PathPatch)

    r   	PathPatch)matplotlib.patchesr   r   )r   kwargsr   r   r   r   patch_from_polygon'   s   r!   Tc                 K   s   ddl m} |du rt }|du rd}||}|du r(t|}d|d< t|}|du r.|}t| f|||d|}	||	 |  |rPt	| ||d}
|	|
fS |	S )	a  Plot a (Multi)Polygon.

    Note: this function is experimental, and mainly targeting (interactive)
    exploration, debugging and illustration purposes.

    Parameters
    ----------
    polygon : shapely.Polygon or shapely.MultiPolygon
        The polygon to plot.
    ax : matplotlib Axes, default None
        The axes on which to draw the plot. If not specified, will get the
        current active axes or create a new figure.
    add_points : bool, default True
        If True, also plot the coordinates (vertices) as points.
    color : matplotlib color specification
        Color for both the polygon fill (face) and boundary (edge). By default,
        the fill is using an alpha of 0.3. You can specify `facecolor` and
        `edgecolor` separately for greater control.
    facecolor : matplotlib color specification
        Color for the polygon fill.
    edgecolor : matplotlib color specification
        Color for the polygon boundary.
    linewidth : float
        The line width for the polygon boundary.
    **kwargs
        Additional keyword arguments passed to the matplotlib Patch.

    Returns
    -------
    Matplotlib artist (PathPatch), if `add_points` is false.
    A tuple of Matplotlib artists (PathPatch, Line2D), if `add_points` is true.

    r   )colorsNC0g333333?	facecolor	edgecolor	linewidthr   color)
Z
matplotlibr"   r   Zto_rgbalisttupler!   	add_patchautoscale_viewplot_points)r   r   
add_pointsr*   r&   r'   r(   r    r"   patchliner   r   r   plot_polygon>   s2   +

r3   r   c           	         s   ddl m} ddlm  |du rt }|du rd}t| tjr- j fdd| j	D  }n t
| jddddf }||fd	||d
|}|| |  |r_t| ||d} || fS |S )aq  Plot a (Multi)LineString/LinearRing.

    Note: this function is experimental, and mainly targeting (interactive)
    exploration, debugging and illustration purposes.

    Parameters
    ----------
    line : shapely.LineString or shapely.LinearRing
        The line to plot.
    ax : matplotlib Axes, default None
        The axes on which to draw the plot. If not specified, will get the
        current active axes or create a new figure.
    add_points : bool, default True
        If True, also plot the coordinates (vertices) as points.
    color : matplotlib color specification
        Color for the line (edgecolor under the hood) and points.
    linewidth : float, default 2
        The line width for the polygon boundary.
    **kwargs
        Additional keyword arguments passed to the matplotlib Patch.

    Returns
    -------
    Matplotlib artist (PathPatch)

    r   r   r   Nr#   c                    r   r   r   )r   Zmliner   r   r   r      r   zplot_line.<locals>.<listcomp>r   noner%   r)   )r   r   r   r	   r   r   r   ZMultiLineStringr   r   r   r   r   r-   r.   r/   )	r2   r   r0   r*   r(   r    r   pathr1   r   r   r   	plot_line   s0    
r6   oc                 K   sR   |du rt  }t| }|j|dddf |dddf fd||d|\}|S )a  Plot a Point/MultiPoint or the vertices of any other geometry type.

    Parameters
    ----------
    geom : shapely.Geometry
        Any shapely Geometry object, from which all vertices are extracted
        and plotted.
    ax : matplotlib Axes, default None
        The axes on which to draw the plot. If not specified, will get the
        current active axes or create a new figure.
    color : matplotlib color specification
        Color for the filled points. You can use `markeredgecolor` and
        `markerfacecolor` to have different edge and fill colors.
    marker : str, default "o"
        The matplotlib marker for the points.
    **kwargs
        Additional keyword arguments passed to matplotlib `plot` (Line2D).

    Returns
    -------
    Matplotlib artist (Line2D)

    Nr       )Z	linestylemarkerr*   )r   r   Zget_coordinatesZplot)Zgeomr   r*   r:   r    r   r2   r   r   r   r/      s   
r/   )NTNNNN)NTNr   )NNr7   )
__doc__numpyr   r   r   r   r!   r3   r6   r/   r   r   r   r   <module>   s    	

I8