-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprojection_test.go
48 lines (40 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
package osgb
import "testing"
func TestLatLonToEastNort(t *testing.T) {
lat, err := dmsToDecimal(52, 39, 27.2531, north)
if err != nil {
t.Fatal(err)
}
latRadians := degreesToRadians(lat)
lon, err := dmsToDecimal(1, 43, 4.5177, east)
if err != nil {
t.Fatal(err)
}
lonRadians := degreesToRadians(lon)
expectedEast := 651409.903
expectedNorth := 313177.270
coord := nationalGridProjection.toPlaneCoord(latRadians, lonRadians, airyEllipsoid)
checkDistance(t, "east", expectedEast, coord.easting)
checkDistance(t, "north", expectedNorth, coord.northing)
}
func TestEastNortToLatLon(t *testing.T) {
easting := 651409.903
northing := 313177.270
expectedLat, err := dmsToDecimal(52, 39, 27.2531, north)
if err != nil {
t.Fatal(err)
}
expectedLatRadians := degreesToRadians(expectedLat)
expectedLon, err := dmsToDecimal(1, 43, 4.5177, east)
if err != nil {
t.Fatal(err)
}
expectedLonRadians := degreesToRadians(expectedLon)
coord := &planeCoord{
easting: easting,
northing: northing,
}
lat, lon := nationalGridProjection.fromPlaneCoord(coord, airyEllipsoid)
checkAngle(t, "latitude", expectedLatRadians, lat)
checkAngle(t, "longitude", expectedLonRadians, lon)
}