a
    1$e                     @   s  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	m
Z
mZ d dlZd dlmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZmZ d d	lmZ d d
lm Z m!Z! d dl"m#Z#m$Z$ d dlm%Z& d dl'm(Z(m)Z)m*Z* d dl+Z+dd Z,G dd dZ-dS )    N)assert_array_equal)	DataFrameIndex
MultiIndexSeriesconcat)
LinearRing
LineStringMultiLineString
MultiPointPointPolygonMultiPolygon)GeometryCollection)unary_union)wkt)GeoDataFrame	GeoSeries)GeoPandasBase)assert_geodataframe_equalgeom_almost_equals)assert_geoseries_equalgeom_equals)_compat)assert_frame_equalassert_index_equalassert_series_equalc                 O   s@   t | } t |}| j|jks$J t| |g|R i | d S N)npZ
asanyarraydtyper   )abargskwargs r$   ]/var/www/html/django/DPS/env/lib/python3.9/site-packages/geopandas/tests/test_geom_methods.pyassert_array_dtype_equal!   s    

r&   c                
   @   s>	  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zejjejpej d!d"d#d$ Zejjejpejd!d"d%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Z d3d4 Z!d5d6 Z"d7d8 Z#d9d: Z$d;d< Z%d=d> Z&d?d@ Z'dAdB Z(dCdD Z)dEdF Z*ejjejp\ej dGd"dHdI Z+ejjejpejdJd"dKdL Z,ejjejpej dMd"dNdO Z-ejjejpejdPd"dQdR Z.dSdT Z/dUdV Z0dWdX Z1dYdZ Z2d[d\ Z3d]d^ Z4d_d` Z5ejjejp ej dad"dbdc Z6ddde Z7dfdg Z8ej9dhdidj Z:dkdl Z;dmdn Z<dodp Z=dqdr Z>dsdt Z?dudv Z@dwdx ZAdydz ZBd{d| ZCejjejpej d}d"d~d ZDejjejpejdd"dd ZEejjejpejdd"dd ZFejjejpej dd"dd ZGejjejHdd"dd ZIejjejoVejH dd"dd ZJejjej dd"dd ZKejjej dd"ejLdg ddfg ddfgdd ZMdd ZNejjejpej dd"dd ZOejjejp ej dd"dd ZPejjejp$ejdd"dd ZQdd ZRdd ZSdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`dd Zadd ZbddĄ ZcddƄ ZdddȄ Zeddʄ Zfdd̄ Zgejjejpej dd"ddτ Zhejjejpejdd"dd҄ Ziejjejp<ej dd"ddՄ Zjddׄ Zkddل ZlejLdddgddބ ZmejLdddgdd ZnejLdddgdd Zodd Zpdd ZqejLdg ddd ZrejLdg ddd ZsejLdg ddd Ztdd Zudd Zvdd Zwdd ZxejLdddgdd Zydd Zzdd Z{d d Z|dd Z}dd Z~dd Zdd	 Zejjejpej d!d"d
d Zejjejpej d!d"dd Zejjejpej d!d"dd Zejjejpej d!d"dd ZejjejpBejd!d"dd Zejjejphej dd"dd Zejjejpejdd"dd Zejjejpej dd"ejLdg ddd Zejjejpej dd"dd Zejjejp$ej d!d"ejLdg dd d! Zejjejpbej d"d"d#d$ ZejjejHd%d"d&d' ZejjejoejH d(d"d)d* Zejjej d(d"ejLd+eeg d,eeg d-feeg d.eeg d/fgd0d1 ZdS (2  TestGeomMethodsc                    s0  t g d _t g d _t g d _t g d _t g d _t g d _t g d _t g d _t g d	 _	t g d
 _
t g d _t  jj jjg _tdd _tddd _t j j j j j jd g _t j jg _t j jg _t j jg _t j j jg _d j_t j jg _d j_t j jg _t j jt  g _t jd g _ j  _ddg j_ j  _ddg j_tddd _ tddd _!t j  j!gdd _"tdd _#t j  j! j#gdd _$t%&d _'t j  j! j# j'gdd _(t)g d _*t)g d _+t j* j+g _,t j jg _-t j jg _.t j j	g _/tg  _0td d g _1tt2g t2g g _3t   _4t jt5ddd _6t j jg _7t)ddg _8t)d d!g _9t j8 j9g _:t; jd"d#gd$d%gd& _<t; jd'dgd(d)gd* _=t; jd'dgd(d)gd* _>t; jg d+g d,d* _?t j j j' j j j4 j*g _@tABd-d-gd-d-gd.d.gd"d.gd"d"gd.d.gd"d"gd#d#gd/d/gd"d"gd.d.gd.d"gd"d"gg _CtABd-d-tAjDgg d0d.d.tAjDgd"d.tAjDgd"d"tAjDgd.d.tAjDgg d1g d2g d3g d1d.d.tAjDgd.d"tAjDgd"d"tAjDgg _Et fd4d5t5d6D  _Ft)g d7 _Gt)g d8 _Ht jGg _It jHg _Jt)g d7 _Gt)g d8 _Ht jGg _It jHg _Jd S )9N)r   r      r   r*   r*   r(   r+   r   r*      r      r   r2   r*   )r*   r*   r*   r0   r0   r0   r2   r2   r2   )r5   r4   r6   r(   r)   r+   r-   )r4   r5   r6   )   r8   r8   )r(   r1   r2   r2   r   r0   )r/   r1   r9   )r0   r2   )r/   r/   r1   r1   ))      ?r;   )      ?r;   )r<   r<   )r;   r<      z	epsg:4326ABC&SR):_D@S>@YڂR ~:XD@.n<?@crs  zPOINT EMPTYr(   r-   r+   r*      indexr(   r+   r-   r)         ?       @geopandas)geometryZcol0col1r8   randstring)rR   Zcol3Zcol4)r8   r=      )rT   rU   rP         @              @)rW   rW   rW   )rN   rN   rN   )rO   rO   rO   )rY   rY   rY   c                    s   g | ]
} j qS r$   )sq).0_selfr$   r%   
<listcomp>       z0TestGeomMethods.setup_method.<locals>.<listcomp>r2   ))d   r   r(   )r   ra   )r=   r=   )r=   ra   )ra   r=   )Kr   t1t2t3tzZtz1rZ   ZsqzZt4t5t6inner_sqboundarynested_squaresr   p0Zp3dr   g0g1g2g3gzrH   g4g_3dnana_nonecopya1rM   Za2esbsol	landmarksZpt2dlandmarks_mixedr   loadsZpt_emptylandmarks_mixed_emptyr	   l1l2g5g6g7g8emptyall_noner   all_geometry_collection_empty
empty_polyrangeg9g10l3l4crossed_linesr   gdf1Zgdf2gdf3gdfzg11r   arrayexpected_2dnanexpected_3dsquaresl5l6g12g13r]   r$   r]   r%   setup_method)   s   








