o
    ZqiG                     @   sN   d dl Z d dlZd dl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)	polylabel)
LineStringPointPolygonc                   @   sJ   e Zd Zdd Zdd Zdd Zdd Zejj	e
jd	k d
d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
   gMbP?)Z	tolerancegM@gQ[@N)r   bufferr   r   Zequals_exact)selfpolygonlabelexpected r   j/home/app/PaddleOCR-VL/.venv_paddleocr/lib/python3.10/site-packages/shapely/tests/legacy/test_polylabel.pytest_polylabel   s   
z PolylabelTestCase.test_polylabelc                 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   Zconcave_polygonr   r   r   r   test_concave_polygon   s
   z&PolylabelTestCase.test_concave_polygonc                 C   s|   t g d}t|}tjdkr|jdd dgksJ dS tjdkr0|jdd dgks.J dS |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   )      r   N)|Pk\@@gek}L]r      r   )r   gRL])r   gמYM])r   r   shapelygeos_versionZcoordsr   r   r   r   r   r   test_rectangle_special_case#   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%   )shellZholesg?g     @N)r   r   xpytestapproxyr"   r   r   r   test_polygon_with_hole=   s   
z(PolylabelTestCase.test_polygon_with_holer   zFails with GEOS < 3.12)reasonc                 C   s>   t d}t|}|jtdksJ |jtdksJ d S )NzPOLYGON ((536520.0679737709 5438764.374763639, 536520.0679737704 5438764.374763602, 536520.0679737709 5438764.374763642, 536520.0679737709 5438764.374763639))g`"_ Ag   KTA)r    Zfrom_wktr   r)   r*   r+   r,   r"   r   r   r   test_polygon_infinite_loopJ   s   z,PolylabelTestCase.test_polygon_infinite_loopN)__name__
__module____qualname__r   r   r#   r-   r*   markZskipifr    r!   r/   r   r   r   r   r   
   s    
r   )Zunittestr*   r    Zshapely.algorithms.polylabelr   Zshapely.geometryr   r   r   ZTestCaser   r   r   r   r   <module>   s    