§
    eÎjJ+  ã                   ó  — d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ g d	¢Zd
„ Z G d„ de¦  «        Zeej        j        d<    G d„ d¦  «        Z G d„ de
¦  «        Zeej        j        d<   dd„ZdS )z*Polygons and their linear ring components.é    N)Ú_geometry_helpers)Úsigned_area)ÚTopologicalError)ÚBaseGeometry)Ú
LineString)ÚPoint)Ú
LinearRingÚPolygonÚorientc                 ó¬   — t          j        | ¦  «        }t          j        |¦  «        }t          j        |¦  «        }|rt          j        ||¦  «        }|S ©N)ÚshapelyÚfrom_wkbÚget_sridr   Úlinestring_to_linearringÚset_srid)ÚwkbÚ
linestringÚsridÚ
linearrings       úh/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/shapely/geometry/polygon.pyÚ_unpickle_linearringr      sR   € ÝÔ! #Ñ&Ô&€JÝÔ˜JÑ'Ô'€DÝ"Ô;¸JÑGÔG€JØð 8ÝÔ% j°$Ñ7Ô7ˆ
ØÐó    c                   óf   — e Zd ZdZg Zdd„Zed„ ¦   «         Zd„ Zed„ ¦   «         Z	ed„ ¦   «         Z
dS )	r	   aª  Geometry type composed of one or more line segments that forms a closed loop.

    A LinearRing is a closed, one-dimensional feature.
    A LinearRing that crosses itself or touches itself at a single point is
    invalid and operations on it may fail.

    Parameters
    ----------
    coordinates : sequence
        A sequence of (x, y [,z]) numeric coordinate pairs or triples, or
        an array-like with shape (N, 2) or (N, 3).
        Also can be a sequence of Point objects.

    Notes
    -----
    Rings are automatically closed. There is no need to specify a final
    coordinate pair identical to the first.

    Examples
    --------
    Construct a square ring.

    >>> from shapely import LinearRing
    >>> ring = LinearRing( ((0, 0), (0, 1), (1 ,1 ), (1 , 0)) )
    >>> ring.is_closed
    True
    >>> list(ring.coords)
    [(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0)]
    >>> ring.length
    4.0

    Nc                 óú  ‡— |€t          j        d¦  «        S t          |t          ¦  «        r6t	          |¦  «        t
          u r|S |j        st          d¦  «        ‚|j        }n¹t          |d¦  «        rt          j        |¦  «        }t          |t          j        ¦  «        r%t          j        |j        t          j        ¦  «        rnVd„ Št          j        ˆfd„|D ¦   «         ¦  «        }t          j        |j        t          j        ¦  «        st#          d¦  «        ‚t%          |¦  «        dk    rt          j        d¦  «        S t          j        |¦  «        }t          |t
          ¦  «        st#          d	¦  «        ‚|S )