zTestGeomMethods.setup_methodc                 C   s   t }| |||| dS )z,Tests for 'area', 'length', 'is_valid', etc.N)r   _test_unaryr^   opexpectedr    fcmpr$   r$   r%   _test_unary_real   s    z TestGeomMethods._test_unary_realc                 C   s,   t |trt}ndd }| |||| d S )Nc                 S   s   |  |sJ d S r   )equalsr    r!   r$   r$   r%   r      s    z5TestGeomMethods._test_unary_topological.<locals>.fcmp)
isinstancer   r   r   r   r$   r$   r%   _test_unary_topological   s    
z'TestGeomMethods._test_unary_topologicalc           	      O   sT   t |trt}ndd }t |tr(d}nd}| j|||||d|g|R i | dS )z?Tests for 'intersection', 'union', 'symmetric_difference', etc.c                 S   s   t | |sJ d S r   r   r   r$   r$   r%   r      s    z6TestGeomMethods._test_binary_topological.<locals>.fcmpTFNr   r   r   _binary_op_test)	r^   r   r   r    r!   r"   r#   r   right_dfr$   r$   r%   _test_binary_topological   s    

z(TestGeomMethods._test_binary_topologicalc                 O   s,   t }| j|||||ddg|R i | d S )NTF)r   r   )r^   r   r   r    r!   r"   r#   r   r$   r$   r%   _test_binary_real   s    z!TestGeomMethods._test_binary_realc              	   C   sF   t |trt}ndd }t |tr(d}nd}| |||||d| dS )z
        The operators only have GeoSeries on the left, but can have
        GeoSeries or GeoDataFrame on the right.
        If GeoDataFrame is on the left, geometry column is used.

        c                 S   s   t | |sJ d S r   r   r   r$   r$   r%   r      s    z3TestGeomMethods._test_binary_operator.<locals>.fcmpTFNr   )r^   r   r   r    r!   r   r   r$   r$   r%   _test_binary_operator   s    

