forked from go-spatial/tegola
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtile_test.go
106 lines (96 loc) · 2 KB
/
tile_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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package tegola_test
import (
"testing"
"github.com/terranodo/tegola"
)
func TestTileNum2Deg(t *testing.T) {
testcases := []struct {
tile tegola.Tile
expectedLat float64
expectedLng float64
}{
{
tile: tegola.Tile{
Z: 2,
X: 1,
Y: 1,
},
expectedLat: 66.51326044311185,
expectedLng: -90,
},
}
for i, test := range testcases {
lat, lng := test.tile.Num2Deg()
if lat != test.expectedLat {
t.Errorf("Failed test %v. Expected lat (%v), got (%v)", i, test.expectedLat, lat)
}
if lng != test.expectedLng {
t.Errorf("Failed test %v. Expected lng (%v), got (%v)", i, test.expectedLng, lng)
}
}
}
func TestTileBBox(t *testing.T) {
testcases := []struct {
tile tegola.Tile
minx, miny, maxx, maxy float64
}{
{
tile: tegola.Tile{
Z: 2,
X: 1,
Y: 1,
},
minx: -10018754.17,
miny: 10018754.17,
maxx: 0,
maxy: 0,
},
{
tile: tegola.Tile{
Z: 16,
X: 11436,
Y: 26461,
},
minx: -13044437.497219238996,
miny: 3856706.6986199953,
maxx: -13043826.000993041,
maxy: 3856095.202393799,
},
}
for i, test := range testcases {
bbox := test.tile.BoundingBox()
if bbox.Minx != test.minx {
t.Errorf("Failed test %v. Expected minx (%v), got (%v)", i, test.minx, bbox.Minx)
}
if bbox.Miny != test.miny {
t.Errorf("Failed test %v. Expected miny (%v), got (%v)", i, test.miny, bbox.Miny)
}
if bbox.Maxx != test.maxx {
t.Errorf("Failed test %v. Expected maxx (%v), got (%v)", i, test.maxx, bbox.Maxx)
}
if bbox.Maxy != test.maxy {
t.Errorf("Failed test %v. Expected maxy (%v), got (%v)", i, test.maxy, bbox.Maxy)
}
}
}
func TestTileZRes(t *testing.T) {
testcases := []struct {
tile tegola.Tile
zres float64
}{
{
tile: tegola.Tile{
Z: 2,
X: 1,
Y: 1,
},
zres: 39135.75848201026,
},
}
for i, test := range testcases {
zres := test.tile.ZRes()
if zres != test.zres {
t.Errorf("Failed test %v. Expected zres (%v), got (%v)", i, test.zres, zres)
}
}
}