z!Create a new LinearRing geometry.NzLINEARRING EMPTYz"An input LineString must be valid.Ú	__array__c                 ó^   — t          | t          ¦  «        r| j        d         S d„ | D ¦   «         S )Nr   c                 ó,   — g | ]}t          |¦  «        ‘ŒS © )Úfloat©Ú.0Úcs     r   ú
<listcomp>z7LinearRing.__new__.<locals>._coords.<locals>.<listcomp>[   s   € Ð4Ð4Ð4¨Q¥ a¡¤Ð4Ð4Ð4r   )Ú
isinstancer   Úcoords)Úos    r   Ú_coordsz#LinearRing.__new__.<locals>._coordsW   s4   € Ý! !¥UÑ+Ô+ð 5Ø œx¨œ{Ð*à4Ð4°!Ð4Ñ4Ô4Ð4r   c                 ó&   •— g | ]} ‰|¦  «        ‘ŒS r   r   )r"   r'   r(   s     €r   r$   z&LinearRing.__new__.<locals>.<listcomp>]   s!   ø€ Ð'HÐ'HÐ'H°q¨¨°©
¬
Ð'HÐ'HÐ'Hr   z&Inconsistent coordinate dimensionalityr   z/Invalid values passed to LinearRing constructor)r   Úfrom_wktr%   r   Útyper	   Úis_validr   r&   ÚhasattrÚnpÚasarrayÚndarrayÚ
issubdtypeÚdtypeÚnumberÚarrayÚ
ValueErrorÚlenÚlinearrings)ÚselfÚcoordinatesÚgeomr(   s      @r   Ú__new__zLinearRing.__new__=   sˆ  ø€ àÐõ Ô#Ð$6Ñ7Ô7Ð7Ý˜¥ZÑ0Ô0ð 	OÝ�KÑ Ô ¥JÐ.Ð.à"Ð"Ø Ô)ð 1Ý&Ð'KÑLÔLÐLð *Ô0��õ �{ KÑ0Ô0ð 6Ý œj¨Ñ5Ô5�Ý˜+¥r¤zÑ2Ô2ð Oµr´}ØÔ!¥2¤9ñ8ô 8ð Oð ð5ð 5ð 5õ !œhÐ'HÐ'HÐ'HÐ'H¸KÐ'HÑ'HÔ'HÑIÔI�Ý”} [Ô%6½¼	ÑBÔBð Oõ %Ð%MÑNÔNÐNåˆ{ÑÔ˜qÒ Ð õ Ô#Ð$6Ñ7Ô7Ð7åÔ" ;Ñ/Ô/ˆÝ˜$¥
Ñ+Ô+ð 	PÝÐNÑOÔOÐOØˆr   c                 ó0   — dt          | j        ¦  «        dœS )z9Return a GeoJSON-like mapping of the LinearRing geometry.r	   ©r+   r9   )Útupler&   ©r8   s    r   Ú__geo_interface__zLinearRing.__geo_interface__m   s   € ð %µU¸4¼;Ñ5GÔ5GÐHÐHÐHr   c                 ó>   — t           t          j        | d¬¦  «        ffS )z¯Pickle support.

        WKB doesn't differentiate between LineString and LinearRing so we
        need to move the coordinate sequence into the correct geometry type
        T)Úinclude_srid)r   r   Úto_wkbr?   s    r   Ú
