ref: 35a34791520f17e4cce5dd372a70d7cd1b5cb6d8
server/geo/distances_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 |
/** * Yats - yats * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Paolo Lulli <kevwe.com> * @copyright Paolo Lulli 2024 */ 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) { 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) } |