File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 9
9
from geopandas .tools import sjoin
10
10
from geopandas .tools import overlay
11
11
12
+ from shapely .geometry .base import CAP_STYLE , JOIN_STYLE
13
+
12
14
import geopandas .datasets
13
15
14
16
# make the interactive namespace easier to use
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ void strtree_query_callback(void *item, void *vec)
22
22
GEOSSTRtree * create_index (GEOSContextHandle_t handle , GEOSGeometry * * geoms , size_t n )
23
23
{
24
24
int i ;
25
- GEOSSTRtree * tree = GEOSSTRtree_create_r (handle , n );
25
+ GEOSSTRtree * tree = GEOSSTRtree_create_r (handle , n > 1 ? n : 2 );
26
26
27
27
for (i = 0 ; i < n ; i ++ )
28
28
{
@@ -62,6 +62,8 @@ size_vector sjoin(GEOSContextHandle_t handle,
62
62
kv_init (vec );
63
63
64
64
// begin = clock();
65
+ if (nright == 0 )
66
+ return out ;
65
67
66
68
GEOSSTRtree * tree = create_index (handle , right , nright );
67
69
Original file line number Diff line number Diff line change @@ -103,3 +103,19 @@ def test_errors():
103
103
104
104
assert "both" in str (info .value )
105
105
assert "inner" in str (info .value )
106
+
107
+
108
+ @pytest .mark .parametrize ('l' , [0 , 1 , 5 ])
109
+ @pytest .mark .parametrize ('r' , [0 , 1 , 5 ])
110
+ def test_small (l , r ):
111
+ left = gpd .GeoDataFrame ({'geometry' : triangles ,
112
+ 'x' : np .random .random (len (triangles )),
113
+ 'y' : np .random .random (len (triangles ))},
114
+ index = np .arange (len (triangles )) * 2 ).iloc [:l ]
115
+
116
+ right = gpd .GeoDataFrame ({'geometry' : points ,
117
+ 'x' : np .random .random (len (points )),
118
+ 'z' : np .random .random (len (points ))},
119
+ index = list (string .ascii_lowercase [:len (points )])).iloc [:r ]
120
+
121
+ result = sjoin (left , right )
You can’t perform that action at this time.
0 commit comments