o
    hC,                     @   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 )NGeometryCollection   r   r   gư>r   )r
   	geom_typelengeoms
assertTruer	   simplifyequalsr   area
ValueError)selfgeomsplitterexpected_chunkssunion r   Z/var/www/html/scripts/venv/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          ?r1   )r1         ?r2   r2   )r2   r1   r0   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,   )r4   r6   333333?r7   r9   r5   r5   r.      r,   r   ))皙?r=   r9   r9   r5   r,   )r   r5   r5   r5   )r5   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)r=   r5   )r=   r7   r8   r:   r5   )r7   r   r5   r      r.   r;   r,   ))333333?rH   r>   r?   r@   )r   r   rB   rC   rD   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"   r5   rG   )pytestraisesr   r
   rB   r   r   rC   )r   r   r   r   test_split_poly_with_otherk   s   "z+TestSplitPolygon.test_split_poly_with_otherN)	r&   r'   r(   r   rB   rC   rE   rI   rM   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    r3   )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,   r2   r5   rG   )r   r   r$   rD   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"   r3   r0   rG   r"   rJ   r,   )r"   r3   r"   r5   )r   r   r$   rD   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,   r5   r    )   rR   r   r.   )r   )r   rS   r"   )r   r   r$   rK   rL   r   touchesrD   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+   r5   )r.   r+   )g@g	@rG   r3   rJ   r   )r   r   r$   rK   rL   r   rD   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#   rQ   r-   r+   r#   r5   )r    rQ   r-   r#   r    r,   r*   r/   rG   )r   r   r$   rD   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   rV   )rV   rV   )rV   r   r    rG   )r   r   r   r$   )r   poly1poly2poly3r   r   r   r   !test_split_line_with_multipolygon   s   z/TestSplitLine.test_split_line_with_multipolygonN)r&   r'   r(   r   r$   rO   rP   rU   rW   rX   r\   r   r   r   r   rN   t   s    rN   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   r1   r,   r   r    r^   r1   )r_   r!   r"   r#   r    )r    r!   r"   r#   r1   r   r`   g       @)r   r   r$   r
   r   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$   rc   r   r   r   r   r]      s    &r]   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#   rQ   r"   rG   )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!   rF   r#   rQ   )r"   re   )rG   r,   r<   )r   r   r   r   rf   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"   rQ   r-   re   r"   )rS   rS   rA   rG   )
   rm   )rm      )rn   rn   )rn   rm   rl   )rp   )rp   )rq   rq   )rq   rp   ro   r,   )r   r   r   r   )r   rY   rZ   mpolyr$   r   r   r   !test_split_multipolygon_with_line  s   z0TestSplitMulti.test_split_multipolygon_with_lineN)r&   r'   r(   rj   rk   rs   r   r   r   r   rd      s    	
rd   )unittestrK   shapely.errorsr   shapely.geometryr   r   r   r   r   r   shapely.opsr	   r
   r   TestCaser   r)   rN   r]   rd   r   r   r   r   <module>   s     Fp