o
    jC,                     @   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geomsZ
assertTruer	   simplifyequalsr   Zarea
ValueError)selfZgeomsplitterZexpected_chunkssunion r   `/var/www/html/Deteccion_Ine/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         ?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&   )r.   r0   333333?r1   r3   r/   r/   r(      r&   r   ))皙?r7   r3   r3   r/   r&   )r   r/   r/   r/   )r/   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)r7   r/   )r7   r1   r2   r4   r/   )r1   r   r/   r      r(   r5   r&   ))333333?rB   r8   r9   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   r/   rA   )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=   r?   rC   rG   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,   r/   rA   )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*   rA   r   rD   r&   )r   r-   r   r/   )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&   r/   r   )   rL   r   r(   )r   )r   rM   r   )r   r   r   rE   rF   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%   r/   )r(   r%   )g@g	@rA   r-   rD   r   )r   r   r   rE   rF   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   rK   r'   r%   r   r/   )r   rK   r'   r   r   r&   r$   r)   rA   )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   rO   )rO   rO   )rO   r   r   rA   )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   rI   rJ   rN   rP   rQ   rT   r   r   r   r   rH   t   s    rH   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   rV   r+   )rW   r   r   r   r   )r   r   r   r   r+   r   rX   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   rZ   r   r   r   r   rU      s    &rU   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   rK   r   rA   )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   r@   r   rK   )r   r\   )rA   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   rK   r'   r\   r   )rM   rM   r;   rA   )
   rd   )rd      )re   re   )re   rd   rc   )rg   )rg   )rh   rh   )rh   rg   rf   r&   )r   r   r   r   )r   rR   rS   Zmpolyr   r   r   r   !test_split_multipolygon_with_line  s   z0TestSplitMulti.test_split_multipolygon_with_lineN)r    r!   r"   ra   rb   ri   r   r   r   r   r[      s    	
r[   )ZunittestrE   Zshapely.errorsr   Zshapely.geometryr   r   r   r   r   r   Zshapely.opsr	   r
   r   ZTestCaser   r#   rH   rU   r[   r   r   r   r   <module>   s     Fp