
    \iJ+                        S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  / S	QrS
 r " S S\5      r\\R$                  R&                  S'    " S S5      r " S S\
5      r\\R$                  R&                  S'   SS jrg)z*Polygons and their linear ring components.    N)_geometry_helpers)signed_area)TopologicalError)BaseGeometry)
LineString)Point)
LinearRingPolygonorientc                     [         R                  " U 5      n[         R                  " U5      n[        R                  " U5      nU(       a  [         R
                  " X25      nU$ N)shapelyfrom_wkbget_sridr   linestring_to_linearringset_srid)wkb
linestringsrid
linearrings       [/var/www/html/kml_chatgpt/mouzaenv/lib/python3.13/site-packages/shapely/geometry/polygon.py_unpickle_linearringr      sK    !!#&JJ'D";;JGJ%%j7
    c                   \    \ rS rSrSr/ rS
S jr\S 5       rS r	\S 5       r
\S 5       rS	rg)r	      aF  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                 n   Uc  [         R                  " S5      $ [        U[        5      (       a=  [	        U5      [
        L a  U$ UR                  (       d  [        S5      eUR                  nO[        US5      (       a  [        R                  " U5      n[        U[        R                  5      (       a5  [        R                  " UR                  [        R                  5      (       a  OnS n[        R                   " U Vs/ s H
  o2" U5      PM     sn5      n[        R                  " UR                  [        R                  5      (       d  [#        S5      e[%        U5      S:X  a  [         R                  " S5      $ [         R&                  " U5      n[        U[
        5      (       d  [#        S5      eU$ s  snf )z!Create a new LinearRing geometry.zLINEARRING EMPTYz"An input LineString must be valid.	__array__c                     [        U [        5      (       a  U R                  S   $ U  Vs/ s H  n[        U5      PM     sn$ s  snf Nr   )
isinstancer   coordsfloat)ocs     r   _coords#LinearRing.__new__.<locals>._coordsW   s9    !!U++ xx{*234!Qa!444s   A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__LinearRing.__new__=   sV    ##$677Z00K J."" ))&'KLL *00 {K00 jj5+rzz22r}}!!2998 8 5 !hhK'HKq
K'HI}}[%6%6		BB %%MNN{q  ##$677"";/$
++NOO (Is   >F2c                 2    S[        U R                  5      S.$ )z9Return a GeoJSON-like mapping of the LinearRing geometry.r	   r(   r6   )tupler!   r5   s    r   __geo_interface__LinearRing.__geo_interface__m   s     %U4;;5GHHr   c                 :    [         [        R                  " U SS944$ )zPickle 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__LinearRing.__reduce__r   s     %w~~d'N&PQQr   c                 @    [        [        R                  " U 5      5      $ )z0True if the ring is oriented counter clock-wise.)boolr   is_ccwr=   s    r   rG   LinearRing.is_ccwz   s     GNN4())r   c                 @    [        [        R                  " U 5      5      $ )zgTrue if the geometry is simple.

Simple means that any self-intersections are only at boundary points.
)rF   r   	is_simpler=   s    r   rJ   LinearRing.is_simple   s     G%%d+,,r    r   )__name__
__module____qualname____firstlineno____doc__	__slots__r8   propertyr>   rC   rG   rJ   __static_attributes__rL   r   r   r	   r	      sY    B I.` I IR * * - -r   r	      c                   H    \ rS rSrSrSrSrSrS rS r	S r
S rS rS	 rS
rg)InteriorRingSequence   Nr   c                 2    Xl         UR                  U l        g r   )_parent_ndim)r5   parents     r   __init__InteriorRingSequence.__init__   s    \\
r   c                 >    SU l         U R                  5       U l        U $ r   )_index__len___lengthr=   s    r   __iter__InteriorRingSequence.__iter__   s    ||~r   c                     U R                   U R                  :  a2  U R                  U R                   5      nU =R                   S-  sl         U$ [        e)N   )r`   rb   	_get_ringStopIteration)r5   rings     r   __next__InteriorRingSequence.__next__   s=    ;;%>>$++.DKK1KKr   c                 B    [         R                  " U R                  5      $ r   )r   get_num_interior_ringsrZ   r=   s    r   ra   InteriorRingSequence.__len__   s    --dll;;r   c                    U R                  5       n[        U[        5      (       a6  X-   S:  d  X:  a  [        S5      eUS:  a  X!-   nOUnU R	                  U5      $ [        U[
        5      (       aK  / nUR                  U5      u  pVn[        XVU5       H#  nUR                  U R	                  U5      5        M%     U$ [        S5      e)Nr   zindex out of rangezkey must be an index or slice)
ra   r    int
IndexErrorrg   sliceindicesrangeappend	TypeError)r5   keymiresstartstopstrides           r   __getitem__ InteriorRingSequence.__getitem__   s    LLNc3w{ch !566QwG>>!$$U##C"%++a.E5/

4>>!,- 0J;<<r   c                 D    [         R                  " U R                  U5      $ r   )r   get_interior_ringrZ   )r5   ry   s     r   rg   InteriorRingSequence._get_ring   s    ((q99r   )r`   rb   r[   rZ   )rM   rN   rO   rP   rZ   r[   r`   rb   r]   rc   rj   ra   r~   rg   rT   rL   r   r   rW   rW      s4    GEFG"
 <=&:r   rW   c                       \ rS rSrSr/ rSS jr\S 5       r\S 5       r	\S 5       r
\S 5       rSS	 jr\S
 5       rSrg)r
      a  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                 N   Uc  [         R                  " S5      $ [        U[        5      (       a  U$ [	        U5      nUb-  [        U5      S:X  a  SnOU Vs/ s H  n[	        U5      PM     nn[         R                  " XS9n[        U[        5      (       d  [        S5      eU$ s  snf )zCreate a new Polygon geometry.NzPOLYGON EMPTYr   )holesz,Invalid values passed to Polygon constructor)r   r'   r    r
   r	   r3   polygonsr2   )r5   shellr   ri   r7   s        r   r8   Polygon.__new__   s    = ##O44w''Lu%E5zQ6;<edD)e<3$((KLL =s   B"c                 .    [         R                  " U 5      $ )z(Return the exterior ring of the polygon.)r   get_exterior_ringr=   s    r   exteriorPolygon.exterior   s     ((..r   c                 >    U R                   (       a  / $ [        U 5      $ )z5Return the sequence of interior rings of the polygon.)is_emptyrW   r=   s    r   	interiorsPolygon.interiors   s     ==I#D))r   c                     [        S5      e)zNot implemented for polygons.zCComponent rings have coordinate sequences, but the polygon does not)NotImplementedErrorr=   s    r   r!   Polygon.coords  s     "Q
 	
r   c                    U R                   [        5       :X  a  / nOW[        U R                   R                  5      /nU R                   H'  nUR                  [        UR                  5      5        M)     S[        U5      S.$ )z6Return a GeoJSON-like mapping of the Polygon geometry.r
   r;   )r   r	   r<   r!   r   ru   )r5   r!   holes      r   r>   Polygon.__geo_interface__  s`     ==JL(FDMM0012FeDKK01 '!%-@@r   c                 4   U R                   (       a  gUc  U R                  (       a  SOSnUc  SnU R                  R                   Vs/ s H  nSR                  " U6 PM     sn/nU R
                   VVs/ s H,  ofR                   Vs/ s H  nSR                  " U6 PM     snPM.     nnnSR                  XW-    Vs/ s H*  nSR	                  US	   S
R                  USS 5      5      PM,     sn5      n	SU SSU-   SU SU	 S3	$ s  snf s  snf s  snnf s  snf )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 rf   z <path fill-rule="evenodd" fill="z!" stroke="#555555" stroke-width="g       @z" opacity="z" d="z" />)r   r)   r   r!   formatr   join)
r5   scale_factor
fill_coloropacityr$   exterior_coordsinteriorinterior_coordsr!   paths
             r   svgPolygon.svg  s&    ==&*mmJ?G8<8L8LM8L1GNNA.8LMNJN..
JXh9AW^^Q9. 	 
 xx .??F $$VAY

6!":0FG?
 /zl ; </0G9E$tU	
 N9
s$   D4DD
 D;1D
Dc                 "    U " X4X4X44X24/5      $ )z,Construct a `Polygon()` from spatial bounds.rL   )clsxminyminxmaxymaxs        r   from_boundsPolygon.from_bounds<  s      TL4,tlKLLr   rL   )NN)      ?NN)rM   rN   rO   rP   rQ   rR   r8   rS   r   r   r!   r>   r   classmethodr   rT   rL   r   r   r
   r
      s    "H I0 / / * * 
 
 A A!
F M Mr   r
      c                 0    [         R                  " XS:  S9$ )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    ( ""7s
CCr   )r   )rQ   numpyr+   r   r   shapely.algorithms.cgar   shapely.errorsr   shapely.geometry.baser   shapely.geometry.linestringr   shapely.geometry.pointr   __all__r   r	   libregistryrW   r
   r   rL   r   r   <module>r      s    0   % . + . 2 (
-l- l-^ %  Q .: .:bCMl CML "  Q Dr   