o
    œeî  ã                   @   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 )z¥
Plot single geometries using Matplotlib.

Note: this module is experimental, and mainly targetting (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   ú@D:\Projects\ConvertPro\env\Lib\site-packages\shapely/plotting.pyÚ_default_ax   s
   

r   c                    sn   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   ©ÚPathc                 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	   Ú
isinstanceÚshapelyZMultiPolygonÚmake_compound_pathÚgeomsr   r   Zexteriorr   Z	interiors)Úpolygonr   r   r   r
      s   ÿ ÿþr
   c                 K   s    ddl m} |t| ƒfi |¤ŽS )až  
    Gets a Matplotlib patch from a (Multi)Polygon.

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

    Parameters
    ----------
    polygon : shapely.Polygon or shapely.MultiPolygon
    **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 targetting (interactive)
    exploration, debugging and illustration purposes.

    Parameters
    ----------
    polygon : shapely.Polygon or shapely.MultiPolygon
    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   *
ÿÿÿ
r2   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 )a]  
    Plot a (Multi)LineString/LinearRing.

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

    Parameters
    ----------
    line : shapely.LineString or shapely.LinearRing
    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 pointes.
    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.   )	r1   r   r/   r)   r'   r   r   Úpathr0   r   r   r   Ú	plot_lineƒ   s0   ÿ ÿÿÿ
r5   Ú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
        `markeredgecolor` 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)   r9   r   r   r1   r   r   r   r.   º   s   
ÿÿÿr.   )NTNNNN)NTNr   )NNr6   )
Ú__doc__Únumpyr   r   r   r
   r    r2   r5   r.   r   r   r   r   Ú<module>   s    	
ù
H7