
    Og%                         d dl Z d dlZd dlmZ d dlmZmZmZmZm	Z	m
Z
 d dlmZmZmZ  G d de j                        Z G d de      Z G d	 d
e      Z G d de      Z G d de      Zy)    N)GeometryTypeError)
LineStringMultiLineString
MultiPointMultiPolygonPointPolygon)	linemergesplitunary_unionc                       e Zd Zd Zd Zy)TestSplitGeometryc                 H   t        ||      }|j                  dk(  sJ t        |j                        |k(  sJ |dkD  r|j                  d   j                  dk(  r9| j	                  t        |      j                  d      j                  |             y |j                  d   j                  dk(  rHt        |      j                  d      }|j                  |      sJ |j                  |j                  k(  sJ t        y |dk(  r!|j                  d   j                  |      sJ y y )NGeometryCollection   r   r   gư>r	   )r   	geom_typelengeoms
assertTruer
   simplifyequalsr   area
ValueError)selfgeomsplitterexpected_chunkssunions         d/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/shapely/tests/legacy/test_split.pyhelperzTestSplitGeometry.helper   s   $!{{2222177|...Qwwqz##|3	! 5 5h ? F Ft LM%%2#A//9||D)))zzTYY...   / !771:$$T*** "    c                 \    t        g d      }t        dd      }| j                  ||d       y )N)r   r   r   r   r   r   r   r   r$   r   r   )r   r   r!   )r   lsr   s      r    !test_split_closed_line_with_pointz3TestSplitGeometry.test_split_closed_line_with_point%   s*     @AA;B!$r"   N)__name__
__module____qualname__r!   r)    r"   r    r   r      s    +$%r"   r   c                   H    e Zd Z eg d      Z eg dg dg      Zd Zd Zy)TestSplitPolygonr$      r   r2   r2   r   r2   r$         ?r7   )r7         ?r8   r8   )r8   r7   r6   c                 <   t        ddg      }| j                  | j                  |d       | j                  | j                  |d       t        ddg      }| j                  | j                  |d       | j                  | j                  |d       t        g d      }| j                  | j                  |d       | j                  | j                  |d       t        g d      }| j                  | j                  |d       | j                  | j                  |d       y )	N)r      )r   r2   r4   )   r2   r   ))皙?r>   )333333?r?   )r;   r2   ))r   r;   r;   r;   )r;   r   )r   r!   poly_simple	poly_holer   r   s     r    test_split_poly_with_linez*TestSplitPolygon.test_split_poly_with_line4   s    vw/0D$$h2DNNHa0 vv./D$$h2DNNHa0 >?D$$h2DNNHa0 67D$$h2DNNHa0r"   c                    t        j                  t              5  t        | j                  t        dd             d d d        t        j                  t              5  t        | j                  t        ddg             d d d        t        j                  t              5  t        | j                  | j                         d d d        y # 1 sw Y   xY w# 1 sw Y   XxY w# 1 sw Y   y xY w)Nr   r&   r;      )pytestraisesr   r   rA   r   r   rB   )r   s    r    test_split_poly_with_otherz+TestSplitPolygon.test_split_poly_with_otherI   s    ]],- 	1$""E!QK0	1]],- 	B$""J/?$@A	B]],- 	4$""DNN3	4 	4		1 	1	B 	B	4 	4s#   !C	"C!C!	CC!C*N)r*   r+   r,   r	   rA   rB   rD   rJ   r-   r"   r    r/   r/   -   s*    BCK0	EFI
1*4r"   r/   c                   D    e Zd Z eg d      Zd Zd Zd Zd Zd Z	d Z
y)	TestSplitLine)r$   r9   )g      @g      @c                 L   t        dd      }| j                  | j                  |d       t        dd      }| j                  | j                  |d       t        dd      }| j                  | j                  |d       t        dd      }| j                  | j                  |d       y )Nr   r2   r8   r;   rG   )r   r!   r(   rC   s     r    test_split_line_with_pointz(TestSplitLine.test_split_line_with_pointU   s    A;DGGXq) c?DGGXq) A;DGGXq) A;DGGXq)r"   c                     t        g d      }| j                  | j                  |d       t        ddg      }| j                  | j                  |d       t        g d      }| j                  | j                  |d       y )N)r&   r9   r6   rG   r&   rF   r2   )r&   r9   r&   r;   )r   r!   r(   rC   s     r    test_split_line_with_multipointz-TestSplitLine.test_split_line_with_multipointf   sg    >?DGGXq) vv./DGGXq) :;DGGXq)r"   c                    t        ddg      }| j                  | j                  |d       t        g d      }| j                  | j                  |d       t        ddg      }t        j                  t
              5  | j                  | j                  |d       d d d        t        dd	g      }| j                  | j                  |d       t        d
