§
    eÎj~)  ã                   óô   — d Z ddlZddlZddlmZ ddlmZ g d¢Zed„ ¦   «         Z	ed„ ¦   «         Z
ed„ ¦   «         Zd	„ Zed
„ ¦   «         Zedd„¦   «         Zedd„¦   «         Zed„ ¦   «         Zed„ ¦   «         ZdS )z+Methods for measuring (between) geometries.é    N)Úlib)Úmultithreading_enabled)	ÚareaÚboundsÚdistanceÚfrechet_distanceÚhausdorff_distanceÚlengthÚminimum_bounding_radiusÚminimum_clearanceÚtotal_boundsc                 ó&   — t          j        | fi |¤ŽS )a¼  Compute the area of a (multi)polygon.

    Parameters
    ----------
    geometry : Geometry or array_like
        Geometry or geometries for which to compute the area.
    **kwargs
        See :ref:`NumPy ufunc docs <ufuncs.kwargs>` for other keyword arguments.

    Examples
    --------
    >>> import shapely
    >>> from shapely import MultiPolygon, Polygon
    >>> polygon = Polygon([(0, 0), (0, 10), (10, 10), (10, 0), (0, 0)])
    >>> shapely.area(polygon)
    100.0
    >>> polygon2 = Polygon([(10, 10), (10, 20), (20, 20), (20, 10), (10, 10)])
    >>> shapely.area(MultiPolygon([polygon, polygon2]))
    200.0
    >>> shapely.area(Polygon())
    0.0
    >>> shapely.area(None)
    nan

    )r   r   ©ÚgeometryÚkwargss     úc/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/shapely/measurement.pyr   r      s   € õ6 Œ8�HÐ'Ð' Ð'Ð'Ð'ó    c                 ó(   — t          j        | |fi |¤ŽS )aØ  Compute the Cartesian distance between two geometries.

    Parameters
    ----------
    a, b : Geometry or array_like
        Geometry or geometries to compute the distance between.
    **kwargs
        See :ref:`NumPy ufunc docs <ufuncs.kwargs>` for other keyword arguments.

    Examples
    --------
    >>> import shapely
    >>> from shapely import LineString, Point, Polygon
    >>> point = Point(0, 0)
    >>> shapely.distance(Point(10, 0), point)
    10.0
    >>> shapely.distance(LineString([(1, 1), (1, -1)]), point)
    1.0
    >>> shapely.distance(Polygon([(3, 0), (5, 0), (5, 5), (3, 5), (3, 0)]), point)
    3.0
    >>> shapely.distance(Point(), point)
    nan
    >>> shapely.distance(None, point)
    nan

    )r   r   )ÚaÚbr   s      r   r   r   5   s   € õ8 Œ<˜˜1Ð'Ð' Ð'Ð'Ð'r   c                 ó&   — t          j        | fi |¤ŽS )aõ  Compute the bounds (extent) of a geometry.

    For each geometry these 4 numbers are returned: min x, min y, max x, max y.

    Parameters
    ----------
    geometry : Geometry or array_like
        Geometry or geometries for which to compute the bounds.
    **kwargs
        See :ref:`NumPy ufunc docs <ufuncs.kwargs>` for other keyword arguments.

    Examples
    --------
    >>> import shapely
    >>> from shapely import LineString, Point, Polygon
    >>> shapely.bounds(Point(2, 3)).tolist()
    [2.0, 3.0, 2.0, 3.0]
    >>> shapely.bounds(LineString([(0, 0), (0, 2), (3, 2)])).tolist()
    [0.0, 0.0, 3.0, 2.0]
    >>> shapely.bounds(Polygon()).tolist()
    [nan, nan, nan, nan]
    >>> shapely.bounds(None).tolist()
    [nan, nan, nan, nan]

    )r   r   r   s     r   r   r   T   s   € õ6 Œ:�hÐ)Ð) &Ð)Ð)Ð)r   c           
      ó´  — t          | fi |¤Ž}|j        dk    r|S t          j        ¦   «         5  t          j        dt
          ¦  «         t          j        t          j        |d         ¦  «        t          j        |d         ¦  «        t          j	        |d         ¦  «        t          j	        |d         ¦  «        g¦  «        cddd¦  «         S # 1 swxY w Y   dS )a  Compute the total bounds (extent) of the geometry.

    Parameters
    ----------
    geometry : Geometry or array_like
        Geometry or geometries for which to compute the total bounds.
    **kwargs
        See :ref:`NumPy ufunc docs <ufuncs.kwargs>` for other keyword arguments.

    Returns
    -------
    numpy ndarray of [xmin, ymin, xmax, ymax]

    Examples
    --------
    >>> import shapely
    >>> from shapely import LineString, Point, Polygon
    >>> shapely.total_bounds(Point(2, 3)).tolist()
    [2.0, 3.0, 2.0, 3.0]
    >>> shapely.total_bounds([Point(2, 3), Point(4, 5)]).tolist()
    [2.0, 3.0, 4.0, 5.0]
    >>> shapely.total_bounds([
    ...     LineString([(0, 1), (0, 2), (3, 2)]),
    ...     LineString([(4, 4), (4, 6), (6, 7)])
    ... ]).tolist()
    [0.0, 1.0, 6.0, 7.0]
    >>> shapely.total_bounds(Polygon()).tolist()
    [nan, nan, nan, nan]
    >>> shapely.total_bounds([Polygon(), Point(2, 3)]).tolist()
    [2.0, 3.0, 2.0, 3.0]
    >>> shapely.total_bounds(None).tolist()
    [nan, nan, nan, nan]

    é   Úignore).r   ).r   ).é   ).é   N)
