File: test_delaunay.py

package info (click to toggle)
python-shapely 2.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 2,564 kB
  • sloc: python: 18,650; ansic: 6,615; makefile: 88; sh: 62
file content (32 lines) | stat: -rw-r--r-- 838 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
31
32
import unittest

from shapely.geometry import LineString, Point, Polygon
from shapely.ops import triangulate


class DelaunayTriangulation(unittest.TestCase):
    """
    Only testing the number of triangles and their type here.
    This doesn't actually test the points in the resulting geometries.

    """

    def setUp(self):
        self.p = Polygon([(0, 0), (1, 0), (1, 1), (0, 1)])

    def test_polys(self):
        polys = triangulate(self.p)
        assert len(polys) == 2
        for p in polys:
            assert isinstance(p, Polygon)

    def test_lines(self):
        polys = triangulate(self.p, edges=True)
        assert len(polys) == 5
        for p in polys:
            assert isinstance(p, LineString)

    def test_point(self):
        p = Point(1, 1)
        polys = triangulate(p)
        assert len(polys) == 0