a
    ßÁdJ4  ã                   @   s\  d dl Z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mZmZ ejZejZejZej dejejejg¡ej de d¡e d	¡e d
¡dejdded�g¡dd„ ƒƒZej dejejejejg¡ej dejddgejd�de egg¡dg¡dd„ ƒƒZ ej dejejejg¡ej degdd dgdgg¡dd„ ƒƒZ!ejded�Z"de"j#_$ej dejejejg¡ej dg d¢e d¡e"ejded�ejded�ejded�g¡d d!„ ƒƒZ%d"d#„ Z&d$d%„ Z'd&d'„ Z(ej d(d dgeee	dgfd dgede	egfddgddeegfg¡d)d*„ ƒZ)ej d+ddgddggd d geddgddggƒgfg d,¢g d-¢gd d geg d,¢g d-¢gƒgfddgddgddgddggg d.¢eddgddggƒeddgddggƒgfg¡d/d0„ ƒZ*d1d2„ Z+ej d(g d3¢e
e
e	dgfg d4¢e
de	e
gfg d5¢dde
e
gfg¡d6d7„ ƒZ,ej dddgddgddgddggddgddgddggg¡d8d9„ ƒZ-ej ddej.gddgddgddggg¡d:d;„ ƒZ/d<d=„ Z0ej d(g d>¢edde	gfg d?¢dede	gfg d@¢dddegfg¡dAdB„ ƒZ1ej dCddg¡ej dDdEdFg¡dGdH„ ƒƒZ2e g dI¢¡Z3e g dJ¢¡Z4e 5e¡Z6eƒ Z7ej5ee3gdK�Z8ej5ee4gdK�Z9ej5ee3e4gdK�Z:ej dLeegd dge6e6gfdegd dge7e6gfdeddgg d.¢e6e7gfee3egg dM¢e8e6gfeee3gg dN¢e6e8gfdeee3gg d.¢e6e8gfedee3gg d.¢e6e8gfedee3gg dO¢e6e8gfeede3gg dO¢e6e8gfeee3dgg dO¢e6e8gfee3e4egg dP¢e:e6gfee3ee4gg d.¢e8e9gfeee3e4gg dO¢e6e:gfee3de4egg dQ¢e:e6gfee3dee4gg dR¢e8e9gfee3ede4gg dS¢e8e9gfg¡dTdU„ ƒZ;ej d(d dge6e6e	dgfd dge6de	e6gfddgdde6e6gfg¡dVdW„ ƒZ<ej dej5ejejejejg¡ej de eg¡dd dgdgg¡dXdY„ ƒƒZ=ej dZee
gd d geee
gƒgfee
gd dgeegƒee
gƒgfedgd d geegƒgfedgd dgeegƒeg ƒgfdeddgg d.¢eegƒeg ƒgfede
gg d[¢eee
gƒgfg¡d\d]„ ƒZ>d^d_„ Z?ej d(d d geee
gƒdde	gfddgdddeee
gƒgfg¡d`da„ ƒZ@dbdc„ ZAddde„ ZBdfdg„ ZCdhdi„ ZDej djegej5fe
gej5fegej5fe
gejfegejfegejfegejfegejfe
gejfg	¡dkdl„ ƒZEdS )mé    N)Ú
LinearRingÚPolygon)Úassert_geometries_equalé   )Úempty_pointÚline_stringÚlinear_ringÚpointÚpolygonÚfuncÚcoordinates)é   )r   é   r   )r   r   )r   r   Zfoo©Zdtypec                 C   sB   t  ttf¡�  | |ddgd� W d   ƒ n1 s40    Y  d S ©Nr   r   ©Úindices©ÚpytestÚraisesÚ	TypeErrorÚ
ValueError)r   r   © r   úf/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/shapely/tests/test_creation_indices.pyÚtest_invalid_coordinates   s    r   Ú
geometriesr   Zhelloc                 C   sB   t  ttf¡�  | |ddgd� W d   ƒ n1 s40    Y  d S r   r   )r   r   r   r   r   Útest_invalid_geometries!   s    r   r   z helloéÿÿÿÿc                 C   sD   t  ttf¡�" | ddgg|d� W d   ƒ n1 s60    Y  d S )Nçš™™™™™É?ç333333Ó?r   r   ©r   r   r   r   r   Útest_invalid_indices_simple2   s    r!   é   FÚout)NNN)r"   r   r   c                 C   s°   | t ju r$ddgddgg}ddg}nL| t ju r`ddgddgddgddgdd	gd	d	gg}g d
¢}nttg}ddg}t ttf¡� | |||d� W d   ƒ n1 s¢0    Y  d S )Nr   r   çš™™™™™Ù?g      à?r   r   r   r"   r   )r   r   r   r   r   r   ©r   r#   )	ÚshapelyÚpointsÚlinestringsr	   r   r   r   r   r   )r   r#   Úxr   r   r   r   Útest_invalid_out?   s    


