o
    Jf%                     @   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   k/home/deployuser/azure_apps/autowriter/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                   @   s<   e Zd Zeg dZeg dg dg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 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,   r.   )   r,   r   ))皙?r7   )333333?r8   )r4   r,   ))r   r4   r4   r4   )r4   r   )r   r   poly_simple	poly_holer   r   r   r   r   test_split_poly_with_line4   s   z*TestSplitPolygon.test_split_poly_with_linec                 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"   r4      )pytestraisesr   r
   r:   r   r   r;   )r   r   r   r   test_split_poly_with_otherI   s   "z+TestSplitPolygon.test_split_poly_with_otherN)r&   r'   r(   r   r:   r;   r=   rB   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   r4   r?   )r   r   r$   r<   r   r   r   test_split_line_with_pointU   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   r?   r"   r>   r,   )r"   r3   r"   r4   )r   r   r$   r<   r   r   r   test_split_line_with_multipointf   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,   r4   r    )   rG   r   r.   )r   )r   rH   r"   )r   r   r$   r@   rA   r   touchesr<   r   r   r   test_split_line_with_lines   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+   r4   )r.   r+   )g@g	@r?   r3   r>   r   )r   r   r$   r@   rA   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#   rF   r-   r+   r#   r4   )r    rF   r-   r#   r    r,   r*   r/   r?   )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   rK   )rK   rK   )rK   r   r    r?   )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$   rD   rE   rJ   rL   rM   rQ   r   r   r   r   rC   R   s    rC   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    rS   r1   )rT   r!   r"   r#   r    )r    r!   r"   r#   r1   r   rU   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$   rX   r   r   r   r   rR      s    &rR   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#   rF   r"   r?   )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!   )r4   r   r#   rF   )r"   rZ   )r?   r,   r6   )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"   rF   r-   rZ   r"   )rH   rH   r9   r?   )
   rb   )rb      )rc   rc   )rc   rb   ra   )re   )re   )rf   rf   )rf   re   rd   r,   )r   r   r   r   )r   rN   rO   mpolyr$   r   r   r   !test_split_multipolygon_with_line   s   z0TestSplitMulti.test_split_multipolygon_with_lineN)r&   r'   r(   r_   r`   rh   r   r   r   r   rY      s    	rY   )unittestr@   shapely.errorsr   shapely.geometryr   r   r   r   r   r   shapely.opsr	   r
   r   TestCaser   r)   rC   rR   rY   r   r   r   r   <module>   s     %p