
    Og                     n    d dl Z d dlZd dlmZmZ d dlmZ d dlmZm	Z	m
Z
  G d de j                        Zy)    N)Cell	polylabel)TopologicalError)
LineStringPointPolygonc                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)PolylabelTestCasec                     t        g d      j                  d      }t        |d      }t        dd      }|j	                  |d      sJ y)	zU
        Finds pole of inaccessibility for a polygon with a tolerance of 10

        )r   r   )2      )d   r   )   r   )ii)iji8r   
   )	tolerancegiM@g+"cdu^@gư>N)r   bufferr   r   equals_exact)selfpolygonlabelexpecteds       h/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/shapely/tests/legacy/test_polylabel.pytest_polylabelz PolylabelTestCase.test_polylabel   sO    
 P

&+ 	 'R0*,=>$$UD111    c                     t        g d      }t        j                  t              5  t	        |       ddd       y# 1 sw Y   yxY w)zw
        Makes sure that the polylabel function throws an exception when provided
        an invalid polygon.

        )r   )r   r   r   r   )r   r   )r   r   r   r   N)r   pytestraisesr   r   )r   bowtie_polygons     r   test_invalid_polygonz&PolylabelTestCase.test_invalid_polygon   s=     !L
 ]]+, 	&n%	& 	& 	&s	   <Ac                     t        dd      j                  d      }t        ddd|      }t        ddd|      }||k  sJ ||k  sJ ||k  du sJ ||k(  sJ ||k(  du sJ ||k7  sJ ||k7  du sJ ||kD  sJ ||kD  du sJ ||k\  sJ ||k\  du sJ y)zt
        Tests rich comparison operators of Cells for use in the polylabel
        minimum priority queue.

        r   r   r   FN)r   r   r   )r   r   cell1cell2s       r   test_cell_sortingz#PolylabelTestCase.test_cell_sorting#   s     1+$$S)Q2w'RR)u}}~~5(((~~5(((~~5(((u}}%'''~~5(((r   c                 x    t        g d      j                  d      }t        |      }|j                  |      sJ y)zt
        Finds pole of inaccessibility for a concave polygon and ensures that
        the point is inside.

        ))  r   r   )r   r'   )r'   r'   r   N)r   r   r   contains)r   concave_polygonr   s      r   test_concave_polygonz&PolylabelTestCase.test_concave_polygon8   s=     %%MNUU
 /*''...r   c                 ^    t        g d      }t        |      }|j                  dd dgk(  sJ y)a  
        The centroid algorithm used is vulnerable to floating point errors
        and can give unexpected results for rectangular polygons. Test
        that this special case is handled correctly.
        https://github.com/mapbox/polylabel/issues/3
        ))'\@@6[L])r,   9#J{M])G\@@r.   )r/   r-   N)g|Pk\@@gRL])r   r   coordsr   r   r   s      r   test_rectangle_special_casez-PolylabelTestCase.test_rectangle_special_caseD   s9     
 '"||A#;"<<<<r   c                     t        g dg dg      }t        |d      }|j                  t        j                  d      k(  sJ |j
                  t        j                  d      k(  sJ y)z
        Finds pole of inaccessibility for a polygon with a hole
        https://github.com/shapely/shapely/issues/817
        )r   )r   r   r   )r   r   r   )   r5   )   r5   )r6   r6   )r5   r6   r4   )shellholesg?g     @N)r   r   xr   approxyr1   s      r   test_polygon_with_holez(PolylabelTestCase.test_polygon_with_holeV   s[    
 >;<
 '4(ww&--0000ww&--0000r   N)	__name__
__module____qualname__r   r!   r%   r*   r2   r<    r   r   r
   r
   
   s     
2
&)*
/=$1r   r
   )unittestr   shapely.algorithms.polylabelr   r   shapely.errorsr   shapely.geometryr   r   r   TestCaser
   r@   r   r   <module>rF      s+      8 + 7 7W1)) W1r   