(
r*   c                   C   sN   t  tj¡�. tjddgddggddgd� W d   ƒ n1 s@0    Y  d S ©Nr   r   r   r   )r   r   r&   ÚGEOSExceptionr'   r   r   r   r   Útest_points_invalid[   s    r-   c                  C   sF   t jtjddgddggtd�tjddgtjd�d�} t| ttgƒ d S )Nr   r"   r   r   r   r   )r&   r'   ÚnpÚarrayÚfloatÚintpr   r	   ©Úactualr   r   r   Útest_pointsa   s
    þr4   c                   C   sb   t  t¡�D tjtjddgddggtd�tjddgtjd�d� W d   ƒ n1 sT0    Y  d S )Nr   r"   r   r   r   )	r   r   r   r&   r'   r.   r/   r0   r1   r   r   r   r   Útest_points_no_index_raisesi   s
    þr5   zindices,expectedc                 C   sL   t jdtd�}t|d< tjddgddgg| |d�}t||ƒ ||u sHJ ‚d S )Nr   r   r   r"   r%   )r.   ÚemptyÚobjectr   r&   r'   r   ©r   Úexpectedr#   r3   r   r   r   Útest_points_outq   s    	ý
r:   zcoordinates,indices,expected)r   r   r   )r   r   r   )r   r   r   r   c                 C   s2   t jtj| td�tj|tjd�d�}t||ƒ d S ©Nr   r   )r&   r(   r.   r/   r0   r1   r   )r   r   r9   r3   r   r   r   Útest_linestrings…   s    ÿr<   c                   C   sN   t  tj¡�. tjddgddggddgd� W d   ƒ n1 s@0    Y  d S r+   )r   r   r&   r,   r(   r   r   r   r   Útest_linestrings_invalid˜   s    r=   )r   r   r   r   r   r   )r   r   r   r"   r"   r"   )r   r   r   r"   r"   r"   c                 C   sD   t jdtd�}t|d< tjg d¢| |d�}t||ƒ ||u s@J ‚d S )Nr   r   r   )©r   r   ©r   r   ©r   r   r>   r?   r@   r%   )r.   r6   r7   r   r&   r(   r   r8   r   r   r   Útest_linestrings_outž   s    	ý
rA   c                 C   s>   t jtj| tjd�tjt| ƒtjd�d�}t|t  | ¡ƒ d S r;   )	r&   Úlinearringsr.   r/   Úfloat64ÚzerosÚlenr1   r   )r   r3   r   r   r   Útest_linearrings²   s
    þrF   c                 C   sL   t  tjtf¡�( tj| t t| ƒ¡d� W d   ƒ n1 s>0    Y  d S ©Nr   )	r   r   r&   r,   r   rB   r.   rD   rE   )r   r   r   r   Útest_linearrings_invalid½   s    rH   c                  C   s.   t jg d¢t d¡d�} t| tg d¢ƒƒ d S )N)r>   r>   r>   r"   r   )r>   r>   r>   r>   )r&   rB   r.   rD   r   r   r2   r   r   r   Ú*test_linearrings_unclosed_all_coords_equalÉ   s    rI   )r   r   r   r   r   )r   r   r   r   r   )r"   r"   r"   r"   r"   c                 C   sD   t jdtd�}t|d< tjg d¢| |d�}t||ƒ ||u s@J ‚d S )Nr   r   r"   )r>   r?   r@   )r   r   r>   r%   )r.   r6   r7   r   r&   rB   r   r8   r   r   r   Útest_linearrings_outÎ   s    	ý