r   ÚndimÚwarningsÚcatch_warningsÚsimplefilterÚRuntimeWarningÚnpÚarrayÚnanminÚnanmax)r   r   r   s      r   r   r   r   s  € õF 	ˆxÐ"Ð"˜6Ð"Ð"€AØ„v�‚{€{Øˆå	Ô	 Ñ	"Ô	"ð 

ð 

åÔ˜h­Ñ7Ô7Ð7ÝŒxå”	˜!˜Fœ)Ñ$Ô$Ý”	˜!˜Fœ)Ñ$Ô$Ý”	˜!˜Fœ)Ñ$Ô$Ý”	˜!˜Fœ)Ñ$Ô$ð	ñ
ô 
ð

ð 

ð 

ð 

ñ 

ô 

ð 

ð 

ð 

ð 

ð 

ð 

øøøð 

ð 

ð 

ð 

ð 

ð 

s   ®BCÃCÃCc                 ó&   — t          j        | fi |¤ŽS )a  Compute the length of a (multi)linestring or polygon perimeter.

    Parameters
    ----------
    geometry : Geometry or array_like
        Geometry or geometries for which to compute the length.
    **kwargs
        See :ref:`NumPy ufunc docs <ufuncs.kwargs>` for other keyword arguments.

    Examples
    --------
    >>> import shapely
    >>> from shapely import LineString, MultiLineString, Polygon
    >>> shapely.length(LineString([(0, 0), (0, 2), (3, 2)]))
    5.0
    >>> shapely.length(MultiLineString([
    ...     LineString([(0, 0), (1, 0)]),
    ...     LineString([(1, 0), (2, 0)])
    ... ]))
    2.0
    >>> shapely.length(Polygon([(0, 0), (0, 10), (10, 10), (10, 0), (0, 0)]))
    40.0
    >>> shapely.length(LineString())
    0.0
    >>> shapely.length(None)
    nan

    )r   r
   r   s     r   r
   r
   ¦   s   € õ< Œ:�hÐ)Ð) &Ð)Ð)Ð)r   c                 óT   — |€t          j        | |fi |¤ŽS t          j        | ||fi |¤ŽS )aá  Compute the discrete Hausdorff distance between two geometries.

    The Hausdorff distance is a measure of similarity: it is the greatest
    distance between any point in A and the closest point in B. The discrete
    distance is an approximation of this metric: only vertices are considered.
    The parameter 'densify' makes this approximation less coarse by splitting
    the line segments between vertices before computing the distance.

    Parameters
    ----------
    a, b : Geometry or array_like
        Geometry or geometries to compute the distance between.
    densify : float or array_like, optional
        The value of densify is required to be between 0 and 1.
    **kwargs
        See :ref:`NumPy ufunc docs <ufuncs.kwargs>` for other keyword arguments.

    Examples
    --------
    >>> import shapely
    >>> from shapely import LineString
    >>> line1 = LineString([(130, 0), (0, 0), (0, 150)])
    >>> line2 = LineString([(10, 10), (10, 150), (130, 10)])
    >>> shapely.hausdorff_distance(line1, line2)
    14.142135623730951
    >>> shapely.hausdorff_distance(line1, line2, densify=0.5)
    70.0
    >>> shapely.hausdorff_distance(line1, LineString())
    nan
    >>> shapely.hausdorff_distance(line1, None)
    nan

    )r   r	   Úhausdorff_distance_densify©r   r   Údensifyr   s       r   r	   r	   Ç   sB   € ðF €ÝÔ% a¨Ð5Ð5¨fÐ5Ð5Ð5åÔ-¨a°°GÐFÐF¸vÐFÐFÐFr   c                 óT   — |€t          j        | |fi |¤ŽS t          j        | ||fi |¤ŽS )u¨  Compute the discrete FrÃ©chet distance between two geometries.

    The FrÃ©chet distance is a measure of similarity: it is the greatest
    distance between any point in A and the closest point in B. The discrete
    distance is an approximation of this metric: only vertices are considered.
    The parameter 'densify' makes this approximation less coarse by splitting
    the line segments between vertices before computing the distance.

    FrÃ©chet distance sweep continuously along their respective curves
    and the direction of curves is significant. This makes it a better measure
    of similarity than Hausdorff distance for curve or surface matching.

    Parameters
    ----------
    a, b : Geometry or array_like
        Geometry or geometries to compute the distance between.
    densify : float or array_like, optional
        The value of densify is required to be between 0 and 1.
    **kwargs
        See :ref:`NumPy ufunc docs <ufuncs.kwargs>` for other keyword arguments.

    Examples
    --------
    >>> import shapely
    >>> from shapely import LineString
    >>> line1 = LineString([(0, 0), (100, 0)])
    >>> line2 = LineString([(0, 0), (50, 50), (100, 0)])
    >>> shapely.frechet_distance(line1, line2)
    70.71067811865476
    >>> shapely.frechet_distance(line1, line2, densify=0.5)
    50.0
    >>> shapely.frechet_distance(line1, LineString())
    nan
    >>> shapely.frechet_distance(line1, None)
    nan

    )r   r   Úfrechet_distance_densifyr)   s       r   r   r   ð   sB   € ðN €ÝÔ# A qÐ3Ð3¨FÐ3Ð3Ð3ÝÔ'¨¨1¨gÐ@Ð@¸Ð@Ð@Ð@r   c                 ó&   — t          j        | fi |¤ŽS )a­  Compute the Minimum Clearance distance.

    A geometry's "minimum clearance" is the smallest distance by which
    a vertex of the geometry could be moved to produce an invalid geometry.

    If no minimum clearance exists for a geometry (for example, a single
    point, or an empty geometry), infinity is returned.

    Parameters
    ----------
    geometry : Geometry or array_like
        Geometry or geometries for which to compute the minimum clearance.
    **kwargs
        See :ref:`NumPy ufunc docs <ufuncs.kwargs>` for other keyword arguments.

    Examples
    --------
    >>> import shapely
    >>> from shapely import Polygon
    >>> polygon = Polygon([(0, 0), (0, 10), (5, 6), (10, 10), (10, 0), (5, 4), (0, 0)])
    >>> shapely.minimum_clearance(polygon)
    2.0
    >>> shapely.minimum_clearance(Polygon())
    inf
    >>> shapely.minimum_clearance(None)
    nan

    See Also
    --------
    minimum_clearance_line

    )r   r   r   s     r   r   r     s   € õD Ô  Ð4Ð4¨VÐ4Ð4Ð4r   c                 ó&   — t          j        | fi |¤ŽS )a�  Compute the radius of the minimum bounding circle of an input geometry.

    Parameters
    ----------
    geometry : Geometry or array_like
        Geometry or geometries for which to compute the minimum bounding radius.
    **kwargs
        See :ref:`NumPy ufunc docs <ufuncs.kwargs>` for other keyword arguments.


    Examples
    --------
    >>> import shapely
    >>> from shapely import GeometryCollection, LineString, MultiPoint, Point, Polygon
    >>> shapely.minimum_bounding_radius(
    ...     Polygon([(0, 5), (5, 10), (10, 5), (5, 0), (0, 5)])
    ... )
    5.0
    >>> shapely.minimum_bounding_radius(LineString([(1, 1), (1, 10)]))
    4.5
    >>> shapely.minimum_bounding_radius(MultiPoint([(2, 2), (4, 2)]))
    1.0
    >>> shapely.minimum_bounding_radius(Point(0, 1))
    0.0
    >>> shapely.minimum_bounding_radius(GeometryCollection())
    0.0

    See Also
    --------
    minimum_bounding_circle

    )r   r   r   s     r   r   r   A  s   € õD Ô& xÐ:Ð:°6Ð:Ð:Ð:r   )N)Ú__doc__r   Únumpyr"   Úshapelyr   Úshapely.decoratorsr   Ú__all__r   r   r   r   r
   r	   r   r   r   © r   r   ú<module>r5      se  ðØ 1Ð 1à €€€à Ð Ð Ð à Ð Ð Ð Ð Ð Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5ð
ð 
ð 
€ð ð(ð (ñ Ôð(ð: ð(ð (ñ Ôð(ð< ð*ð *ñ Ôð*ð:1
ð 1
ð 1
ðh ð*ð *ñ Ôð*ð@ ð%Gð %Gð %Gñ Ôð%GðP ð(Að (Að (Añ Ôð(AðV ð!5ð !5ñ Ôð!5ðH ð!;ð !;ñ Ôð!;ð !;ð !;r   