-
Notifications
You must be signed in to change notification settings - Fork 0
/
tile_coord_test.go
67 lines (58 loc) · 1.44 KB
/
tile_coord_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
package coordtile
import (
"fmt"
"testing"
)
func TestTileCoord_GetTile(t1 *testing.T) {
//15 X: 120.8657455444336, Y: 30.759538817987497 x: 27380, y: 13434,
coord := NewTileCoord(TileProjWebMercator)
//13 120.805664, 30.798474 x: 6844, y: 3358,
tile := coord.WGS84ToWebMercatorTile(Coordinate{
X: 120.81098556518555,
Y: 30.803634881295125,
}, 15)
fmt.Println(tile)
tile = coord.WGS84ToWebMercatorTile(Coordinate{
X: 120.805664,
Y: 30.798474,
}, 13)
fmt.Println(tile)
tile = coord.WGS84ToWebMercatorTile(Coordinate{
X: 120.8657455444336,
Y: 30.759538817987497,
}, 13)
fmt.Println(tile)
}
func TestTileCoord_WGS84ToWebMercatorTileBounds(t1 *testing.T) {
coord := NewTileCoord(TileProjWebMercator)
bound := coord.WGS84ToWebMercatorTileBound(13, []Coordinate{
{
X: 120.805664, Y: 30.798474,
},
{
X: 120.816650, Y: 30.807911,
},
})
fmt.Println("bound:", bound)
//x:6844 y:3358 level:13
//x:6845 y:3358 level:13
bound.Expand(func(x, y, level int) {
fmt.Printf("---------x:%d y:%d level:%d\n", x, y, level)
})
}
func TestTileCoord_WGS84TileBounds(t1 *testing.T) {
coord := NewTileCoord(TileProjWGS1984)
bound := coord.WGS84TileBound(4, []Coordinate{
{
//73.0821065143448, 53.560629756117
X: 73.0821065143448, Y: 53.560629756117,
},
{
//135.087067, 18.2143401996406
X: 135.087067, Y: 18.2143401996406,
},
})
fmt.Printf("bound:%+v\n", bound)
//x:6844 y:3358 level:13
//x:6845 y:3358 level:13
}