rJ   ÚdimÚorderÚCÚFc           	      C   s¨   t j dd| ¡}t j| d| ¡|d�}t  tdƒd¡}tj||d�}t  	||d d …dgd d …f f¡}t j| d| ¡|d�}t  tdƒd¡}tj||d�}t
||ƒ d S )	Né
   r   é(   )rL   r   r   é2   é   )r.   ÚrandomZrandnZasarrayZreshapeÚrepeatÚranger&   rB   Zhstackr   )	rK   rL   ZcoordsZcoords1Zindices1Zresult1Zcoords2Zindices2Zresult2r   r   r   Útest_linearrings_bufferâ   s    "rV   ))r   r   )r   r$   )r$   r$   ))ç333333ã?rW   )rW   çš™™™™™é?)rX   rX   )Zholeszrings,indices,expected)r   r   r   )r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   c                 C   s2   t jtj| td�tj|tjd�d�}t||ƒ d S r;   )r&   Úpolygonsr.   r/   r7   r1   r   )Zringsr   r9   r3   r   r   r   Útest_polygonsû   s    .ÿrZ   c                 C   sD   t jdtd�}t|d< tjttg| |d�}t||ƒ ||u s@J ‚d S )Nr   r   r   r%   )r.   r6   r7   r   r&   rY   r   r   r8   r   r   r   Útest_polygons_out/  s
    	
r[   c                 C   s@   t  ttf¡� | tg|d� W d   ƒ n1 s20    Y  d S rG   )r   r   r   r   r	   r    r   r   r   Ú test_invalid_indices_collections?  s    r\   zgeometries,indices,expected)r   r   r   c                 C   s&   t jtj| td�|d�}t||ƒ d S r;   )r&   Úgeometrycollectionsr.   r/   r7   r   )r   r   r9   r3   r   r   r   Útest_geometrycollectionsO  s    ÿr^   c                   C   sN   t  t¡�0 tjtjttgt	d�ddgd� W d   ƒ n1 s@0    Y  d S )Nr   r   r   r   )
r   r   r   r&   r]   r.   r/   r	   r   r7   r   r   r   r   Ú(test_geometrycollections_no_index_raisesa  s    ÿr_   c                 C   sD   t jdtd�}t|d< tjttg| |d�}t||ƒ ||u s@J ‚d S )Nr   r   r"   r%   )	r.   r6   r7   r   r&   r]   r	   r   r   r8   r   r   r   Útest_geometrycollections_outh  s
    
r`   c                  C   s<   t jtjtgtd�tjdtjd�d�} t| t  tg¡ƒ d S ©Nr   r   r   )	r&   Úmultipointsr.   r/   r	   r7   rD   r1   r   r2   r   r   r   Útest_multipointsw  s    ÿrc   c                  C   s<   t jtjtgtd�tjdtjd�d�} t| t  tg¡ƒ d S ra   )	r&   Úmultilinestringsr.   r/   r   r7   rD   r1   r   r2   r   r   r   Útest_multilinestrings~  s    ÿre   c                  C   s<   t jtjtgtd�tjdtjd�d�} t| t  tg¡ƒ d S ra   )	r&   rd   r.   r/   r   r7   rD   r1   r   r2   r   r   r   Útest_multilinearrings…  s    ÿrf   c                  C   s<   t jtjtgtd�tjdtjd�d�} t| t  tg¡ƒ d S ra   )	r&   Úmultipolygonsr.   r/   r
   r7   rD   r1   r   r2   r   r   r   Útest_multipolygonsŒ  s    ÿrh   zgeometries,funcc                 C   s<   t  t¡� || dgd� W d   ƒ n1 s.0    Y  d S )Nr   r   )r   r   r   )r   r   r   r   r   Útest_incompatible_types“  s    ri   )FÚnumpyr.   r   r&   r   r   Zshapely.testingr   Úcommonr   r   r   r	   r
   r'   Zpntsr(   Zlstrsr]   Z	geom_collÚmarkZparametrizerB   r6   Úfullr7   r   rb   rd   rg   r/   r1   r   r!   Znon_writeableÚflagsZ	writeabler*   r-   r4   r5   r:   r<   r=   rA   rF   ÚnanrH   rI   rJ   rV   Zhole_1Zhole_2rY   ZpolyZ
poly_emptyZpoly_hole_1Zpoly_hole_2Zpoly_hole_1_2rZ   r[   r\   r^   r_   r`   rc   re   rf   rh   ri   r   r   r   r   Ú<module>   s¢  ÿûþ
üþ	&ÿÿÿúþýþ
**&ýýþ
ýþ
2ÿ
ÿþ
ýþ


ý
ý
ýýýýÜþ-
ýþ
ûþ
" "úþ
þþ









÷þ