o
    A+ iC,                     @   s   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 de jZG dd deZG d	d
 d
eZG dd deZG dd deZdS )    N)GeometryTypeError)
LineStringMultiLineString
MultiPointMultiPolygonPointPolygon)	linemergesplitunary_unionc                   @   s   e Zd Zdd Zdd ZdS )TestSplitGeometryc                 C   s   t ||}|jdksJ t|j|ksJ |dkrR|jd jdkr0| t|d| d S |jd jdkrPt|d}||sFJ |j	|j	ksNJ d S t
|dkr`|jd |sbJ d S d S )NZGeometryCollection   r   r   gư>r   )r
   Z	geom_typelengeoms
assertTruer	   simplifyequalsr   area
ValueError)selfZgeomsplitterZexpected_chunkssunion r   k/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/shapely/tests/legacy/test_split.pyhelper   s   
zTestSplitGeometry.helperc                 C   s(   t g d}tdd}| ||d d S )N)r   r   r   r   r   r   r   r   r   r   r   )r   r   r   )r   lsr   r   r   r   !test_split_closed_line_with_point&   s   
z3TestSplitGeometry.test_split_closed_line_with_pointN)__name__
__module____qualname__r   r!   r   r   r   r   r      s    r   c                   @   sD   e Zd Zeg dZeg dg dgZdd Zdd Zdd Zd	S )
TestSplitPolygonr      r   r(   r(   r   r(   r         ?r-   )r-         ?r.   r.   )r.   r-   r,   c                 C   s   t ddg}| | j|d | | j|d t g d}| | j|d | | j|d t ddg}| | j|d | | j|d t g d	}| | j|d | | j|d t g d
}| | j|d | | j|d d S )Nr      r   r(   )r0   r2   333333?r3   r5   r1   r1   r*      r(   r   ))皙?r9   r5   r5   r1   r(   )r   r1   r1   r1   )r1   r   )r   r   poly_simple	poly_holer   r   r   r   r   test_split_poly_with_line5   s   z*TestSplitPolygon.test_split_poly_with_linec                 C   s  t ddgddgg}| | j|d | | j|d t ddgddgg}| | j|d | | j|d t ddgd	d
gg}| | j|d | | j|d t ddgg dg}| | j|d | | j|d t ddgg dg}| | j|d | | j|d d S )N)r9   r1   )r9   r3   r4   r6   r1   )r3   r   r1   r      r*   r7   r(   ))333333?rD   r:   r;   r<   )r   r   r>   r?   r@   r   r   r   test_split_poly_with_multilineO   s"   z/TestSplitPolygon.test_split_poly_with_multilinec                 C   s   t t t| jtdd W d    n1 sw   Y  t t t| jtddg W d    n1 s8w   Y  t t t| j| j W d    d S 1 sUw   Y  d S )Nr   r   r1   rC   )pytestraisesr   r
   r>   r   r   r?   )r   r   r   r   test_split_poly_with_otherk   s   "z+TestSplitPolygon.test_split_poly_with_otherN)	r"   r#   r$   r   r>   r?   rA   rE   rI   r   r   r   r   r%   .   s    r%   c                   @   sH   e Zd Zeg dZdd Zdd Zdd Zdd	 Zd
d Z	dd Z
dS )TestSplitLine)r   r/   )g      @g      @c                 C   sl   t dd}| | j|d t dd}| | j|d t dd}| | j|d t dd}| | j|d d S )Nr   r(   r.   r1   rC   )r   r   r    r@   r   r   r   test_split_line_with_pointw   s   



z(TestSplitLine.test_split_line_with_pointc                 C   sX   t g d}| | j|d t ddg}| | j|d t g d}| | j|d d S )N)r   r/   r,   rC   r   rF   r(   )r   r/   r   r1   )r   r   r    r@   r   r   r   test_split_line_with_multipoint   s   z-TestSplitLine.test_split_line_with_multipointc                 C   s   t ddg}| | j|d t g d}| | j|d t ddg}tt | | j|d W d    n1 s:w   Y  t dd	g}| | j|d t d
dg}|| js[J | | j|d t ddg}|| jsqJ | | j|d d S )Nr   r   r(   )r   r   r   r(   r1   r   )   rN   r   r*   )r   )r   rO   r   )r   r   r    rG   rH   r   Ztouchesr@   r   r   r   test_split_line_with_line   s    z'TestSplitLine.test_split_line_with_linec                 C   s   t ddgddgg}| | j|d t ddgddgg}| | j|d t ddgg d	g}| | j|d
 t ddgddgg}tt | | j|d W d    n1 sXw   Y  t ddgddgg}| | j|d d S )Nr   r   r   )r(   r(   r*   r'   r1   )r*   r'   )g@g	@rC   r/   rF   r   )r   r   r    rG   rH   r   r@   r   r   r   test_split_line_with_multiline   s   z,TestSplitLine.test_split_line_with_multilinec                 C   s`   t g d}| | j|d t g d}| | j|d t g dg dg}| | j|d d S )N)r   rM   r)   r'   r   r1   )r   rM   r)   r   r   r(   r&   r+   rC   )r   r   r    r@   r   r   r   test_split_line_with_polygon   s   z*TestSplitLine.test_split_line_with_polygonc                 C   sF   t g d}t g d}t g d}t|||g}| | j|d d S )Nr&   r+   )r   )r   rQ   )rQ   rQ   )rQ   r   r   rC   )r   r   r   r    )r   poly1poly2Zpoly3r   r   r   r   !test_split_line_with_multipolygon   s   z/TestSplitLine.test_split_line_with_multipolygonN)r"   r#   r$   r   r    rK   rL   rP   rR   rS   rV   r   r   r   r   rJ   t   s    rJ   c                   @   s:   e Zd ZeddgddgddgddgddggZdd ZdS )TestSplitClosedRingr   r   c                 C   s  t ddg}| | j|d t ddg}| | j|d t| j|}|jd jd d  ddgks2J |jd jd d  g dksBJ t ddg}| | j|d t| j|}|jd jd d  g d	ksfJ |jd jd d  d