z%TestGeomMethods._test_binary_operatorc                 O   s   dd }
t |||g|R i |	}||| |r`|
|}t |||g|R i |	}||| |r|
|}t |||g|R i |	}||| |rt |||g|R i |	}||| dS )a^  
        This is a helper to call a function on GeoSeries and GeoDataFrame
        arguments. For example, 'intersection' is a member of both GeoSeries
        and GeoDataFrame and can take either GeoSeries or GeoDataFrame inputs.
        This function has the ability to test all four combinations of input
        types.

        Parameters
        ----------

        expected : str
            The operation to be tested. e.g., 'intersection'
        left: GeoSeries
        right: GeoSeries
        fcmp: function
            Called with the result of the operation and expected. It should
            assert if the result is incorrect
        left_df: bool
            If the left input should also be called with a GeoDataFrame
        right_df: bool
            Indicates whether the right input should be called with a
            GeoDataFrame

        c                 S   s:   t | }tjd | }t|}t| j||d| j| jdS )N)rR   rS   col2rM   rH   )lenrU   ascii_lowercaser   r   valuesrM   rH   )snrS   r   r$   r$   r%   	_make_gdf  s    z2TestGeomMethods._binary_op_test.<locals>._make_gdfN)getattr)r^   r   r   leftrightr   Zleft_dfr   r"   r#   r   resultZgdf_leftZ	gdf_rightr$   r$   r%   r      s    


zTestGeomMethods._binary_op_testc                 C   s8   t ||}||| | j|}t ||}||| d S r   )r   r   set_geometry)r^   r   r   r    r   r   gdfr$   r$   r%   r   -  s
    


zTestGeomMethods._test_unaryc                 C   s   |  d| j| j| j tjtdd& |  d| j| j| j W d    n1 sP0    Y  tjtdd. t	| j
j| jdddksJ W d    n1 s0    Y  t	| j
j| jdddksJ d S )	NintersectionThe indices .+ differentmatchTalignrK   F   )r   rc   rn   ro   pytestwarnsUserWarningr   r   r   rm   r   r   r]   r$   r$   r%   test_intersection@  s    "<z!TestGeomMethods.test_intersectionc                 C   s@   | j d| j| jg| jjR   | j d| j| jg| jjR   d S )NZclip_by_rect)r   rn   r   rZ   boundsr   re   r]   r$   r$   r%   test_clip_by_rectK  s    

z!TestGeomMethods.test_clip_by_rectc                 C   s   |  d| j| j| j tjtdd. t| jj	| j
dddksDJ W d    n1 sX0    Y  t| jj	| j
dddksJ d S )	Nunionr   r   Tr   rK   Fr   )r   rZ   rn   ro   r   r   r   r   rm   r   r   r]   r$   r$   r%   test_union_seriesT  s    <z!TestGeomMethods.test_union_seriesc                 C   s   |  d| j| j| j d S )Nr   )r   rZ   rn   rd   r]   r$   r$   r%   test_union_polygon[  s    z"TestGeomMethods.test_union_polygonc                 C   s   |  d| j| j| j tjtdd. t| jj	| j
dddksDJ W d    n1 sX0    Y  t| jj	| j
dddksJ d S )	Nsymmetric_differencer   r   Tr   rK   Fr   )r   rZ   rp   rr   r   r   r   r   rm   r   r   r]   r$   r$   r%    test_symmetric_difference_series^  s    <z0TestGeomMethods.test_symmetric_difference_seriesc                 C   s0   t t | jg| jjd}| d|| j| j d S )NrG   r   )r   r   rZ   rp   rH   r   rc   r^   r   r$   r$   r%   test_symmetric_difference_polye  s    z.TestGeomMethods.test_symmetric_difference_polyc                 C   s   t t | jg}| d|| j| j tjtdd. t	| j
j| jdddksRJ W d    n1 sf0    Y  t	| j
j| jdddksJ d S )	N
differencer   r   Tr   rK   Fr   )r   r   rd   r   rn   ro   r   r   r   r   rm   r   r   r   r$   r$   r%   test_difference_seriesk  s
    <z&TestGeomMethods.test_difference_seriesc                 C   s(   t | j| jg}| d|| j| j d S )Nr   )r   rc   r   rn   rd   r   r$   r$   r%   test_difference_polys  s    z$TestGeomMethods.test_difference_polyz-get_coordinates not implemented for shapely<2)reasonc                 C   s   t tddgd g}t|| j| j t tddgtddgg}t|| j| j t tddgtddgg}| jd d d }t|| jj|dd d S )Nr+   rb   r/   )      ?r   Fr   )	r   r	   r&   ru   shortest_linerl   r   r   r   )r^   r   Zcrossed_lines_invr$   r$   r%   test_shortest_linew  s    

z"TestGeomMethods.test_shortest_linec                 C   s@   t jtdd | j| j W d    n1 s20    Y  d S Nz$shapely >= 2.0 or PyGEOS is requiredr   )r   raisesNotImplementedErrorru   r   rl   r]   r$   r$   r%   test_shortest_line_not  s    z&TestGeomMethods.test_shortest_line_notc                 C   sz   t ddg}t ddg}tt g}t|g|}t|| t|gt|g}t|| tt gj}t|| d S )Nr(   r+   r0   r0   r9   )r	   r   r   r   r   convex_hull)r^   r~   r   r   r   r$   r$   r%   test_geo_op_empty_result  s    

z(TestGeomMethods.test_geo_op_empty_resultc                 C   sF   t g d}t g d}t||g| jj| jjd}| d|| j d S )Nr(   r)   r+   r(   )r(   r)   r+   r-   r(   r   rj   )r	   r   rn   rM   rH   r   )r^   r~   r   r   r$   r$   r%   test_boundary  s    zTestGeomMethods.test_boundaryc                 C   sZ   t tddg| jjd}| d|| j t tdtjg| jjd}| d|| j d S )Nr   rN   rL   area)r   r   r   rn   rM   r   r   ru   r   r$   r$   r%   	test_area  s    zTestGeomMethods.test_areac                 C   s:   t jtdd | jj W d    n1 s,0    Y  d S NGeometry is in a geographic CRSr   )r   r   r   rr   r   r]   r$   r$   r%   test_area_crs_warn  s    z"TestGeomMethods.test_area_crs_warnc                 C   sd   t ddgddgddgddgd| jjg dd}| jj}t|| | j| j}|j}t|| d S )NrX   rN   ZminxZminyZmaxxZmaxy)rM   columns)r   rn   rM   r   r   r   r   )r^   r   r   r   r$   r$   r%   test_bounds  s    
zTestGeomMethods.test_boundsc                 C   s0   t g }|j}tg d|jdd}t|| d S )Nr   float64)r   rM   r   )r   r   r   rM   r   )r^   r   r   r   r$   r$   r%   test_bounds_empty  s    z!TestGeomMethods.test_bounds_emptyc                 C   s   | j }tg d}t||g}t||g}| d|| t|d g}| d|| tjtdd* td d g}|jd u s|J W d    n1 s0    Y  d S )Nr.   r   z`unary_union` returned Noner   )rc   r   r   r   r   r   r   FutureWarning)r^   p1p2r   gro   rp   r$   r$   r%   test_unary_union  s    z TestGeomMethods.test_unary_unionc                 C   sd   | j }tg d}t||g}tjtdd |j}W d    n1 sH0    Y  ||jks`J d S )Nr.   z,The 'cascaded_union' attribute is deprecatedr   )rc   r   r   r   r   r   Zcascaded_unionr   )r^   r   r   r   r   r$   r$   r%   test_cascaded_union_deprecated  s    $z.TestGeomMethods.test_cascaded_union_deprecatedc                 C   s   g d}t || j| j g d}tjtdd( t || jj| jdd W d    n1 s`0    Y  g d}t || jj| jdd d S )	N)TFTFFFFFTTTTTFFr   r   Tr   FFTFFFFF)r&   rm   containsrc   r   r   r   r   r   r$   r$   r%   test_contains  s    6zTestGeomMethods.test_containsc                 C   sn   t tdtd dg| jjd}| d|| j t tdtd tjg| jjd}| d|| j d S )Nr0   r8   rL   length)	r   r   r   sqrtrn   rM   r   r   ru   r   r$   r$   r%   test_length  s    $&zTestGeomMethods.test_lengthc                 C   s:   t jtdd | jj W d    n1 s,0    Y  d S r   )r   r   r   rr   r   r]   r$   r$   r%   test_length_crs_warn  s    z$TestGeomMethods.test_length_crs_warnc                 C   s   g d}t || j| j ddg}t || j| j dgd }tjtdd( t || jj| j	dd W d    n1 s~0    Y  dgd }t || jj| j	dd d S )	N)FFFFFFFFTrK   r   r   r   r   )
r&   rm   Zcrossesrc   r   r   r   r   r   r   r   r$   r$   r%   test_crosses  s    
6
zTestGeomMethods.test_crossesc                 C   s   g d}t || j| j dgd }tjtdd( t || jj| jdd W d    n1 sb0    Y  g d}t || jj| jdd d S )	N)FFFFFTFFrK   r   r   Tr   )FFFFTFF)r&   rm   Zdisjointrc   r   r   r   r   r   r$   r$   r%   test_disjoint  s    
6zTestGeomMethods.test_disjointc                 C   s   t g d| jjd}t|| j| j t dd g| jjd}t|| j| j t g dtdd}t	j
tdd( t|| jj| jdd	 W d    n1 s0    Y  t g d
| jjd}t|| jj| jdd	 d S )N)	212101212r   	212FF1FF2	2FFF1FFF2Z	FF2F112F2	FF0FFF212NrL   r   )Nr   r   r   r   Z	0FFFFFFF2NNrK   r   r   Tr   )Z	FF2F11212Z	2FF11F212r   Z	FF2F1F212Z	FF2FF10F2NNF)r   rm   rM   r&   Zrelateri   r   ru   r   r   r   r   r   r   r$   r$   r%   test_relate  s$    	
6	zTestGeomMethods.test_relatec                 C   s4  t ttdtjg| jj}t|| j| j	 t ttdtjg| j
j}t|| j
| j t ttjdddddtjtjgtd}tjtdd( t|| jj| jdd W d    n1 s0    Y  | jjd | jjd }t tdddd|tjtjg| jj}t|| jj| jd	d d S )
N    r   rK   r   r   Tr   r8   F)r   r   r   r   r   ru   rM   r&   distancerl   r   r   r   r   r   rm   r   iloc)r^   r   valr$   r$   r%   test_distanceP  s     *6&zTestGeomMethods.test_distancec                 C   s@   t jtdd | j| j W d    n1 s20    Y  d S r   )r   r   r   rr   r   rl   r]   r$   r$   r%   test_distance_crs_warninga  s    z)TestGeomMethods.test_distance_crs_warningz+requires hausdorff_distance in shapely 2.0+c                 C   s  t ttdtjg| jj}t|| j| j	 t ttdtjg| jj}t|| j| j	 t ttjdddddtjtjgt
d}tjtdd( t|| jj| jdd W d    n1 s0    Y  | jjd | jjd }| jjd | jjd }| jjd	 | jjd	 }t t|||||tjtjg| jj}t|| jj| jd
d t tdg| jj}t|| jj| jdd d S )N2   r   rK   r   r   Tr   r0   r8   Fg     @J@r;   Zdensify)r   r   r   r   r   ru   rM   r&   hausdorff_distancerl   r   r   r   r   rm   r   r  r   r   )r^   r   val_1val_2val_3r$   r$   r%   test_hausdorff_distancee  s4    *" z'TestGeomMethods.test_hausdorff_distancez0hausdorff_distance not implemented for shapely<2c                 C   s@   t jtdd | j| j W d    n1 s20    Y  d S r   )r   r   r   rm   r  r   r]   r$   r$   r%   test_hausdorff_distance_not  s    z+TestGeomMethods.test_hausdorff_distance_notz)requires frechet_distance in shapely 2.0+c                 C   sL  t ttdtjg| jj}t|| j| j	 t ttjdddddtjtjgt
d}tjtdd( t|| jj| jdd W d    n1 s0    Y  d}td	d
 }td	d	 }td	d	 d }t t|||||tjtjg| jj}t|| jj| jdd t ttdg| jj}t|| jj| jdd d S )Nr  r   rK   r   r   Tr   rN   r0   r8   
   FiQJ  r;   r  )r   r   r   r   r   ru   rM   r&   frechet_distancerl   r   r   r   r   rm   r   r   r   )r^   r   r  r	  r
  Zval_4r$   r$   r%   test_frechet_distance  s2    *" z%TestGeomMethods.test_frechet_distancez.frechet_distance not implemented for shapely<2c                 C   s@   t jtdd | j| j W d    n1 s20    Y  d S r   )r   r   r   rm   r  r   r]   r$   r$   r%   test_frechet_distance_not  s    z)TestGeomMethods.test_frechet_distance_notc                 C   s  g d}t || j| j ddg}t || j| j tjg td}t || j	| j tjg td}t || j	| j
 dgd }t || j| j
 g d}tjtdd( t || jj| jdd	 W d    n1 s0    Y  g d
}t || jj| jdd	 d S )NTTTTTFFTF)r   r   r   r   r   r   )TTTTFFF)r&   rm   Z
intersectsrc   ru   rd   r   r   boolr   r   r   r   r   r   r   r$   r$   r%   test_intersects  s    
6zTestGeomMethods.test_intersectsc                 C   s   g d}t || j| j ddg}t || j| j dgd }tjtdd( t || jj| j	dd W d    n1 s~0    Y  dgd }t || jj| j	dd d S )	N)TTFFFFFFrK   r   r   Tr   r   )
r&   rm   overlapsri   rr   rc   r   r   r   r   r   r$   r$   r%   test_overlaps  s    
6
zTestGeomMethods.test_overlapsc                 C   s   g d}t || j| j dgd }tjtdd( t || jj| jdd W d    n1 sb0    Y  g d}t || jj| jdd d S )	NFTFFFFFFrK   r   r   Tr   )TFFTFFF)r&   rm   Ztouchesrc   r   r   r   r   r   r$   r$   r%   test_touches  s    
6zTestGeomMethods.test_touchesc                 C   s   g d}t || j| j g d}t || j| j g d}tjtdd( t || jj| jdd W d    n1 s|0    Y  g d}t || jj| jd	d d S )
N)TFFFFFFr  r   r   r   Tr   r  F)	r&   rm   Zwithinrc   rZ   r   r   r   r   r   r$   r$   r%   test_within  s    6zTestGeomMethods.test_withinc                 C   s(   | j | j }tddg}t|| d S )NT)rn   coversr   r   r^   resexpr$   r$   r%   test_covers_itself   s    z"TestGeomMethods.test_covers_itselfc                 C   s   | j | j}tddg}t|| g d}tjtdd( t|| j	j| j
dd W d    n1 sh0    Y  g d}t|| j	j| j
dd d S )NTFr   r   r   r   r   )r   r  r   r   r   r   r   r   r&   rm   r   r^   r  r  r   r$   r$   r%   test_covers  s    
6zTestGeomMethods.test_coversc                 C   s(   | j | j}tddg}t|| d S )NF)r   r  r   r   r   r  r$   r$   r%   test_covers_inverse  s    z#TestGeomMethods.test_covers_inversez6covered_by is only implemented for pygeos, not shapelyc                 C   s   | j | j }tddg}t|| g d}tjtdd( t|| jj| j	dd W d    n1 sh0    Y  g d}t|| jj| j	dd d S )NTr   r   r   r   r  F)
rn   Z
covered_byr   r   r   r   r   r&   rm   r   r  r$   r$   r%   test_covered_by  s    
6zTestGeomMethods.test_covered_byc                 C   s4   t tdgt| j | jj}| d|| j d S )NTis_validr   r   r   r   rn   rM   r   r   r$   r$   r%   test_is_valid'  s     zTestGeomMethods.test_is_validc                 C   s4   t tdgt| j | jj}| d|| j d S )NFis_emptyr#  r   r$   r$   r%   test_is_empty+  s     zTestGeomMethods.test_is_emptyzignore:is_ring:FutureWarningc                 C   s4   t tdgt| j | jj}| d|| j d S )NTZis_ringr#  r   r$   r$   r%   test_is_ring0  s     zTestGeomMethods.test_is_ringc                 C   s4   t tdgt| j | jj}| d|| j d S )NTZ	is_simpler#  r   r$   r$   r%   test_is_simple5  s     zTestGeomMethods.test_is_simplec                 C   s&   t ddg| jj}| d|| j d S )NFTZhas_z)r   rs   rM   r   r   r$   r$   r%   
test_has_z9  s    zTestGeomMethods.test_has_zc                 C   sh   ddg}ddg}ddg}t || jjj t || jjj t || jjj ddtjg}t || jjj d S NrA   rD   rB   rE   rC   rF   )	r&   rz   rR   xyzr   r   r{   r^   Z
expected_xZ
expected_yZ
expected_zr$   r$   r%   test_xyz_points=  s    zTestGeomMethods.test_xyz_pointsc                 C   s`   dddt jg}dddt jg}ddt jt jg}t|| jjj t|| jjj t|| jjj d S r*  )r   r   r&   r}   rR   r+  r,  r-  r.  r$   r$   r%   test_xyz_points_emptyJ  s    z%TestGeomMethods.test_xyz_points_emptyc                 C   s   t t | jjj}W d    n1 s*0    Y  t t | jjj}W d    n1 s^0    Y  t t | jjj}W d    n1 s0    Y  d S r   )	r   r   
ValueErrorr   rR   r+  r,  r   r-  )r^   r\   r$   r$   r%   test_xyz_polygonsS  s    ((z!TestGeomMethods.test_xyz_polygonsc                    sZ   t g dtdd tfddtdD }t fddtdD }t|j| d S )N))r   r   )r*   r   r+   )r   r*   r   c                    s   g | ]} qS r$   r$   r[   i)polygonr$   r%   r_   a  r`   z1TestGeomMethods.test_centroid.<locals>.<listcomp>r2   c                    s   g | ]} qS r$   r$   r3  )pointr$   r%   r_   b  r`   )r   r   r   r   r   centroid)r^   ZpolygonsZpointsr$   )r6  r5  r%   test_centroid^  s
    
