o
    j                     @   s   d Z ddlZddlZddlmZ ddlmZ ddlm	Z
 dd Zdd	 Zd
d Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd ZdS )z
Test cases for Voronoi Diagram creation.

Overall, I'm trying less to test the correctness of the result
and more to cover input cases and behavior, making sure
that we return a sane result without error or raise a useful one.
    N)
MultiPoint)voronoi_diagram)loadsc                  C   sV   t dgd} tjdd t| }W d    n1 sw   Y  t|jdks)J d S )N      ?r   Zpointsignore)invalidr   )r   npZerrstater   lengeomsmpregions r   j/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/shapely/tests/legacy/test_voronoi_diagram.pytest_no_regions   s
   
r   c                  C   s,   t ddgd} t| }t|jdksJ d S )Nr         ?r   r      )r   r   r   r   r   r   r   r   test_two_regions   s   r   c                  C   sH   t ddgd} t| dd}t|jdksJ tdd |jD s"J d S )	Nr   r   r   T)edges   c                 s   s    | ]	}|j d V  qdS )Z
LineStringN)Z	geom_typeendswith.0rr   r   r   	<genexpr>&   s    ztest_edges.<locals>.<genexpr>)r   r   r   r   allr   r   r   r   
test_edges    s   r   c                  C   sV   t ddgd} td}t| |d}t|jdksJ tdd |jD |jks)J d S )	Nr   r   r   +POLYGON ((0 0, 0.5 0, 0.5 0.5, 0 0.5, 0 0))enveloper   c                 s       | ]}|j V  qd S Narear   r   r   r   r   0       z(test_smaller_envelope.<locals>.<genexpr>r   load_wktr   r   r   sumr&   r   polyr   r   r   r   test_smaller_envelope)   s
   "r-   c                  C   sV   t ddgd} td}t| |d}t|jdksJ tdd |jD |jks)J d	S )
zWhen the envelope we specify is larger than the
    area of the input feature, the created regions should
    expand to fill that area.r   r   r   z#POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))r!   r   c                 s   r#   r$   r%   r   r   r   r   r   =   r'   z'test_larger_envelope.<locals>.<genexpr>Nr(   r+   r   r   r   test_larger_envelope3   s
   "r.   c                  C   s&   t d} t| }t|jdksJ d S )N#POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))   r)   r   r   r   r,   r   r   r   r   test_from_polygon@   s   r3   c                  C   s*   t d} t| dd}t|jdksJ d S )Nr    r   Z	tolerancer   r1   r2   r   r   r   'test_from_polygon_with_enough_toleranceG   s   r5   c                  C   f   t d} tt}t| dd W d    n1 sw   Y  dt|jv s(J dt|jv s1J d S )Nr    g333333?r4   :Could not create Voronoi Diagram with the specified inputs/Try running again with default tolerance value.r)   pytestZraises
ValueErrorr   strvaluer,   excr   r   r   *test_from_polygon_without_enough_toleranceN      
r@   c                  C   r6   )Nr/   皙?r4   r7   r8   r9   r>   r   r   r   4test_from_polygon_without_floating_point_coordinatesY   rA   rC   c                  C   f   t d} tt}t| dd W d   n1 sw   Y  dt|jv s(J dt|jv s1J dS )zNA Multipoint with the same "shape" as the above Polygon raises the same error.zMULTIPOINT (0 0, 1 0, 1 1, 0 1)rB   r4   Nr7   r8   r9   r   r?   r   r   r   7test_from_multipoint_without_floating_point_coordinatesd   s   
rF   c                  C   rD   )z5This multipoint will not work with a tolerance value.MULTIPOINT (0 0, 1 0, 1 2, 0 1)rB   r4   Nr7   r8   r9   rE   r   r   r   Etest_from_multipoint_with_tolerace_without_floating_point_coordinatesq   s   
rH   c                  C   s&   t d} t| }t|jdksJ dS )zBut it's fine without it.rG   r0   Nr1   r   r   r   r   Htest_from_multipoint_without_tolerace_without_floating_point_coordinates}   s   rI   )__doc__numpyr
   r:   Zshapely.geometryr   Zshapely.opsr   Zshapely.wktr   r)   r   r   r   r-   r.   r3   r5   r@   rC   rF   rH   rI   r   r   r   r   <module>   s$    	
