@@ -388,6 +388,28 @@ def test_split_partial_cut(cell_polygon):
388
388
assert fragments [0 ].equals_exact (cell_polygon , tolerance = 0.0 )
389
389
390
390
391
+ def test_split_order (cell_polygon ):
392
+ # This test is to indicate that the order matters
393
+ cutlines_2 = [
394
+ shapely .LineString ([(5 , 0 ), (5 , 6 )]),
395
+ shapely .LineString ([(0 , 0 ), (10 , 10 )]),
396
+ ]
397
+ fragments = Grid .split (cell_polygon , cutlines_2 )
398
+ assert len (fragments ) == 2
399
+
400
+ cutlines_3 = [
401
+ shapely .LineString ([(0 , 0 ), (10 , 10 )]),
402
+ shapely .LineString ([(5 , 0 ), (5 , 5 )]),
403
+ ]
404
+ fragments = Grid .split (cell_polygon , cutlines_3 )
405
+ assert len (fragments ) == 3
406
+
407
+ # Combining the lines in a single linestring solves the problem
408
+ cutlines_3 = [shapely .LineString ([(0 , 0 ), (10 , 10 ), (5 , 5 ), (5 , 0 )])]
409
+ fragments = Grid .split (cell_polygon , cutlines_3 )
410
+ assert len (fragments ) == 3
411
+
412
+
391
413
def test_split_double_cut (cell_polygon ):
392
414
cutlines = [
393
415
shapely .LineString ([(0 , 0 ), (10 , 10 )]),
0 commit comments