dgksvJ t ddg}| | j|d d S )N        r   r-   r(   r   r   rX   r-   )rY   r   r   r   r   )r   r   r   r   r-   r   rZ   g       @)r   r   r    r
   r   Zcoords)r   r   resultr   r   r   !test_split_closed_ring_with_point   s       z5TestSplitClosedRing.test_split_closed_ring_with_pointN)r"   r#   r$   r   r    r\   r   r   r   r   rW      s    &rW   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestSplitMultic                 C   s>   t ddg}t ddg}t||g}td}| ||d d S )Nr   r(   r   r   rM   r   rC   )r   r   r   r   r   l1l2mlr   r   r   r   test_split_multiline_with_point   s
   z.TestSplitMulti.test_split_multiline_with_pointc                 C   sB   t ddg}t ddg}t||g}tg d}| ||d d S )Nr   rB   r   rM   )r   r^   )rC   r(   r8   )r   r   r   r   r_   r   r   r   $test_split_multiline_with_multipoint  s
   z3TestSplitMulti.test_split_multiline_with_multipointc                 C   s   t g d}t g d}t||g}tddg}| ||d t g d}t g d}t||g}tddg}| ||d d S )	N)r   r   r   r   r   )r   rM   r)   r^   r   )rO   rO   r=   rC   )
   rf   )rf      )rg   rg   )rg   rf   re   )ri   )ri   )rj   rj   )rj   ri   rh   r(   )r   r   r   r   )r   rT   rU   Zmpolyr    r   r   r   !test_split_multipolygon_with_line  s   z0TestSplitMulti.test_split_multipolygon_with_lineN)r"   r#   r$   rc   rd   rk   r   r   r   r   r]      s    	
r]   )ZunittestrG   Zshapely.errorsr   Zshapely.geometryr   r   r   r   r   r   Zshapely.opsr	   r
   r   ZTestCaser   r%   rJ   rW   r]   r   r   r   r   <module>   s     Fp