
    (&hd                         d dl Zd dlmZmZmZ d dlmZ d dlm	Z	m
Z
 g dZ e
d          e	dd                        Z e
d          e	dd	                        Z e
d          e	d
dd                        ZdS )    N)GeometryGeometryTypelib)	get_parts)multithreading_enabledrequires_geos)coverage_invalid_edgescoverage_is_validcoverage_simplifyz3.12.0        c                 x    t          j        |           }t          j        |                    d          |fi |S )a  Verify if a coverage is valid.

    The coverage is represented by an array of polygonal geometries with
    exactly matching edges and no overlap.

    A valid coverage may contain holes (regions of no coverage). However,
    sometimes it might be desirable to detect narrow gaps as invalidities in
    the coverage. The `gap_width` parameter allows to specify the maximum
    width of gaps to detect. When gaps are detected, this function will
    return False and the `coverage_invalid_edges` function can be used to
    find the edges of those gaps.

    Geometries that are not Polygon or MultiPolygon are ignored.

    .. versionadded:: 2.1.0

    Parameters
    ----------
    geometry : array_like
        Array of geometries to verify.
    gap_width : float, default 0.0
        The maximum width of gaps to detect.
    **kwargs
        See :ref:`NumPy ufunc docs <ufuncs.kwargs>` for other keyword arguments.

    Returns
    -------
    bool

    See Also
    --------
    coverage_invalid_edges, coverage_simplify

    Korder)npasarrayr   r
   ravelgeometry	gap_widthkwargs
geometriess       L/var/www/html/reinick/venv/lib/python3.11/site-packages/shapely/_coverage.pyr
   r
   
   sB    J H%%J  !1!1!1!<!<iRR6RRR    c                 x    t          j        |           }t          j        |                    d          |fi |S )a  Verify if a coverage is valid and return invalid edges.

    This functions returns linear indicators showing the location of invalid
    edges (if any) in each polygon in the input array.

    The coverage is represented by an array of polygonal geometries with
    exactly matching edges and no overlap.

    A valid coverage may contain holes (regions of no coverage). However,
    sometimes it might be desirable to detect narrow gaps as invalidities in
    the coverage. The `gap_width` parameter allows to specify the maximum
    width of gaps to detect. When gaps are detected, the `coverage_is_valid`
    function will return False and this function can be used to find the
    edges of those gaps.

    Geometries that are not Polygon or MultiPolygon are ignored.

    .. versionadded:: 2.1.0

    Parameters
    ----------
    geometry : array_like
        Array of geometries to verify.
    gap_width : float, default 0.0
        The maximum width of gaps to detect.
    **kwargs
        See :ref:`NumPy ufunc docs <ufuncs.kwargs>` for other keyword arguments.

    Returns
    -------
    numpy.ndarray | shapely.Geometry

    See Also
    --------
    coverage_is_valid, coverage_simplify

    r   r   )r   r   r   r	   r   r   s       r   r	   r	   5   sC    P H%%J %j&6&6S&6&A&A9WWPVWWWr   T)simplify_boundaryc                   d}t          | t                    rd}t          j        |           }|j        }|                                }t          j        |t          j        t          j
                            }t          j        |||          }t          |                              |          }|r|                                S |S )aN  Return a simplified version of an input geometry using coverage simplification.

    Assumes that the geometry forms a polygonal coverage. Under this assumption, the
    function simplifies the edges using the Visvalingam-Whyatt algorithm, while
    preserving a valid coverage. In the most simplified case, polygons are reduced to
    triangles.

    A collection of valid polygons is considered a coverage if the polygons are:

    * **Non-overlapping** - polygons do not overlap (their interiors do not intersect)
    * **Edge-Matched** - vertices along shared edges are identical

    The function allows simplification of all edges including the outer boundaries of
    the coverage or simplification of only the inner (shared) edges.

    If there are other geometry types than Polygons or MultiPolygons present,
    the function will raise an error.

    If the geometry is polygonal but does not form a valid coverage due to overlaps,
    it will be simplified but it may result in invalid topology.

    .. versionadded:: 2.1.0

    Parameters
    ----------
    geometry : Geometry or array_like
    tolerance : float or array_like
        The degree of simplification roughly equal to the square root of the area
        of triangles that will be removed.
    simplify_boundary : bool, optional
        By default (True), simplifies both internal edges of the coverage as well
        as its boundary. If set to False, only simplifies internal edges.

    Returns
    -------
    numpy.ndarray | shapely.Geometry

    See Also
    --------
    coverage_is_valid, coverage_invalid_edges

    Examples
    --------
    >>> import shapely
    >>> from shapely import Polygon
    >>> poly = Polygon([(0, 0), (20, 0), (20, 10), (10, 5), (0, 10), (0, 0)])
    >>> shapely.coverage_simplify(poly, tolerance=2)
    <POLYGON ((0 0, 20 0, 20 10, 10 5, 0 10, 0 0))>
    FT)
isinstancer   r   r   shaper   r   create_collectionintcr   GEOMETRYCOLLECTIONr   r   reshapeitem)	r   	tolerancer   scalarr   r   collections
simplifiedpartss	            r   r   r   c   s    h F(H%% H%%JE!!##J 'BGL;<< K &{I?PQQJj!!))%00E zz||Lr   )r   )numpyr   shapelyr   r   r   shapely._geometryr   shapely.decoratorsr   r   __all__r
   r	   r    r   r   <module>r0      s)       / / / / / / / / / / ' ' ' ' ' ' D D D D D D D D
N
N
N x&S &S &S  &SR x)X )X )X  )XX x@D C C C C  C C Cr   