-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgeojson_test.go
55 lines (51 loc) · 1.04 KB
/
geojson_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import "testing"
func makeSegment(id int64, p1, p2 Point) *Linestring {
return &Linestring{
Id: id,
Points: []Point{p1, p2},
}
}
func TestCloseRings(t *testing.T) {
points := []Point{
{63157253, 495828250},
{63393455, 495385894},
{62918950, 495482440},
{63122770, 495816200},
{63249607, 495308781},
{63553830, 495556220},
{63391705, 495382442},
{63425441, 495417741},
{63396664, 495392000},
}
makeSegments := func(indices ...int) []*Linestring {
segments := []*Linestring{}
for i := range indices {
if i == 0 {
continue
}
segments = append(segments, &Linestring{
Id: int64(i - 1),
Points: []Point{
points[indices[i-1]],
points[indices[i]],
},
})
}
return segments
}
tests := [][]*Linestring{
makeSegments(0, 1, 2, 0),
makeSegments(0, 1, 2, 4, 0),
makeSegments(0, 3, 2, 4, 6, 1, 8, 7, 5, 0),
}
for _, test := range tests {
rings, err := makeRings(test)
if err != nil {
t.Fatal(err)
}
if len(rings) != 1 {
t.Fatal("could not merge rings")
}
}
}