aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/paulmach/orb/simplify/helpers_test.go
blob: 7ade3dd4c9d6bf7eb249f9c996c6d357778c2811 (plain) (blame)
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
33
34
35
36
37
38
package simplify

import (
	"testing"

	"github.com/paulmach/orb"
)

func TestSimplify(t *testing.T) {
	r := DouglasPeucker(10)
	for _, g := range orb.AllGeometries {
		simplify(r, g)
	}
}

func TestPolygon(t *testing.T) {
	p := orb.Polygon{
		{{0, 0}, {1, 0}, {1, 1}, {0, 0}},
		{{0, 0}, {0, 0}},
	}

	p = DouglasPeucker(0).Polygon(p)
	if len(p) != 1 {
		t.Errorf("should remove empty ring")
	}
}

func TestMultiPolygon(t *testing.T) {
	mp := orb.MultiPolygon{
		{{{0, 0}, {1, 0}, {1, 1}, {0, 0}}},
		{{{0, 0}, {0, 0}}},
	}

	mp = DouglasPeucker(0).MultiPolygon(mp)
	if len(mp) != 1 {
		t.Errorf("should remove empty polygon")
	}
}