zTestGeomMethods.test_centroidc                 C   s:   t jtdd | jj W d    n1 s,0    Y  d S r   )r   r   r   rr   r7  r]   r$   r$   r%   test_centroid_crs_warne  s    z&TestGeomMethods.test_centroid_crs_warnc                 C   s\   t g d}tg d}tdd}t|||g}t g d}t|||g}t| | d S )Nr,   r(   r+   r)   r   rJ   )r   r	   r   r   r   	normalize)r^   r5  
linestringr6  seriespolygon2r   r$   r$   r%   test_normalizei  s    
zTestGeomMethods.test_normalizec           	      C   s   t g d}t g d}tg d}t|||g}tt g dt g dg}tt g dtddgg}t|||g}|j rJ | }t|| |j sJ d S )	N)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	   r   r   r   r"  allZ
make_validr   )	r^   Zpolygon1r>  r<  r=  Zout_polygon1Zout_polygon2r   r   r$   r$   r%   test_make_validr  s"    


zTestGeomMethods.test_make_validz9reverse is only implemented for pygeos and shapely >= 2.0c                 C   s0   t tg dtg dg}t|| j  d S )NrJ   r7   )r   r	   r   r   reverser   r$   r$   r%   test_reverse  s    

zTestGeomMethods.test_reversez%reverse not implemented for shapely<2c                 C   s<   t jtdd | j  W d    n1 s.0    Y  d S r   )r   r   r   r   rB  r]   r$   r$   r%   test_reverse_not_implemented  s    z,TestGeomMethods.test_reverse_not_implementedz,segmentize keyword introduced in shapely 2.0c                 C   sX   t tddg}tjtdtj dd |jdd W d    n1 sJ0    Y  d S )Nr*   .shapely >= 2.0 or PyGEOS is required, version  is installedr   Zmax_segment_length)r   r   r   r   r   shapely__version__
segmentizer^   r   r$   r$   r%   test_segmentize_shapely_pre20  s    z-TestGeomMethods.test_segmentize_shapely_pre20c                 C   sd   t tdtdg}t tg dtg dg}| jjdd}| jjdd}t|| t|| d S )N)r(   r   r   r)   r*   r   r+   )UUUUUU?rO  )UUUUUU?rP  r(   )	r(   rM  r)   rN  r+   r   r*   r-   r   r   r(   )r(   rR  r-   rQ  r+   )r(   rM  r)   rN  r+   rQ  r-   r   rG  )r   r   r	   rn   rJ  r   r   )r^   Zexpected_g1Zexpected_g5Z	result_g1Z	result_g5r$   r$   r%   test_segmentize_linestrings  s(    !

z+TestGeomMethods.test_segmentize_linestringsz.concave_hull is implemented for shapely >= 2.0c                 C   sF   t jtdtj dd | j  W d    n1 s80    Y  d S Nz$shapely >= 2.0 is required, version rF  r   )r   r   r   rH  rI  r   concave_hullr]   r$   r$   r%   .test_concave_hull_not_implemented_shapely_pre2  s    z>TestGeomMethods.test_concave_hull_not_implemented_shapely_pre2z3concave_hull is only implemented for shapely >= 2.0c                 C   s^   t tg dtg dg}tjtdd  t|| j  W d    n1 sP0    Y  d S )N)r-   r+   r(   r-   )r)   r(   r-   r+   r)   zCPyGEOS does not support concave_hull, and Shapely >= 2 is installedr   )r   r   r   r   r   r   r   rU  r   r$   r$   r%   .test_concave_hull_pygeos_set_shapely_installed  s    