__reduce__zLinearRing.__reduce__r   s!   € õ %¥w¤~°dÈÐ'NÑ'NÔ'NÐ&PÐQÐQr   c                 óD   — t          t          j        | ¦  «        ¦  «        S )z0True if the ring is oriented counter clock-wise.)Úboolr   Úis_ccwr?   s    r   rG   zLinearRing.is_ccwz   s   € õ •G”N 4Ñ(Ô(Ñ)Ô)Ð)r   c                 óD   — t          t          j        | ¦  «        ¦  «        S )zwTrue if the geometry is simple.

        Simple means that any self-intersections are only at boundary points.
        )rF   r   Ú	is_simpler?   s    r   rI   zLinearRing.is_simple   s   € õ •GÔ% dÑ+Ô+Ñ,Ô,Ð,r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r;   Úpropertyr@   rD   rG   rI   r   r   r   r	   r	      s¡   € € € € € ðð ðB €Ið.ð .ð .ð .ð` ðIð Iñ „XðIðRð Rð Rð ð*ð *ñ „Xð*ð ð-ð -ñ „Xð-ð -ð -r   r	   é   c                   óB   — e Zd ZdZdZdZdZd„ Zd„ Zd„ Z	d„ Z
d„ Zd„ ZdS )	ÚInteriorRingSequenceNr   c                 ó,   — || _         |j        | _        d S r   )Ú_parentÚ_ndim)r8   Úparents     r   Ú__init__zInteriorRingSequence.__init__‘   s   € ØˆŒØ”\ˆŒ
ˆ
ˆ
r   c                 óF   — d| _         |                      ¦   «         | _        | S )Nr   )Ú_indexÚ__len__Ú_lengthr?   s    r   Ú__iter__zInteriorRingSequence.__iter__•   s   € ØˆŒØ—|’|‘~”~ˆŒØˆr   c                 óˆ   — | j         | j        k     r,|                      | j         ¦  «        }| xj         dz  c_         |S t          ‚)Né   )rY   r[   Ú	_get_ringÚStopIteration)r8   Úrings     r   Ú__next__zInteriorRingSequence.__next__š   s?   € ØŒ;˜œÒ%Ð%Ø—>’> $¤+Ñ.Ô.ˆDØˆKŒK˜1ÑˆKŒKØˆKåÐr   c                 ó4   — t          j        | j        ¦  «        S r   )r   Úget_num_interior_ringsrT   r?   s    r   rZ   zInteriorRingSequence.__len__¢   s   € ÝÔ-¨d¬lÑ;Ô;Ð;r   c                 óÐ  — |                       ¦   «         }t          |t          ¦  «        rA||z   dk     s||k    rt          d¦  «        ‚|dk     r||z   }n|}|                      |¦  «        S t          |t
          ¦  «        rYg }|                     |¦  «        \  }}}t          |||¦  «        D ]*}|                     |                      |¦  «        ¦  «         Œ+|S t          d¦  «        ‚)Nr   zindex out of rangezkey must be an index or slice)
rZ   r%   ÚintÚ
IndexErrorr_   ÚsliceÚindicesÚrangeÚappendÚ	TypeError)r8   ÚkeyÚmÚiÚresÚstartÚstopÚstrides           r   Ú__getitem__z InteriorRingSequence.__getitem__¥   sí   € Ø�LŠL‰NŒNˆÝ�c�3ÑÔð 	=Ø�Q‰w˜Š{ˆ{˜c Qšh˜hÝ Ð!5Ñ6Ô6Ð6Ø�QŠwˆwØ˜‘G��à�Ø—>’> !Ñ$Ô$Ð$Ý˜�UÑ#Ô#ð 	=ØˆCØ"%§+¢+¨a¡.¤.ÑˆE�4˜Ý˜5 $¨Ñ/Ô/ð .ð .�Ø—
’
˜4Ÿ>š>¨!Ñ,Ô,Ñ-Ô-Ð-Ð-ØˆJåÐ;Ñ<Ô<Ð<r   c                 ó6   — t          j        | j        |¦  «        S r   )r   Úget_interior_ringrT   )r8   ro   s     r   r_   zInteriorRingSequence._get_ring¸   s   € ÝÔ(¨¬°qÑ9Ô9Ð9r   )rJ   rK   rL   rT   rU   rY   r[   rW   r\   rb   rZ   rt   r_   r   r   r   rR   rR   ‹   s‚   € € € € € Ø€GØ€EØ€FØ€Gð"ð "ð "ðð ð ð
 ð  ð  ð<ð <ð <ð=ð =ð =ð&:ð :ð :ð :ð :r   rR   c                   ó”   — e Zd ZdZg Zdd„Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Z	ed„ ¦   «         Z
dd	„Zed
„ ¦   «         ZdS )r
   ae  A geometry type representing an area that is enclosed by a linear ring.

    A polygon is a two-dimensional feature and has a non-zero area. It may
    have one or more negative-space "holes" which are also bounded by linear
    rings. If any rings cross each other, the feature is invalid and
    operations on it may fail.

    Parameters
    ----------
    shell : sequence
        A sequence of (x, y [,z]) numeric coordinate pairs or triples, or
        an array-like with shape (N, 2) or (N, 3).
        Also can be a sequence of Point objects.
    holes : sequence
        A sequence of objects which satisfy the same requirements as the
        shell parameters above

    Attributes
    ----------
    exterior : LinearRing
        The ring which bounds the positive space of the polygon.
    interiors : sequence
        A sequence of rings which bound all existing holes.

    Examples
    --------
    Create a square polygon with no holes

    >>> from shapely import Polygon
    >>> coords = ((0., 0.), (0., 1.), (1., 1.), (1., 0.), (0., 0.))
    >>> polygon = Polygon(coords)
    >>> polygon.area
    1.0

    Nc                 ó:  — |€t          j        d¦  «        S t          |t          ¦  «        r|S t	          |¦  «        }|�"t          |¦  «        dk    rd}nd„ |D ¦   «         }t          j        ||¬¦  «        }t          |t          ¦  «        st          d¦  «        ‚|S )zCreate a new Polygon geometry.NzPOLYGON EMPTYr   c                 ó,   — g | ]}t          |¦  «        ‘ŒS r   )r	   )r"   ra   s     r   r$   z#Polygon.__new__.<locals>.<listcomp>ô   s    € Ð<Ð<Ð<¨d� DÑ)Ô)Ð<Ð<Ð<r   )Úholesz,Invalid values passed to Polygon constructor)r   r*   r%   r
   r	   r6   Úpolygonsr5   )r8   Úshellrz   r:   s       r   r;   zPolygon.__new__ã   s©   € àˆ=õ Ô# OÑ4Ô4Ð4Ý˜�wÑ'Ô'ð 	&àˆLå˜uÑ%Ô%ˆEàÐÝ�5‰zŒz˜QŠˆà��à<Ð<°eÐ<Ñ<Ô<�åÔ ¨UÐ3Ñ3Ô3ˆÝ˜$¥Ñ(Ô(ð 	MÝÐKÑLÔLÐLØˆr   c                 ó*   — t          j        | ¦  «        S )z(Return the exterior ring of the polygon.)r   Úget_exterior_ringr?   s    r   ÚexteriorzPolygon.exteriorû   s   € õ Ô(¨Ñ.Ô.Ð.r   c                 ó2   — | j         rg S t          | ¦  «        S )z5Return the sequence of interior rings of the polygon.)Úis_emptyrR   r?   s    r   Ú	interiorszPolygon.interiors   s!   € ð Œ=ð 	ØˆIÝ# DÑ)Ô)Ð)r   c                 ó    — t          d¦  «        ‚)zNot implemented for polygons.zCComponent rings have coordinate sequences, but the polygon does not)ÚNotImplementedErrorr?   s    r   r&   zPolygon.coords  s   € õ "ØQñ
ô 
ð 	
r   c                 óð   — | j         t          ¦   «         k    rg }nKt          | j         j        ¦  «        g}| j        D ])}|                     t          |j        ¦  «        ¦  «         Œ*dt          |¦  «        dœS )z6Return a GeoJSON-like mapping of the Polygon geometry.r
   r=   )r   r	   r>   r&   r‚   rk   )r8   r&   Úholes      r   r@   zPolygon.__geo_interface__  su   € ð Œ=�J™LœLÒ(Ð(ØˆFˆFå˜DœMÔ0Ñ1Ô1Ð2ˆFØœð 2ð 2�Ø—’�e D¤KÑ0Ô0Ñ1Ô1Ð1Ð1Ø!µ%¸±-´-Ð@Ð@Ð@r   ç      ð?c           	      óî   — | j         rdS |€| j        rdnd}|€d}d„ | j        j        D ¦   «         g}d„ | j        D ¦   «         }d                     d	„ ||z   D ¦   «         ¦  «        }d
|› dd|z  › d|› d|› d�	S )aÕ  Return SVG path element for the Polygon geometry.

        Parameters
        ----------
        scale_factor : float
            Multiplication factor for the SVG stroke-width.  Default is 1.
        fill_color : str, optional
            Hex string for fill color. Default is to use "#66cc99" if
            geometry is valid, and "#ff3333" if invalid.
        opacity : float
            Float number between 0 and 1 for color opacity. Default value is 0.6

        z<g />Nz#66cc99z#ff3333g333333ã?c                 ó"   — g | ]} d j         |Ž ‘ŒS ©z{},{}©Úformatr!   s     r   r$   zPolygon.svg.<locals>.<listcomp>-  s!   € ÐMÐMÐM°1˜N˜GœN¨AÐ.ÐMÐMÐMr   c                 ó0   — g | ]}d „ |j         D ¦   «         ‘ŒS )c                 ó"   — g | ]} d j         |Ž ‘ŒS rŠ   r‹   r!   s     r   r$   z*Polygon.svg.<locals>.<listcomp>.<listcomp>/  s!   € Ð9Ð9Ð9 Aˆ^ˆWŒ^˜QÐÐ9Ð9Ð9r   )r&   )r"   Úinteriors     r   r$   zPolygon.svg.<locals>.<listcomp>.  s6   € ð 
ð 
ð 
Ø>FÐ9Ð9¨¬Ð9Ñ9Ô9ð
ð 
ð 
r   ú c           
      ó|   — g | ]9}d                       |d         d                     |dd…         ¦  «        ¦  «        ‘Œ:S )zM {} L {} zr   z L r^   N)rŒ   Újoin)r"   r&   s     r   r$   zPolygon.svg.<locals>.<listcomp>2  sP   € ð ð ð àð ×$Ò$ V¨A¤Y°·
²
¸6À!À"À"¼:Ñ0FÔ0FÑGÔGðð ð r   z <path fill-rule="evenodd" fill="z!" stroke="#555555" stroke-width="g       @z" opacity="z" d="z" />)r�   r,   r   r&   r‚   r’   )r8   Úscale_factorÚ
fill_colorÚopacityÚexterior_coordsÚinterior_coordsÚpaths          r   ÚsvgzPolygon.svg  sõ   € ð Œ=ð 	Ø�7ØÐØ&*¤mÐB˜˜¸ˆJØˆ?ØˆGØMÐM¸¼Ô8LÐMÑMÔMÐNˆð
ð 
ØJNÌ.ð
ñ 
ô 
ˆð �xŠxðð à-°Ñ?ðñ ô ñ
ô 
ˆðU¨zð Uð UØ  <Ñ/ðUð UØ<CðUð UØJNðUð Uð Uð	
r   c                 ó0   —  | ||f||f||f||fg¦  «        S )z,Construct a `Polygon()` from spatial bounds.r   )ÚclsÚxminÚyminÚxmaxÚymaxs        r   Úfrom_boundszPolygon.from_bounds<  s-   € ð ˆs�T˜4�L 4¨ ,°°t°¸tÀT¸lÐKÑLÔLÐLr   )NN)r‡   NN)rJ   rK   rL   rM   rN   r;   rO   r   r‚   r&   r@   r™   Úclassmethodr    r   r   r   r
   r
   ¼   sÞ   € € € € € ð"ð "ðH €Iðð ð ð ð0 ð/ð /ñ „Xð/ð ð*ð *ñ „Xð*ð ð
ð 
ñ „Xð
ð ðAð Añ „XðAð!
ð !
ð !
ð !
ðF ðMð Mñ „[ðMð Mð Mr   r
   é   r‡   c                 ó6   — t          j        | |dk     ¬¦  «        S )aî  Return an oriented polygon.

    It is recommended to use :func:`shapely.orient_polygons` instead.

    Parameters
    ----------
    polygon : shapely.Polygon
    sign : float, default 1.
        The sign of the result's signed area.
        A non-negative sign means that the coordinates of the geometry's exterior
        rings will be oriented counter-clockwise.

    Returns
    -------
    Geometry or array_like

    Refer to :func:`shapely.orient_polygons` for full documentation.

    g        )Úexterior_cw)r   Úorient_polygons)ÚpolygonÚsigns     r   r   r   E  s   € õ( Ô" 7¸¸sº
ÐCÑCÔCÐCr   )r‡   )rM   Únumpyr.   r   r   Úshapely.algorithms.cgar   Úshapely.errorsr   Úshapely.geometry.baser   Úshapely.geometry.linestringr   Úshapely.geometry.pointr   Ú__all__r   r	   ÚlibÚregistryrR   r
   r   r   r   r   ú<module>r±      sƒ  ðØ 0Ð 0à Ð Ð Ð à €€€Ø %Ð %Ð %Ð %Ð %Ð %Ø .Ð .Ð .Ð .Ð .Ð .Ø +Ð +Ð +Ð +Ð +Ð +Ø .Ð .Ð .Ð .Ð .Ð .Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø (Ð (Ð (Ð (Ð (Ð (à
-Ð
-Ð
-€ðð ð ðl-ð l-ð l-ð l-ð l-�ñ l-ô l-ð l-ð^ %€„Ô �QÑ ð.:ð .:ð .:ð .:ð .:ñ .:ô .:ð .:ðbCMð CMð CMð CMð CMˆlñ CMô CMð CMðL "€„Ô �QÑ ðDð Dð Dð Dð Dð Dr   