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 geo
import (
"fmt"
"testing"
"github.com/pd0mz/go-maidenhead"
)
func TestDistance(t *testing.T) {
winnipeg := coordinate{49.895077, -97.138451}
regina := coordinate{50.445210, -104.618896}
result := Distance(winnipeg, regina)
fmt.Printf("%f\n", result)
}
func TestGenerateAllNodes(t *testing.T) {
for lon := -180; lon <= 180; lon += 10 {
for lat := -90; lat <= 90; lat += 10 {
fmt.Printf("Lon: %d Lat: %d\n", lon, lat)
}
fmt.Printf("")
// lon += 10
}
}
func TestMaidenHead(t *testing.T) {
//winnipeg := coordinate{50.445210, -104.618896}
//point := coordinate{50.445210, -104.618896}
point := coordinate{0,0}
var p = maidenhead.NewPoint(point.lat, point.lon)
locator, _ := p.Locator(3)
fmt.Printf("Locator: %s\n", locator)
var centerOfMaidenHead, _ = maidenhead.ParseLocatorCentered(locator)
fmt.Printf("long: %f lat: %f", centerOfMaidenHead.Longitude, centerOfMaidenHead.Latitude)
d := Distance(coordinate{centerOfMaidenHead.Latitude, centerOfMaidenHead.Longitude}, point)
fmt.Printf("Distance from maidenhead center: %f", d)
}
|