o
    Jf                     @   sV   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 de jZdS )    N)Cell	polylabel)TopologicalError)
LineStringPointPolygonc                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )PolylabelTestCasec                 C   s<   t g dd}t|dd}tdd}||dsJ dS )	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expected r   o/home/deployuser/azure_apps/autowriter/venv/lib/python3.10/site-packages/shapely/tests/legacy/test_polylabel.pytest_polylabel   s   
z PolylabelTestCase.test_polylabelc                 C   sD   t g d}tt t| W d   dS 1 sw   Y  dS )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_polygonr   r   r   test_invalid_polygon   s   
"z&PolylabelTestCase.test_invalid_polygonc                 C   s   t ddd}tddd|}tddd|}||k sJ ||ks"J ||kdu s*J ||ks0J ||kdu s8J ||ks>J ||kdu sFJ ||ksLJ ||kdu sTJ ||ksZJ ||kdu sbJ dS )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cell2r   r   r   test_cell_sorting#   s   z#PolylabelTestCase.test_cell_sortingc                 C   s,   t g dd}t|}||sJ dS )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   r   r   r   test_concave_polygon8   s
   z&PolylabelTestCase.test_concave_polygonc                 C   s0   t g d}t|}|jdd dgksJ dS )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   r   r   r   test_rectangle_special_caseD   s
   z-PolylabelTestCase.test_rectangle_special_casec                 C   sL   t g dg dgd}t|d}|jtdksJ |jtdks$J dS )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	   )   r-   )   r-   )r.   r.   )r-   r.   r,   )shellholesg?g     @N)r   r   xr   approxyr*   r   r   r   test_polygon_with_holeV   s   
z(PolylabelTestCase.test_polygon_with_holeN)	__name__
__module____qualname__r   r   r    r$   r+   r4   r   r   r   r   r   
   s    r   )unittestr   shapely.algorithms.polylabelr   r   shapely.errorsr   shapely.geometryr   r   r   TestCaser   r   r   r   r   <module>   s    