z>TestGeomMethods.test_concave_hull_pygeos_set_shapely_installedc                 C   s   t | j| j  d S r   )r   r   rU  r]   r$   r$   r%   test_concave_hull  s    z!TestGeomMethods.test_concave_hullzexpected_series,ratio)r(   r   r2   r+   r9   r1   r(   rX   )r(   rY  r9   r1   r(   rN   c                 C   s2   t t|}t tg d}t||j|d d S )N)r(   rY  r+   r1   r9   )ratio)r   r   r   r   rU  )r^   Zexpected_seriesrZ  r   r   r$   r$   r%    test_concave_hull_accepts_kwargs  s    z0TestGeomMethods.test_concave_hull_accepts_kwargsc                 C   s   t | j| jj d S r   )r   r   r   r]   r$   r$   r%   test_convex_hull  s    z TestGeomMethods.test_convex_hullz0delaunay_triangles not implemented for shapely<2c                 C   sN   t ttg dgttg dgg}| j }t|t s@J t|| d S )Nr   )r-   r(   r+   r-   )r   r   r   rp   delaunay_trianglesr   r   r^   r   Zdltr$   r$   r%   test_delaunay_triangles  s    
z'TestGeomMethods.test_delaunay_trianglesc                 C   sb   t tddgddgddggtddgddgddggg}| jjdd}t|t sTJ t|| d S )Nr(   r+   r)   r-   T)Z
only_edges)r   r
   rp   r]  r   r   r^  r$   r$   r%   #test_delaunay_triangles_pass_kwargs$  s    z3TestGeomMethods.test_delaunay_triangles_pass_kwargsz,delaunay_triangles implemented for shapely>2c                 C   sT   t tddg}tjtdtj dd |  W d    n1 sF0    Y  d S )Nr*   rE  rF  r   )r   r   r   r   r   rH  rI  r]  rK  r$   r$   r%   %test_delaunay_triangles_shapely_pre203  s    z5TestGeomMethods.test_delaunay_triangles_shapely_pre20c                 C   s>   t dd | jD }t|| jjD ]\}}||s"J q"d S )Nc                 S   s   g | ]}t |jqS r$   )r   rj   )r[   pr$   r$   r%   r_   A  r`   z1TestGeomMethods.test_exterior.<locals>.<listcomp>)r   rp   zipZexteriorr   )r^   Zexp_exteriorr   Zcomputedr$   r$   r%   test_exterior@  s    zTestGeomMethods.test_exteriorc                 C   sN   t | j| jg}g }|jd |ks&J t| jj}|jd d |sJJ d S )Nr   r*   )r   rc   rk   Z	interiorsr   ri   rj   r   )r^   originalr   r$   r$   r%   test_interiorsE  s
    zTestGeomMethods.test_interiorsc                 C   s\   t tddtddg}| jd|| jddd t tddtddg}| d|| jd d S )Nr   rN   r<   interpolateT
normalized      ?)r   r   r   r   r   r$   r$   r%   test_interpolateO  s    z TestGeomMethods.test_interpolatec              	   C   sp   t tddtddg}| d|| jtddg t tddtddg}| jd|| jtddgdd d S )	NrX   r<   rN   r   rg  rj  Trh  )r   r   r   r   r   r   r   r$   r$   r%   test_interpolate_distance_arrayX  s    z/TestGeomMethods.test_interpolate_distance_arrayc                 C   sH   t g d}tt | j| W d    n1 s:0    Y  d S Nr*   r0   r2   )r   r   r   r   r1  r   rg  r^   	distancesr$   r$   r%   &test_interpolate_distance_wrong_lengthc  s    z6TestGeomMethods.test_interpolate_distance_wrong_lengthc                 C   sN   t ddgddgd}tt | j| W d    n1 s@0    Y  d S )Nr*   r0   c   b   rL   )r   r   r   r1  r   rg  ro  r$   r$   r%   %test_interpolate_distance_wrong_indexh  s    z5TestGeomMethods.test_interpolate_distance_wrong_indexc                 C   sL   | j  }d|_tjtdd |d W d    n1 s>0    Y  d S )NrI   r   r   r*   )r   rv   rH   r   r   r   rg  )r^   Zg5_crsr$   r$   r%   test_interpolate_crs_warningm  s    
z,TestGeomMethods.test_interpolate_crs_warningc                 C   s   t ddg| jjd}tdd}| d|| j| t ddg| jjd}| jd|| j|dd ttd	d	tddgd
d	gd}t tjdtjg}tj	t
dd" t| j|| W d    n1 s0    Y  t ddg| jjd}t| jj|dd| d S )NrO   rj  rL   rN   r   projectTrh  r0   r*   r   r   Fr   )r   r   rM   r   r   r   r   r   r   r   r   r   rv  )r^   r   rb  r   r$   r$   r%   test_projects  s    
 0zTestGeomMethods.test_projectc                 C   s(   g d}| j }| j|}t|| d S )N)r   r*   r*   r   r   r   )rr   rp   Zaffine_transformr   )r^   matrixr   r  r$   r$   r%   test_affine_transform  s    z%TestGeomMethods.test_affine_transformc                 C   sh   | j j| jj | j j| jj f}| jj| d | j s<J | j| jj| d }|| j sdJ d S )Nr   )	ry   r+  rx   r,  rz   	translater   r   r   )r^   Ztransr  r$   r$   r%   test_translate_tuple  s     z$TestGeomMethods.test_translate_tuplec                 C   s|   d}| j }tdd}| j j||dj| |d}t| j |s@J | j| j j|tddd}t||j| |dsxJ d S )Nrs  r   )origin)rr   r   rotater   r   r   )r^   Zangler   or  r$   r$   r%   test_rotate  s    
