test_minimum_clearance.py 694 B

123456789101112131415161718192021222324252627282930
  1. """
  2. Tests for the minimum clearance property.
  3. """
  4. import math
  5. from shapely.wkt import loads as load_wkt
  6. def test_point():
  7. point = load_wkt("POINT (0 0)")
  8. assert point.minimum_clearance == math.inf
  9. def test_linestring():
  10. line = load_wkt("LINESTRING (0 0, 1 1, 2 2)")
  11. assert round(line.minimum_clearance, 6) == 1.414214
  12. def test_simple_polygon():
  13. poly = load_wkt("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))")
  14. assert poly.minimum_clearance == 1.0
  15. def test_more_complicated_polygon():
  16. poly = load_wkt(
  17. "POLYGON ((20 20, 34 124, 70 140, 130 130, 70 100, 110 70, 170 20, 90 10, "
  18. "20 20))"
  19. )
  20. assert round(poly.minimum_clearance, 6) == 35.777088