forked from spatial-go/geoos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoordtransform_test.go
More file actions
46 lines (43 loc) · 1.15 KB
/
coordtransform_test.go
File metadata and controls
46 lines (43 loc) · 1.15 KB
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
package coordtransform
import (
"testing"
"github.com/spatial-go/geoos/algorithm/matrix"
)
func TestTransformer_TransformLatLng(t1 *testing.T) {
type fields struct {
CoordType string
}
type args struct {
lng float64
lat float64
}
tests := []struct {
name string
fields fields
args args
want float64
want1 float64
tolerance float64
}{
{
name: "lnglat to mercator", fields: fields{CoordType: LLTOMERCATOR},
args: args{lng: 110, lat: 40}, want: 12245143.99, want1: 4865942.28, tolerance: 0.1,
},
{
name: "mercator to lnglat", fields: fields{CoordType: MERCATORTOLL},
args: args{lng: 12245143, lat: 4865942}, want: 109.9999911, want1: 39.9999981, tolerance: 0.0000001,
},
}
for _, tt := range tests {
t1.Run(tt.name, func(t1 *testing.T) {
t := GetInstance()
t.CoordType = tt.fields.CoordType
got, got1 := t.TransformLatLng(tt.args.lng, tt.args.lat)
gotPoint := matrix.Matrix{got, got1}
wantPoint := matrix.Matrix{tt.want, tt.want1}
if !gotPoint.EqualsExact(wantPoint, tt.tolerance) {
t1.Errorf("TransformLatLng() got = %v %v, want %v %v", got, got1, tt.want, tt.want1)
}
})
}
}