Skip to content

Commit

Permalink
add test for PolygonalRegion.unionAll
Browse files Browse the repository at this point in the history
  • Loading branch information
dfremont committed Oct 9, 2023
1 parent 14e676b commit 05b3589
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/core/test_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,24 @@ def test_polygon_region():
)


def test_polygon_unionAll():
poly1 = PolygonalRegion([(1, 0), (1, 1), (2, 1), (2, 0)], z=2)
poly2 = PolygonalRegion([(-1, 0), (-1, 1), (0, 1), (0, 0)], z=2)
union = PolygonalRegion.unionAll((poly1, nowhere, poly2))
assert isinstance(union, PolygonalRegion)
assert union.z == 2
assert union.containsPoint((1.5, 0.5))
assert union.containsPoint((-0.5, 0.5))
assert not union.containsPoint((0.5, 0.5))

poly3 = PolygonalRegion([(0, 0), (1, 1), (1, 0)], z=1)
with pytest.raises(ValueError):
PolygonalRegion.unionAll((poly1, poly3))

with pytest.raises(TypeError):
PolygonalRegion.unionAll((poly1, everywhere))


def test_polygon_sampling():
p = shapely.geometry.Polygon(
[(0, 0), (0, 3), (3, 3), (3, 0)], holes=[[(1, 1), (1, 2), (2, 2), (2, 1)]]
Expand Down

0 comments on commit 05b3589

Please sign in to comment.