zTestGeomMethods.test_rotatec                 C   s   | j }d}tdd |D }tdd}| j j|d|ij|d|i}t||sRJ | j| j j|d|i}|j|d|i}t||sJ d S )N)rO   rN   c                 s   s   | ]}d | V  qdS )rN   Nr$   r3  r$   r$   r%   	<genexpr>  r`   z-TestGeomMethods.test_scale.<locals>.<genexpr>r   r|  )rr   tupler   scaler   r   r   )r^   r   r  invr~  r  r$   r$   r%   
test_scale  s    
zTestGeomMethods.test_scalec                 C   s   | j }d}tdd}| j j||dj| |d}t||s>J | j| j j||d}|j| |d}t||stJ | j j||dj| |d}t||sJ | j| j j||d}|j| |d}t||sJ d S )Ng     F@r   )Zxsr|  )Zysr|  )rr   r   skewr   r   r   )r^   r   r  r~  r  r$   r$   r%   	test_skew  s    
zTestGeomMethods.test_skewc                 C   s>   t tddg}t tdg}|jddd}t||s:J d S )Nr   )r=   r   )r   )r  r   r   r=   r  r=   r*   
resolution)r   r   r   bufferr   r^   re  r   
calculatedr$   r$   r%   test_buffer  s    zTestGeomMethods.test_bufferc                 C   sl   dddd}| j jdi |}t| j |D ]<\}}|d u rH|d u sfJ q*|jdi |}||s*J q*d S )Nr2   r0   g      @)Z	cap_style
join_styleZmitre_limitr  )r  )r  )rm   r  rc  r   )r^   r"   Zcalculated_seriesre  r  r   r$   r$   r%   test_buffer_args  s    z TestGeomMethods.test_buffer_argsc                 C   sN   t | j| jg}t tdtdg}|jtddgdd}t||dd d S )N)rV   r=   )r=   r8   )r8   r=   )r=   rV   r  )r  r=   r  r  )r=   r  r  r*   r=   r  T)Zcheck_less_precise)r   rl   r   r  r   r   r   r  r$   r$   r%   test_buffer_distance_array  s    z*TestGeomMethods.test_buffer_distance_arrayc                 C   sV   t | j| jg}tg d}tt || W d    n1 sH0    Y  d S rm  )r   rl   r   r   r   r   r1  r  r^   re  rp  r$   r$   r%   !test_buffer_distance_wrong_length  s    z1TestGeomMethods.test_buffer_distance_wrong_lengthc                 C   sd   t | j| jgddgd}tddgddgd}tt || W d    n1 sV0    Y  d S )Nr   r*   rL   r0   rr  rs  )datarM   )r   rl   r   r   r   r1  r  r  r$   r$   r%    test_buffer_distance_wrong_index  s    z0TestGeomMethods.test_buffer_distance_wrong_indexc                 C   sR   t g d}t|t d g}|d}t|| |tg d}t|| d S )N)r(   r-   r+   r)   r   r   r   r   )r   r   r   r  r   r   r   )r^   rb  r   r   r$   r$   r%   test_buffer_empty_none  s    

z&TestGeomMethods.test_buffer_empty_nonec                 C   s   t jtdd | jd W d    n1 s00    Y  tjdd}| jd W d    n1 sh0    Y  |D ]}dt|jvsvJ qvd S )Nr   r   r*   T)recordr   z Geometry is in a geographic CRS.)	r   r   r   rr   r  warningscatch_warningsstrmessage)r^   r  rr$   r$   r%   test_buffer_crs_warn  s    **z$TestGeomMethods.test_buffer_crs_warnc                 C   sB   | j j}t|| jsJ t|ts,J | j j|jks>J d S r   )	rp   enveloper   r@  r   rZ   r   r   rH   )r^   er$   r$   r%   test_envelope  s    zTestGeomMethods.test_envelopec                 C   sf   t | j| jgdd}| }t ddg}t| |dsDJ t	|t sRJ |j
|j
ksbJ d S )Ni  rG   z#POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))z#POLYGON ((2 0, 2 3, 3 3, 3 0, 2 0))MbP?)r   rZ   rg   Zminimum_rotated_rectangleZfrom_wktr   r@  r;  Zgeom_equals_exactr   rH   )r^   r   r  r  r$   r$   r%   test_minimum_rotated_rectangle  s    z.TestGeomMethods.test_minimum_rotated_rectanglezGextract_unique_points is only implemented for pygeos and shapely >= 2.0c                 C   s0   t | jg }t tddgg}t|| d S )Nr/   r1   )r   rh   extract_unique_pointsr   r   )r^   Zeupr   r$   r$   r%   test_extract_unique_points  s    z*TestGeomMethods.test_extract_unique_pointsz3extract_unique_points not implemented for shapely<2c                 C   s<   t jtdd | j  W d    n1 s.0    Y  d S r   )r   r   r   rn   r  r]   r$   r$   r%   *test_extract_unique_points_not_implemented  s    z:TestGeomMethods.test_extract_unique_points_not_implementedzCminimum_bounding_circle is only implemented for pygeos, not shapelyc                 C   sn   | j  }ttddgd }t|j|ds6J t|j	t
ddg t|tsXJ | j j|jksjJ d S )Nr   r0   r  g1?)rn   Zminimum_bounding_circler   r   r   r@  r7  r   r   r   r   r   rH   )r^   ZmbcZcentersr$   r$   r%   test_minimum_bounding_circle%  s    

z,TestGeomMethods.test_minimum_bounding_circlec                 C   st   | j j| j j| jj| jjf}t| jjtjs0J t	| jj|ksDJ t
| jtt| jd}t	|j|kspJ d S )N)rR   rS   )ry   r+  r,  rx   r   rz   Ztotal_boundsr   Zndarrayr  r   r   r   )r^   Zbboxdfr$   r$   r%   test_total_bounds4  s    z!TestGeomMethods.test_total_boundsc                 C   s   t tddgtg dgdd}d|j_dd g}g d}t tddtd	d	td
d
tddtddgtj||ddd}tjt	dd t
||  W d    n1 s0    Y  d S )Nr(   r+   )r   r9   )r8   r8   rI   rG   Ztest_index_name)r(   r-   r)   r+   r*   r0   r   r*   r0   r2   r8   namesr   Currently, index_parts defaultsr   )r   r   rM   namer   r   from_tuplesr   r   r   r   explode)r^   r   Zexpected_index_namerM   r   r$   r$   r%   test_explode_geoseries>  s    *z&TestGeomMethods.test_explode_geoseries
index_nameNtestc                 C   s   t ttddtddgtddg}tddg|d}||j_tjtdd |	 }W d    n1 sl0    Y  t tddtddtddg}tg d|d}t
d	dgd	dggg d
g dg|d gd}||}t|| d S )Nr*   r0   r2   r=   )colrR   r  r   r*   r*   r0   r   r   r   r*   r   r*   r   r  )r   r   r   r   rM   r  r   r   r   r  r   	set_indexr   r^   r  r   r  test_df
expected_sexpected_dfexpected_indexr$   r$   r%   test_explode_geodataframeN  s    && 
z)TestGeomMethods.test_explode_geodataframec                 C   s   t ttddtddgtddg}tddg|d}||j_|jdd}t tddtddtddg}tg d|d}td	dgd	dggg d
g dg|d gd}||}t	|| d S )Nr*   r0   r2   r=   Zlevel_1rR   Tindex_partsr  r   r  r  r  )
r   r   r   r   rM   r  r  r   r  r   r  r$   r$   r%   !test_explode_geodataframe_level_1a  s    & 
z1TestGeomMethods.test_explode_geodataframe_level_1c                 C   s   t ttddtddgtddg}tddg|d}||j_|jdd}t tddtddtddg}tg d|d}tg d	|d
}||}t	|| d S )Nr*   r0   r2   r=   r  Fr  r  r  )r  )
r   r   r   r   rM   r  r  r   r  r   r  r$   r$   r%   'test_explode_geodataframe_no_multiindext  s    & 
z7TestGeomMethods.test_explode_geodataframe_no_multiindexc                 C   s   ddgddggt ddgt ddggd	}t|d
d}tg dt ddgt ddgt ddgt ddggd	g dd
d}|d}t|| |jdd}t|| d S )Nname1name2name3name4r  r2   r8   r0   r*   r(   rS   rR   rI   rG   r  r  r  r  )r   r   r*   r*   r   rS   )columnr   r   r  r   r^   dr   r  Zexploded_dfr$   r$   r%   test_explode_pandas_fallback  s&    



	

z,TestGeomMethods.test_explode_pandas_fallbackc                 C   s   ddgddggt ddgt ddggd	}t|d
d}tg dt ddgt ddgt ddgt ddggd	d
d}|jddd}t|| |jddd}t|| d S )Nr  r  r  r  r  r  r  r(   r  rI   rG   r  rS   Tignore_index)r  r  r  r  r$   r$   r%   )test_explode_pandas_fallback_ignore_index  s$    



	
z9TestGeomMethods.test_explode_pandas_fallback_ignore_indexouter_index)r*   r  1c              	      s   t j   gg dgdd}tdg didd tdD |d}|jd	d
}ttddtddtddtddtddtddg}tg d|d}t j fdddD g dd}||}t	|| d S )Nrn  firstsecondr  valsc                 S   s    g | ]}t ||f|d fgqS r   r   r[   r+  r$   r$   r%   r_     r`   zCTestGeomMethods.test_explode_pandas_multi_index.<locals>.<listcomp>r2   rR   rM   Tr  r   r*   r0   r*   r*   r0   r0   r2   r2   r  rR   c                    s   g | ]} g|R qS r$   r$   )r[   pairr  r$   r%   r_     s   )r)   r+   r/   r  r1   r3   )r  r  N
r   from_arraysr   r   r  r   r   r  r  r   r^   r  rM   r  r  r  r  r  r$   r  r%   test_explode_pandas_multi_index  s8    



