Ë
    ~ìqjJ+  ã                   ó  — 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y)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       úT/var/www/html/truck-me/venv/lib/python3.12/site-packages/shapely/geometry/polygon.pyÚ_unpickle_linearringr      sM   € Ü×!Ñ! #Ó&€JÜ×Ñ˜JÓ'€DÜ"×;Ñ;¸JÓG€JÙÜ×%Ñ% j°$Ó7ˆ
ØÐó    c                   óR   — e Zd ZdZg Zdd„Zed„ «       Zd„ Zed„ «       Z	ed„ «       Z
y)	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        «      r7t	        |«      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ned„ }t        j                   |D �cg c]
  } ||«      ‘Œ c}«      }t        j                  |j                  t        j                  «      st#        d«      ‚t%        |«      dk(  rt        j                  d«      S t        j&                  |«      }t        |t
        «      st#        d«      ‚|S c c}w )z!Create a new LinearRing geometry.zLINEARRING EMPTYz"An input LineString must be valid.Ú	__array__c                 ó|   — t        | t        «      r| j                  d   S | D �cg c]  }t        |«      ‘Œ c}S c c}w ©Nr   )Ú
isinstancer   ÚcoordsÚfloat)ÚoÚcs     r   Ú_coordsz#LinearRing.__new__.<locals>._coordsW   s2   € Ü! !¤UÔ+Ø Ÿx™x¨™{Ð*à23Ö4¨Q¤ a¥Ò4Ð4ùÒ4s   ¤9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Úcoordinatesr$   r"   Úgeoms        r   Ú__new__zLinearRing.__new__=   s>  € àÐô ×#Ñ#Ð$6Ó7Ð7Ü˜¤ZÔ0Ü�KÓ ¤JÑ.à"Ð"Ø ×)Ò)Ü&Ð'KÓLÐLð *×0Ñ0‘ô �{ KÔ0Ü Ÿj™j¨Ó5�Ü˜+¤r§z¡zÔ2´r·}±}Ø×!Ñ!¤2§9¡9ô8ð ò5ô !Ÿh™h¸KÖ'H°q©°­
Ò'HÓI�Ü—}‘} [×%6Ñ%6¼¿	¹	ÔBô %Ð%MÓNÐNäˆ{Ó˜qÒ ô ×#Ñ#Ð$6Ó7Ð7ä×"Ñ" ;Ó/ˆÜ˜$¤
Ô+ÜÐNÓOÐOØˆùò (Is   ÃFc                 ó2   — dt        | j                  «      dœS )z9Return a GeoJSON-like mapping of the LinearRing geometry.r	   ©r&   r4   )Útupler    ©r3   s    r   Ú__geo_interface__zLinearRing.__geo_interface__m   s   € ð %´U¸4¿;¹;Ó5GÑ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Ð&PÐQÐQr   c                 ó>   — t        t        j                  | «      «      S )z0True if the ring is oriented counter clock-wise.)Úboolr   Úis_ccwr:   s    r   rB   zLinearRing.is_ccwz   s   € ô ”G—N‘N 4Ó(Ó)Ð)r   c                 ó>   — t        t        j                  | «      «      S )zwTrue if the geometry is simple.

        Simple means that any self-intersections are only at boundary points.
        )rA   r   Ú	is_simpler:   s    r   rD   zLinearRing.is_simple   s   € ô ”G×%Ñ% dÓ+Ó,Ð,r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r6   Úpropertyr;   r?   rB   rD   © r   r   r	   r	      sY   „ ñðB €Ió.ð` ñIó ðIòRð ñ*ó ð*ð ñ-ó ñ-r   r	   é   c                   ó@   — e Zd ZdZdZdZdZd„ Zd„ Zd„ Z	d„ Z
d„ Zd„ Zy)	ÚInteriorRingSequenceNr   c                 ó4   — || _         |j                  | _        y r   )Ú_parentÚ_ndim)r3   Úparents     r   Ú__init__zInteriorRingSequence.__init__‘   s   € ØˆŒØ—\‘\ˆ�
r   c                 ó>   — d| _         | j                  «       | _        | S r   )Ú_indexÚ__len__Ú_lengthr:   s    r   Ú__iter__zInteriorRingSequence.__iter__•   s   € ØˆŒØ—|‘|“~ˆŒØˆr   c                 ó¤   — | j                   | j                  k  r2| j                  | j                   «      }| xj                   dz  c_         |S t        ‚)Né   )rU   rW   Ú	_get_ringÚStopIteration)r3   Úrings     r   Ú__next__zInteriorRingSequence.__next__š   s=   € Ø�;‰;˜Ÿ™Ò%Ø—>‘> $§+¡+Ó.ˆDØ�KŠK˜1Ñ�KØˆKäÐr   c                 ó@   — t        j                  | j                  «      S r   )r   Úget_num_interior_ringsrP   r:   s    r   rV   zInteriorRingSequence.__len__¢   s   € Ü×-Ñ-¨d¯l©lÓ;Ð;r   c                 óz  — | j                  «       }t        |t        «      r6||z   dk  s||k\  rt        d«      ‚|dk  r||z   }n|}| j	                  |«      S t        |t
        «      rKg }|j                  |«      \  }}}t        |||«      D ]"  }|j                  | j	                  |«      «       Œ$ |S t        d«      ‚)Nr   zindex out of rangezkey must be an index or slice)
rV   r   ÚintÚ
IndexErrorr[   ÚsliceÚindicesÚrangeÚappendÚ	TypeError)r3   ÚkeyÚmÚiÚresÚstartÚstopÚstrides           r   Ú__getitem__z InteriorRingSequence.__getitem__¥   s¹   € Ø�L‰L‹NˆÜ�cœ3ÔØ�Q‰w˜Š{˜c QšhÜ Ð!5Ó6Ð6Ø�QŠwØ˜‘G‘à�Ø—>‘> !Ó$Ð$Ü˜œUÔ#ØˆCØ"%§+¡+¨a£.ÑˆE�4˜Ü˜5 $¨Ó/ò .�Ø—
‘
˜4Ÿ>™>¨!Ó,Õ-ð.àˆJäÐ;Ó<Ð<r   c                 óB   — t        j                  | j                  |«      S r   )r   Úget_interior_ringrP   )r3   rk   s     r   r[   zInteriorRingSequence._get_ring¸   s   € Ü×(Ñ(¨¯©°qÓ9Ð9r   )rE   rF   rG   rP   rQ   rU   rW   rS   rX   r^   rV   rp   r[   rK   r   r   rN   rN   ‹   s4   „ Ø€GØ€EØ€FØ€Gò"òò
 ò<ò=ó&:r   rN   c                   ót   — 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y)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                 ó2  — |€t        j                  d«      S t        |t        «      r|S t	        |«      }|�)t        |«      dk(  rd}n|D �cg c]  }t	        |«      ‘Œ }}t        j                  ||¬«      }t        |t        «      st        d«      ‚|S c c}w )zCreate a new Polygon geometry.NzPOLYGON EMPTYr   )Úholesz,Invalid values passed to Polygon constructor)r   r%   r   r
   r	   r1   Úpolygonsr0   )r3   Úshellru   r]   r5   s        r   r6   zPolygon.__new__ã   s“   € àˆ=ô ×#Ñ# OÓ4Ð4Ü˜œwÔ'àˆLä˜uÓ%ˆEàÐÜ�5‹z˜QŠà‘à6;Ö<¨dœ DÕ)Ð<�Ð<ä×Ñ ¨UÔ3ˆÜ˜$¤Ô(ÜÐKÓLÐLØˆùò =s   ÁBc                 ó,   — t        j                  | «      S )z(Return the exterior ring of the polygon.)r   Úget_exterior_ringr:   s    r   ÚexteriorzPolygon.exteriorû   s   € ô ×(Ñ(¨Ó.Ð.r   c                 ó4   — | j                   rg S t        | «      S )z5Return the sequence of interior rings of the polygon.)Úis_emptyrN   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 }nUt        | j                   j                  «      g}| j                  D ]&  }|j                  t        |j                  «      «       Œ( dt        |«      dœS )z6Return a GeoJSON-like mapping of the Polygon geometry.r
   r8   )rz   r	   r9   r    r}   rg   )r3   r    Úholes      r   r;   zPolygon.__geo_interface__  se   € ð �=‰=œJ›LÒ(Ø‰Fä˜DŸM™M×0Ñ0Ó1Ð2ˆFØŸ™ò 2�Ø—‘œe D§K¡KÓ0Õ1ð2à!´%¸³-Ñ@Ð@r   c                 ó  — | j                   ry|€| j                  rdnd}|€d}| j                  j                  D �cg c]  } dj                  |Ž ‘Œ c}g}| j
                  D ��cg c])  }|j                  D �cg c]  } dj                  |Ž ‘Œ c}‘Œ+ }}}dj                  ||z   D �cg c])  }dj	                  |d	   d
j                  |dd «      «      ‘Œ+ c}«      }	d|› dd|z  › d|› d|	› d�	S c c}w c c}w c c}}w c c}w )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ã?z{},{}ú zM {} L {} zr   z L rZ   z <path fill-rule="evenodd" fill="z!" stroke="#555555" stroke-width="g       @z" opacity="z" d="z" />)r|   r'   rz   r    Úformatr}   Újoin)
r3   Úscale_factorÚ
fill_colorÚopacityr#   Úexterior_coordsÚinteriorÚinterior_coordsr    Úpaths
             r   ÚsvgzPolygon.svg  s  € ð �=Š=ØØÐØ&*§m¢m™¸ˆJØˆ?ØˆGØ8<¿¹×8LÑ8LÖM°1˜N˜GŸN™N¨AÒ.ÒMÐNˆàJNÏ.É.÷
Ø>F¨¯©Ö9 Aˆ^ˆW�^‰^˜QÒÔ9ð
ˆñ 
ð �x‰xð .°Ñ?öàð ×$Ñ$ V¨A¡Y°·
±
¸6À!À"¸:Ó0FÕGòó
ˆð /¨z¨lð ;Ø  <Ñ/Ð0°¸G¸9ÀEÈ$ÈÈtðUð	
ùò Nùâ9ùó
ùòs#   ¼C/Á%C9Á8C4ÂC9Â(.C?Ã4C9c                 ó*   —  | ||f||f||f||fg«      S )z,Construct a `Polygon()` from spatial bounds.rK   )ÚclsÚxminÚyminÚxmaxÚymaxs        r   Úfrom_boundszPolygon.from_bounds<  s(   € ñ �T˜4�L 4¨ ,°°t°¸tÀT¸lÐKÓLÐLr   )NN)ç      ð?NN)rE   rF   rG   rH   rI   r6   rJ   rz   r}   r    r;   r�   Úclassmethodr”   rK   r   r   r
   r
   ¼   s‚   „ ñ"ðH €Ióð0 ñ/ó ð/ð ñ*ó ð*ð ñ
ó ð
ð ñAó ðAó!
ðF ñMó ñM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ÐCr   )r•   )rH   Únumpyr)   r   r   Úshapely.algorithms.cgar   Úshapely.errorsr   Úshapely.geometry.baser   Úshapely.geometry.linestringr   Úshapely.geometry.pointr   Ú__all__r   r	   ÚlibÚregistryrN   r
   r   rK   r   r   ú<module>r¦      s‡   ðÙ 0ã ã Ý %Ý .Ý +Ý .Ý 2Ý (â
-€òôl-�ô l-ð^ %€‡�× Ñ �QÑ ÷.:ñ .:ôbCMˆlô CMðL "€‡�× Ñ �QÑ ôDr   