
    Dg\                     H   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l
mZ ej                  j                  edk  d	      Zed
        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zy)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)geos_version)voronoi_diagram)loads)      r   zGEOS >= 3.5.0 is required.)reasonc                      t        dg      } t        j                  d      5  t        |       }d d d        t	        j
                        dk(  sJ y # 1 sw Y   $xY w)N      ?r   pointsignore)invalidr   )r   nperrstater   lengeomsmpregionss     h/var/www/html/public_html/venv/lib/python3.12/site-packages/shapely/tests/legacy/test_voronoi_diagram.pytest_no_regionsr      sR    	J<	(B	X	& &!"%& w}}"""& &s   AAc                  j    t        ddg      } t        |       }t        |j                        dk(  sJ y )Nr         ?r   r      )r   r   r   r   r   s     r   test_two_regionsr      s2    	J
3	4Bb!Gw}}"""    c                      t        ddg      } t        | d      }t        |j                        dk(  sJ t	        d |j                  D              sJ y )Nr   r   r   T)edges   c              3   R   K   | ]  }|j                   j                  d        ! yw)
LineStringN)	geom_typeendswith.0rs     r   	<genexpr>ztest_edges.<locals>.<genexpr>.   s     Iaq{{##L1Is   %')r   r   r   r   allr   s     r   
test_edgesr,   '   sL    	J
3	4Bb-Gw}}"""I7==IIIIr   c                      t        ddg      } t        d      }t        | |      }t        |j                        dk(  sJ t        d |j                  D              |j                  kD  sJ y )Nr   r   r   +POLYGON ((0 0, 0.5 0, 0.5 0.5, 0 0.5, 0 0))enveloper   c              3   4   K   | ]  }|j                     y wNarear'   s     r   r*   z(test_smaller_envelope.<locals>.<genexpr>9        -!qvv-   r   load_wktr   r   r   sumr4   r   polyr   s      r   test_smaller_enveloper<   1   s`    	J
3	4BABDb40Gw}}"""-w}}--		999r   c                      t        ddg      } t        d      }t        | |      }t        |j                        dk(  sJ t        d |j                  D              |j                  k(  sJ y)	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              3   4   K   | ]  }|j                     y wr2   r3   r'   s     r   r*   z'test_larger_envelope.<locals>.<genexpr>G   r5   r6   Nr7   r:   s      r   test_larger_enveloper?   <   sb    
 
J
3	4B9:Db40Gw}}"""-w}}--:::r   c                  d    t        d      } t        |       }t        |j                        dk(  sJ y )N#POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))   r8   r   r   r   r;   r   s     r   test_from_polygonrE   J   s.    9:Dd#Gw}}"""r   c                  h    t        d      } t        | d      }t        |j                        dk(  sJ y )Nr.   r   	tolerancer   rC   rD   s     r   'test_from_polygon_with_enough_tolerancerI   R   s0    ABDdc2Gw}}"""r   c                      t        d      } t        j                  t              5 }t	        | d       d d d        dt        j                        v sJ dt        |j                        v sJ y # 1 sw Y   <xY w)Nr.   g333333?rG   :Could not create Voronoi Diagram with the specified inputs/Try running again with default tolerance value.r8   pytestraises
ValueErrorr   strvaluer;   excs     r   *test_from_polygon_without_enough_tolerancerU   Z   sv    ABD	z	" -c,- H3		L    =CIINNN- -   A..A7c                      t        d      } t        j                  t              5 }t	        | d       d d d        dt        j                        v sJ dt        |j                        v sJ y # 1 sw Y   <xY w)NrA   皙?rG   rK   rL   rM   rS   s     r   4test_from_polygon_without_floating_point_coordinatesrY   f   sv    9:D	z	" -c,- H3		L    =CIINNN- -rV   c                      t        d      } t        j                  t              5 }t	        | d       ddd       dt        j                        v sJ dt        |j                        v sJ y# 1 sw Y   <xY w)zPA Multipoint with the same "shape" as the above Polygon raises the same error...zMULTIPOINT (0 0, 1 0, 1 1, 0 1)rX   rG   NrK   rL   rM   r   rT   s     r   7test_from_multipoint_without_floating_point_coordinatesr\   r   sx     
3	4B	z	" +cc*+ H3		L    =CIINNN+ +rV   c                      t        d      } t        j                  t              5 }t	        | d       ddd       dt        j                        v sJ dt        |j                        v sJ y# 1 sw Y   <xY w)z5This multipoint will not work with a tolerance value.MULTIPOINT (0 0, 1 0, 1 2, 0 1)rX   rG   NrK   rL   rM   r[   s     r   Etest_from_multipoint_with_tolerace_without_floating_point_coordinatesr_      sx     
3	4B	z	" +cc*+ H3		L    =CIINNN+ +rV   c                  d    t        d      } t        |       }t        |j                        dk(  sJ y)zBut it's fine without it.r^   rB   NrC   r   s     r   Htest_from_multipoint_without_tolerace_without_floating_point_coordinatesra      s0     
3	4Bb!Gw}}"""r   )__doc__numpyr   rN   shapely.geometryr   shapely.geosr   shapely.opsr   shapely.wktr   r8   markskipifrequires_geos_35r   r   r,   r<   r?   rE   rI   rU   rY   r\   r_   ra    r   r   <module>rl      s=     ' % ' );;%%9%A &  
 # # # # J J : : 
; 
; # # # # O O O O 
O 
O 	O 	O # #r   