z/TestGeomMethods.test_explode_pandas_multi_indexc              	   C   s   t j|||gg dgdd}tdg didd tdD |d}|jd	d
}ttddtddtddtddtddtddg}tg d|d}t j|df|df|df|df|df|dfgddgd}||}t	|| d S )Nrn  r  r  r  c                 S   s    g | ]}t ||f|d fgqS r  r  r  r$   r$   r%   r_     r`   zITestGeomMethods.test_explode_pandas_multi_index_false.<locals>.<listcomp>r2   r  Fr  r   r*   r0   r  r  r  r  r  r  r$   r$   r%   %test_explode_pandas_multi_index_false  s@    


z5TestGeomMethods.test_explode_pandas_multi_index_falsec              	   C   s   t j|||gg dgdd}tdg didd tdD |d}|jd	d
}ttddtddtddtddtddtddg}tg d|d}ttt|}|	|}t
|| |jd	d	d}t
|| d S )Nrn  r  r  r  c                 S   s    g | ]}t ||f|d fgqS r  r  r  r$   r$   r%   r_     r`   zPTestGeomMethods.test_explode_pandas_multi_index_ignore_index.<locals>.<listcomp>r2   r  Tr  r   r*   r0   r  r  )r  r  )r   r  r   r   r  r   r   r   r   r  r   r  r$   r$   r%   ,test_explode_pandas_multi_index_ignore_index  s2    



z<TestGeomMethods.test_explode_pandas_multi_index_ignore_indexc              	   C   s   t dg didd tdD g dd}|jdd	}tg d
g dg}ttddtddtddtddtddtddg|d}t dg di||d}t|| d S )Nr  rn  c                 S   s    g | ]}t ||f|d fgqS r  r  r  r$   r$   r%   r_   )  r`   z6TestGeomMethods.test_explode_order.<locals>.<listcomp>r2   r0   	   r   r  Tr  )r0   r0   r  r  r   r   r   r*   r   r*   r   r*   r   r*   r0   rL   r  r   r   r  r   r  r   r   r   r^   r  r  r  Zexpected_geometryr  r$   r$   r%   test_explode_order&  s2    

z"TestGeomMethods.test_explode_orderc                 C   s|   t dg didd tdD g dd}|jdd	}tg dg d
g}t dg didd tdD |d}t|| d S )Nr  rn  c                 S   s   g | ]}t d |qS r  r   r  r$   r$   r%   r_   F  r`   z?TestGeomMethods.test_explode_order_no_multi.<locals>.<listcomp>r2   r  r  Tr  r  c                 S   s   g | ]}t d |qS r  r  r  r$   r$   r%   r_   P  r`   )r   r   r  r   r  r   )r^   r  r  r  r  r$   r$   r%   test_explode_order_no_multiC  s    

z+TestGeomMethods.test_explode_order_no_multic                 C   s   t dg didd tdD tddg g dd	}|jd
d}tg dg dg}ttddtddtddtddtddg|d}t dg di||d	}t|| d S )Nr  rn  c                 S   s    g | ]}t ||f|d fgqS r  r  r  r$   r$   r%   r_   X  r`   z<TestGeomMethods.test_explode_order_mixed.<locals>.<listcomp>r0   r   r  r  r  Tr  )r0   r0   r  r  r   )r   r*   r   r*   r   r*   rL   )r*   r*   r0   r0   r2   )r   r   r   r  r   r  r   r   r  r$   r$   r%   test_explode_order_mixedU  s0    


