forked from rubenv/topojson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimplify_test.go
38 lines (34 loc) · 963 Bytes
/
simplify_test.go
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 topojson
import (
"testing"
"github.com/paulmach/orb"
geojson "github.com/paulmach/orb/geojson"
)
func TestSimplify(t *testing.T) {
poly := geojson.NewFeature(orb.Polygon{
orb.Ring{
{0, 0}, {0, 1}, {0.5, 1.1}, {1, 1}, {1, 0}, {0, 0},
},
})
poly.ID = "poly"
fc := geojson.NewFeatureCollection()
fc.Append(poly)
t.Run("Reducing a triangle, 0.0501", func(tt *testing.T) {
tt.Parallel()
topo := NewTopology(fc, &TopologyOptions{
Simplify: 0.0501, // 1 x 0.1 / 2 = 0.05
})
if len(topo.Arcs[0]) != 5 {
tt.Error("failed to simplify, Arcs must be [0 0] [0 1] [1 1] [1 0] [0 0], actual:", topo.Arcs[0])
}
})
t.Run("Reducing a triangle, 0.0500", func(tt *testing.T) {
tt.Parallel()
topo := NewTopology(fc, &TopologyOptions{
Simplify: 0.0500, // 1 x 0.1 / 2 = 0.05
})
if len(topo.Arcs[0]) != 6 {
tt.Error("failed to simplify, Arcs must be [0 0] [0 1] [0.5 1.1] [1 1] [1 0] [0 0], actual:", topo.Arcs[0])
}
})
}