-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathellipsoid_test.go
62 lines (50 loc) · 1.39 KB
/
ellipsoid_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
package osgb
import (
"testing"
)
func TestLatLonHeightToCartesian(t *testing.T) {
lat, err := dmsToDecimal(52, 39, 27.2531, north)
if err != nil {
t.Fatal(err)
}
lon, err := dmsToDecimal(1, 43, 4.5177, east)
if err != nil {
t.Fatal(err)
}
latRadians := degreesToRadians(lat)
lonRadians := degreesToRadians(lon)
geoCoord := &geographicCoord{
lat: latRadians,
lon: lonRadians,
height: 24.700,
}
cartCoord := airyEllipsoid.geographicToCartesian(geoCoord)
expectedX := 3874938.850
expectedY := 116218.624
expectedZ := 5047168.207
checkDistance(t, "x", expectedX, cartCoord.x)
checkDistance(t, "y", expectedY, cartCoord.y)
checkDistance(t, "z", expectedZ, cartCoord.z)
}
func TestCartesianToLatLonHeight(t *testing.T) {
cartesianCoord := &cartesianCoord{
x: 3874938.850,
y: 116218.624,
z: 5047168.207,
}
geoCoord := airyEllipsoid.cartesianToGeographic(cartesianCoord)
expectedLat, err := dmsToDecimal(52, 39, 27.2531, north)
if err != nil {
t.Fatal(err)
}
expectedLon, err := dmsToDecimal(1, 43, 4.5177, east)
if err != nil {
t.Fatal(err)
}
expectedHeight := 24.700
expectedLatRadians := degreesToRadians(expectedLat)
expectedLonRadians := degreesToRadians(expectedLon)
checkAngle(t, "latitude", expectedLatRadians, geoCoord.lat)
checkAngle(t, "longitude", expectedLonRadians, geoCoord.lon)
checkDistance(t, "height", expectedHeight, geoCoord.height)
}