z(TestGeomMethods.test_explode_order_mixedc              	   C   s   t dg didd tdD g dd}|jdd	}tg d
g dg}ttddtddtddtddtddtddg|d}t dg di||d}t|| d S )Nr  rn  c                 S   s    g | ]}t ||f|d fgqS r  r  r  r$   r$   r%   r_   t  r`   zATestGeomMethods.test_explode_duplicated_index.<locals>.<listcomp>r2   r  r  Tr  )r*   r*   r*   r*   r0   r0   r  r   r*   r0   rL   r  r  r  r$   r$   r%   test_explode_duplicated_indexq  s2    

z-TestGeomMethods.test_explode_duplicated_indexgeom_colgeomrR   c                 C   sp   t ttddtddgtddg}tdddg||i|d}|jdd}|jj|ksZJ |jj|jkslJ d S )	Nr*   r0   r2   r=   r  rR   Tr  )r   r   r   r   r  rR   r  _geometry_column_name)r^   r  r   r  r  r$   r$   r%   test_explode_geometry_name  s
    &z*TestGeomMethods.test_explode_geometry_namec                 C   s~   t ttddtddgtddg}tddg||ddd}|jdd	}|jjdksZJ |jj|jkslJ d
|jv szJ d S )Nr*   r0   r2   r=   )r  r  rR   r  r  Tr  rR   )	r   r   r   r   r  rR   r  r  r   )r^   r   r  r  r$   r$   r%   $test_explode_geometry_name_two_geoms  s    &z4TestGeomMethods.test_explode_geometry_name_two_geomsc                 C   s   t t& | d| j| j| j W d    n1 s60    Y  t t& | d| j| j| j W d    n1 sv0    Y  d S )N__and__)r   r   r   r   rc   rn   ro   r   r]   r$   r$   r%   test_intersection_operator  s    4z*TestGeomMethods.test_intersection_operatorc                 C   s   t t& | d| j| j| j W d    n1 s60    Y  t t& | d| j| j| j W d    n1 sv0    Y  d S N__or__)r   r   r   r   rZ   rn   ro   r   r]   r$   r$   r%   test_union_operator  s    4z#TestGeomMethods.test_union_operatorc                 C   s   t t& | d| j| j| j W d    n1 s60    Y  t t& | d| j| j| j W d    n1 sv0    Y  d S r  )r   r   r   r   rZ   rn   rd   r   r]   r$   r$   r%   test_union_operator_polygon  s    4z+TestGeomMethods.test_union_operator_polygonc                 C   s   t t& | d| j| j| j W d    n1 s60    Y  t t& | d| j| j| j W d    n1 sv0    Y  d S )N__xor__)r   r   r   r   rZ   rp   rr   r   r]   r$   r$   r%   "test_symmetric_difference_operator  s    4z2TestGeomMethods.test_symmetric_difference_operatorc                 C   s   t t | jg}tt$ | d|| j| j W d    n1 sD0    Y  tt$ | d|| j	| j W d    n1 s0    Y  d S N__sub__)
r   r   rd   r   r   r   r   rn   ro   r   r   r$   r$   r%   test_difference_series2  s
    2z'TestGeomMethods.test_difference_series2c                 C   s   t | j| jg}tt$ | d|| j| j W d    n1 sD0    Y  tt$ | d|| j| j W d    n1 s0    Y  d S r  )	r   rc   r   r   r   r   rn   rd   r   r   r$   r$   r%   test_difference_poly2  s
    2z%TestGeomMethods.test_difference_poly2c                 C   s,   t | jddgg dd}t| j | d S )Nr+  r,  r   r*   r2   r2   r2   r2   r8   r8   r8   r8   rV   rV   rV   r  r   rM   r   r   r   r   get_coordinatesr   r$   r$   r%   test_get_coordinates  s    z$TestGeomMethods.test_get_coordinatesc                 C   s0   t | jg dg dd}t| jjdd| d S )N)r+  r,  r-  r  r  T)Z	include_z)r   r   r   r   r
  r   r$   r$   r%   test_get_coordinates_z  s    z&TestGeomMethods.test_get_coordinates_zc                 C   s*   t | jddgd}t| jjdd| d S )Nr+  r,  )r  r   Tr  r	  r   r$   r$   r%   test_get_coordinates_ignore  s
    z+TestGeomMethods.test_get_coordinates_ignorec                 C   s6   t | jddgtg dd}t| jjdd| d S )Nr+  r,  )r(   r)   r1   r3   )r2   r0   r9   )r8   r   )r8   r*   )r8   r0   )r8   r2   )rV   r   )rV   r*   )rV   r0   r  Tr  )r   r   r   r  r   r   r
  r   r$   r$   r%   test_get_coordinates_parts  s    z*TestGeomMethods.test_get_coordinates_partsc                 C   s<   t jtdd | j  W d    n1 s.0    Y  d S )Nz%shapely >= 2.0 or PyGEOS are requiredr   )r   r   r   r   r
  r]   r$   r$   r%   test_get_coordinates_not  s    z(TestGeomMethods.test_get_coordinates_notz5minimum_bounding_radius not implemented for shapely<2c                 C   s<   | j  }t|tddg | j }t|tddg d S )NgÜ?)rn   minimum_bounding_radiusr   r   r   )r^   Z	mbr_geomsZ	mbr_linesr$   r$   r%   test_minimum_bounding_radius  s    



z,TestGeomMethods.test_minimum_bounding_radiusc                 C   s<   t jtdd | j  W d    n1 s.0    Y  d S r   )r   r   r   rn   r  r]   r$   r$   r%   !test_minimium_bounding_radius_not$  s    z1TestGeomMethods.test_minimium_bounding_radius_notz;array input in interpolate is not implemented for shapely<2size)r     r  c                 C   s   | j | j| j| jfD ]L}||}t|j|j t|jddt||j	|
 B   | ksJ qtjtdd |j|dd}W d    n1 s0    Y  d S )NTr  z The 'seed' keyword is deprecatedr   r*   )seed)rn   rt   rw   ru   sample_pointsr   rM   r   r  r%  Zisnar   r   r   )r^   r  gsoutputr\   r$   r$   r%   test_sample_points.  s    
z"TestGeomMethods.test_sample_pointsc                 C   sF   t | j| jgg d}tg dg dddd}tt|| d S )N)r     r     )r   r*   r   r*   Zsampled_pointsint32)rM   r  r   )r   rn   r  r   r   rH  Zget_num_geometries)r^   r  r   r$   r$   r%   test_sample_points_arrayC  s
    z(TestGeomMethods.test_sample_points_arrayc                 C   s   t d | j| j| jfD ]H}|j|dd}t|j|j t|j	ddt||j
  | ksJ qt jtdd |jdd	d W d    n1 s0    Y  d S )
NZ	pointpatsZcluster_poisson)methodTr  zpointpats.random module has nor   r  Znonexistent)r   Zimportorskiprn   rt   rw   r  r   rM   r   r  r%  r   AttributeError)r^   r  r  r  r$   r$   r%   test_sample_points_pointpatsN  s    
"z,TestGeomMethods.test_sample_points_pointpatsz8offset_curve is only implemented for pygeos, not shapelyc                 C   sR   t | jgjddd}t tddgddgddggg}t|| t|t sNJ d S )Nr*   Zmitre)r  r   r   r0   )r   r~   Zoffset_curver	   r   r   )r^   ocr   r$   r$   r%   test_offset_curvec  s     
z!TestGeomMethods.test_offset_curvez8remove_repeated_points is implemented for shapely >= 2.0c                 C   sF   t jtdtj dd | j  W d    n1 s80    Y  d S rT  )r   r   r   rH  rI  r   remove_repeated_pointsr]   r$   r$   r%   8test_remove_repeated_points_not_implemented_shapely_pre2m  s    zHTestGeomMethods.test_remove_repeated_points_not_implemented_shapely_pre2z=remove_repeated_points is only implemented for shapely >= 2.0c                 C   s<   t jtdd | j  W d    n1 s.0    Y  d S )NzMPyGEOS does not support remove_repeated_points, and Shapely >= 2 is installedr   )r   r   r   rn   r#  r]   r$   r$   r%   8test_remove_repeated_points_pygeos_set_shapely_installedy  s
    zHTestGeomMethods.test_remove_repeated_points_pygeos_set_shapely_installedzgeom,expected)r(   r  r  r*   r2   r(   )r(   r  r&  r(   )r(   r(   r)   r+   r)   r(   )r(   r)   r+   r)   r(   c                 C   s   t ||jdd d S )NrX   )Z	tolerance)r   r#  )r^   r  r   r$   r$   r%   test_remove_repeated_points  s    z+TestGeomMethods.test_remove_repeated_points)__name__
__module____qualname__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   markZskipifcompatZ
USE_PYGEOSZUSE_SHAPELY_20r   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!  r$  r&  filterwarningsr'  r(  r)  r/  r0  r2  r8  r9  r?  rA  rC  rD  rL  rS  ZSHAPELY_GE_20rV  rW  rX  Zparametrizer[  r\  r_  r`  ra  rd  rf  rk  rl  rq  rt  ru  rw  ry  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  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$   r%   r'   (   sT   
<	




1
!

 



		
	

	
/







	
	
	







"
&
 

r'   ).rU   r  numpyr   Znumpy.testingr   rQ   r   r   r   r   r   rH  Zshapely.geometryr   r	   r
   r   r   r   r   Zshapely.geometry.collectionr   Zshapely.opsr   r   Z	geopandasr   r   Zgeopandas.baser   Zgeopandas.testingr   r   Zgeopandas.tests.utilr   r   r   r,  Zpandas.testingr   r   r   r   r&   r'   r$   r$   r$   r%   <module>   s$   $	