-
Notifications
You must be signed in to change notification settings - Fork 69
/
math_test.go
44 lines (28 loc) · 920 Bytes
/
math_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
package gountries
import "fmt"
func ExampleCalculatePythagorasEquirectangular() {
se, _ := query.FindCountryByAlpha("SWE")
de, _ := query.FindCountryByAlpha("DEU")
distance := MeasureDistancePythagoras(se, de)
fmt.Println(distance)
distance = CalculatePythagorasEquirectangular(
se.Coordinates.MaxLatitude, se.Coordinates.MaxLongitude,
de.Coordinates.MinLatitude, de.Coordinates.MinLongitude)
fmt.Println(distance)
// Output:
// 1430.5502701671583
// 2667.2283097795016
}
func ExampleCalculateHaversine() {
se, _ := query.FindCountryByAlpha("SWE")
de, _ := query.FindCountryByAlpha("DEU")
distance := MeasureDistanceHaversine(se, de)
fmt.Println(distance)
distance = CalculateHaversine(
se.Coordinates.MaxLatitude, se.Coordinates.MaxLongitude,
de.Coordinates.MinLatitude, de.Coordinates.MinLongitude)
fmt.Println(distance)
// Output:
// 1430.1937864547901
// 2641.26145088825
}