dg      }|j                  | j                        sJ | j                  | j                  |d       t        ddg      }|j                  | j                        sJ | j                  | j                  |d       y # 1 sw Y   xY w)Nr%   r'   r2   )r%   r'   r   r2   r;   r$   )   rS   r   r4   )r   )r   rT   r&   )r   r!   r(   rH   rI   r   touchesrC   s     r    test_split_line_with_linez'TestSplitLine.test_split_line_with_lines   s+   vv./DGGXq) 67DGGXq) vx01]]:& 	.KK1-	. vv./DGGXq) w01(((DGGXq) vv./(((DGGXq)	. 	.s   ;EE#c                 ,   t        ddgddgg      }| j                  | j                  |d       t        ddgddgg      }| j                  | j                  |d       t        ddgg d	g      }| j                  | j                  |d
       t        ddgddgg      }t        j                  t
              5  | j                  | j                  |d       d d d        t        ddgddgg      }| j                  | j                  |d       y # 1 sw Y   8xY w)Nr%   r'   r$   )r2   r2   r4   r1   r;   )r4   r1   )g@g	@rG   r9   rF   r   )r   r!   r(   rH   rI   r   rC   s     r    test_split_line_with_multilinez,TestSplitLine.test_split_line_with_multiline   s   "VV$4vw6G#HIDGGXq) #VV$4vv6F#GHDGGXq) #VV$46R#STDGGXq) #VZ$8:v:N#OP]]:& 	.KK1-	. #VV$4vv6F#GHDGGXq)	. 	.s   5D

Dc                    t        g d      }| j                  | j                  |d       t        g d      }| j                  | j                  |d       t        g dg dg      }| j                  | j                  |d       y )N)r'   rR   r3   r1   r'   r;   )r$   rR   r3   r'   r$   r2   r0   r5   rG   )r	   r!   r(   rC   s     r    test_split_line_with_polygonz*TestSplitLine.test_split_line_with_polygon   sm    CDDGGXq) CDDGGXq) 4IJ
 	DGGXq)r"   c                     t        g d      }t        g d      }t        g d      }t        |||g      }| j                  | j                  |d       y )Nr0   r5   )r$   )r   rX   )rX   rX   )rX   r   r$   rG   )r	   r   r!   r(   )r   poly1poly2poly3r   s        r    !test_split_line_with_multipolygonz/TestSplitLine.test_split_line_with_multipolygon   sP    4
 H
 DEu 56DGGXq)r"   N)r*   r+   r,   r   r(   rN   rP   rV   rY   r[   r`   r-   r"   r    rL   rL   R   s+    	4	5B*"**8*,*"	*r"   rL   c                   @    e Zd Z eddgddgddgddgddgg      Zd Zy)TestSplitClosedRingr   r   c                    t        ddg      }| j                  | j                  |d       t        ddg      }| j                  | j                  |d       t        | j                  |      }|j                  d   j
                  d d  ddgk(  sJ |j                  d   j
                  d d  g dk(  sJ t        ddg      }| j                  | j                  |d       t        | j                  |      }|j                  d   j
                  d d  g d	k(  sJ |j                  d   j
                  d d  d
dgk(  sJ t        ddg      }| j                  | j                  |d       y )N        r   r7   r2   r   r$   rd   r7   )re   r%   r&   r'   r$   )r$   r%   r&   r'   r7   r   rf   g       @)r   r!   r(   r   r   coords)r   r   results      r    !test_split_closed_ring_with_pointz5TestSplitClosedRing.test_split_closed_ring_with_point   s<   #s$DGGXq)#s$DGGXq)tww)||A%%a(VZ,@@@@||A%%a(,XXXX #s$DGGXq)tww)||A%%a(,VVVV||A%%a(Xv,>>>>#s$DGGXq)r"   N)r*   r+   r,   r   r(   ri   r-   r"   r    rb   rb      s0    	aVaVaVaVaV<	=B*r"   rb   c                       e Zd Zd Zd Zd Zy)TestSplitMultic                     t        ddg      }t        ddg      }t        ||g      }t        d      }| j                  ||d       y )Nr%   r2   r   r'   rR   r&   rG   )r   r   r   r!   r   l1l2mlr   s        r    test_split_multiline_with_pointz.TestSplitMulti.test_split_multiline_with_point   sG    ()()b"X&=B!$r"   c                     t        ddg      }t        ddg      }t        ||g      }t        g d      }| j                  ||d       y )Nr%   )r;   r   r'   rR   )r&   rm   )rG   r2   r=   )r   r   r   r!   rn   s        r    $test_split_multiline_with_multipointz3TestSplitMulti.test_split_multiline_with_multipoint   sK     ()()b"X&67B!$r"   c                     t        g d      }t        g d      }t        ||g      }t        ddg      }| j                  ||d       t        g d      }t        g d      }t        ||g      }t        ddg      }| j                  ||d       y )	N)r$   r'   r&   r%   r$   )r&   rR   r3   rm   r&   )rT   rT   r@   rG   )
   rw   )rw      )rx   rx   )rx   rw   rv   )rz   )rz   )r{   r{   )r{   rz   ry   r2   )r	   r   r   r!   )r   r]   r^   mpolyr(   s        r    !test_split_multipolygon_with_linez0TestSplitMulti.test_split_multipolygon_with_line   s    @A@AeU^,6*+E2q! JKTUeU^,6*+E2q!r"   N)r*   r+   r,   rr   rt   r}   r-   r"   r    rk   rk      s    %%"r"   rk   )unittestrH   shapely.errorsr   shapely.geometryr   r   r   r   r   r	   shapely.opsr
   r   r   TestCaser   r/   rL   rb   rk   r-   r"   r    <module>r      sj      ,  6 5%)) %8"4( "4Jm*% m*`*+ *0"& "r"   