
    \id                         S SK rS SKJrJrJr  S SKJr  S SKJ	r	J
r
  / SQr\
" S5      \	SS j5       5       r\
" S5      \	SS j5       5       r\
" S5      \	S	S
.S j5       5       rg)    N)GeometryGeometryTypelib)	get_parts)multithreading_enabledrequires_geos)coverage_invalid_edgescoverage_is_validcoverage_simplifyz3.12.0c                 x    [         R                  " U 5      n[        R                  " UR	                  SS9U40 UD6$ )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       T/var/www/html/kml_chatgpt/mouzaenv/lib/python3.13/site-packages/shapely/_coverage.pyr
   r
   
   s;    J H%J   !1!1!1!<iR6RR    c                 x    [         R                  " U 5      n[        R                  " UR	                  SS9U40 UD6$ )aK  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   s<    P H%J %%j&6&6S&6&A9WPVWWr   T)simplify_boundaryc                   Sn[        U [        5      (       a  Sn[        R                  " U 5      nUR                  nUR                  5       n[        R                  " U[        R                  " [        R                  5      5      n[        R                  " XaU5      n[        U5      R                  U5      nU(       a  UR                  5       $ U$ )a  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 ''BGGL;;<K &&{?PQJj!))%0Ezz|Lr   )g        )numpyr   shapelyr   r   r   shapely._geometryr   shapely.decoratorsr   r   __all__r
   r	   r    r   r   <module>r/      s     / / ' D
N x&S  &SR x)X  )XX x@D C  Cr   