
    _ 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 Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Z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)voronoi_diagram)loadsc                      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     /home/developers/rajanand/mypropertyqr-fmb-refixing-v2/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>0        -!qvv-   r   load_wktr   r   r   sumr0   r   polyr   s      r   test_smaller_enveloper8   )   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r.   r/   r#   s     r   r&   z'test_larger_envelope.<locals>.<genexpr>=   r1   r2   Nr3   r6   s      r   test_larger_enveloper;   3   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))   r4   r   r   r   r7   r   s     r   test_from_polygonrA   @   s.    9:Dd#Gw}}"""r   c                  h    t        d      } t        | d      }t        |j                        dk(  sJ y )Nr*   r   	tolerancer   r?   r@   s     r   'test_from_polygon_with_enough_tolerancerE   G   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?rC   :Could not create Voronoi Diagram with the specified inputs/Try running again with default tolerance value.r4   pytestraises
ValueErrorr   strvaluer7   excs     r   *test_from_polygon_without_enough_tolerancerQ   N   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)Nr=   皙?rC   rG   rH   rI   rO   s     r   4test_from_polygon_without_floating_point_coordinatesrU   Y   sv    9:D	z	" -c,- H3		L    =CIINNN- -rR   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)zNA Multipoint with the same "shape" as the above Polygon raises the same error.zMULTIPOINT (0 0, 1 0, 1 1, 0 1)rT   rC   NrG   rH   rI   r   rP   s     r   7test_from_multipoint_without_floating_point_coordinatesrX   d   sv    	3	4B	z	" +cc*+ H3		L    =CIINNN+ +rR   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)rT   rC   NrG   rH   rI   rW   s     r   Etest_from_multipoint_with_tolerace_without_floating_point_coordinatesr[   q   sv    	3	4B	z	" +cc*+ H3		L    =CIINNN+ +rR   c                  d    t        d      } t        |       }t        |j                        dk(  sJ y)zBut it's fine without it.rZ   r>   Nr?   r   s     r   Htest_from_multipoint_without_tolerace_without_floating_point_coordinatesr]   }   s.    	3	4Bb!Gw}}"""r   )__doc__numpyr   rJ   shapely.geometryr   shapely.opsr   shapely.wktr   r4   r   r   r(   r8   r;   rA   rE   rQ   rU   rX   r[   r]    r   r   <module>rd      s\      ' ' )##J:
;##OO
O	O#r   