File: test_minimum_clearance.py

package info (click to toggle)
python-shapely 2.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 2,528 kB
  • sloc: python: 18,648; ansic: 6,615; makefile: 88; sh: 62
file content (30 lines) | stat: -rw-r--r-- 694 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Tests for the minimum clearance property.
"""

import math

from shapely.wkt import loads as load_wkt


def test_point():
    point = load_wkt("POINT (0 0)")
    assert point.minimum_clearance == math.inf


def test_linestring():
    line = load_wkt("LINESTRING (0 0, 1 1, 2 2)")
    assert round(line.minimum_clearance, 6) == 1.414214


def test_simple_polygon():
    poly = load_wkt("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))")
    assert poly.minimum_clearance == 1.0


def test_more_complicated_polygon():
    poly = load_wkt(
        "POLYGON ((20 20, 34 124, 70 140, 130 130, 70 100, 110 70, 170 20, 90 10, "
        "20 20))"
    )
    assert round(poly.minimum_clearance, 6) == 35.777088