forked from paulmach/orb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
projection_test.go
54 lines (43 loc) · 1.18 KB
/
projection_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
package mvt
import (
"testing"
"github.com/Smadarl/orb/maptile"
"github.com/Smadarl/orb/project"
)
func TestNonPowerOfTwoProjection(t *testing.T) {
tile := maptile.New(8956, 12223, 15)
regProj := newProjection(tile, 4096)
nonProj := nonPowerOfTwoProjection(tile, 4096)
expected := loadGeoJSON(t, tile)
layers := NewLayers(loadGeoJSON(t, tile))
// loopy de loop of projections
for _, l := range layers {
for _, f := range l.Features {
f.Geometry = project.Geometry(f.Geometry, regProj.ToTile)
}
}
for _, l := range layers {
for _, f := range l.Features {
f.Geometry = project.Geometry(f.Geometry, nonProj.ToWGS84)
}
}
for _, l := range layers {
for _, f := range l.Features {
f.Geometry = project.Geometry(f.Geometry, nonProj.ToTile)
}
}
for _, l := range layers {
for _, f := range l.Features {
f.Geometry = project.Geometry(f.Geometry, regProj.ToWGS84)
}
}
result := layers.ToFeatureCollections()
xEpsilon, yEpsilon := tileEpsilon(tile)
for key := range expected {
for i := range expected[key].Features {
r := result[key].Features[i]
e := expected[key].Features[i]
compareOrbGeometry(t, r.Geometry, e.Geometry, xEpsilon, yEpsilon)
}
}
}