File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,6 +95,8 @@ def inflate_polygon(poly, radius):
9595 inflated_poly = poly .buffer (
9696 radius , cap_style = CAP_STYLE .flat , join_style = JOIN_STYLE .mitre
9797 )
98+ if inflated_poly .is_empty :
99+ return inflated_poly
98100 return orient (inflated_poly )
99101
100102
Original file line number Diff line number Diff line change @@ -75,8 +75,13 @@ def test_get_polygon_centroid():
7575
7676
7777def test_inflate_polygon ():
78+ empty_poly = Polygon ()
7879 square_poly = Polygon (square_coords )
7980
81+ # Empty polygon
82+ inflated_poly = inflate_polygon (empty_poly , 0.0 )
83+ assert inflated_poly == empty_poly
84+
8085 # Zero inflation radius
8186 inflated_poly = inflate_polygon (square_poly , 0.0 )
8287 inflated_poly_coords = list (inflated_poly .exterior .coords )
@@ -108,8 +113,13 @@ def test_inflate_polygon():
108113
109114
110115def test_transform_polygon ():
116+ empty_poly = Polygon ()
111117 square_poly = Polygon (box_to_coords (dims = [1.0 , 2.0 ]))
112118
119+ # Empty polygon
120+ transformed_poly = transform_polygon (empty_poly , None )
121+ assert transformed_poly == empty_poly
122+
113123 # No transformation, using None as pose
114124 transformed_poly = transform_polygon (square_poly , None )
115125 assert transformed_poly == square_poly
You can’t perform that action at this time.
0 commit comments