/** * Yats - yats * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Paolo Lulli * @copyright Paolo Lulli 2024 */ package geo import ( "fmt" "github.com/pd0mz/go-maidenhead" "github.com/uber/h3-go/v4" "testing" ) 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) } func TestH3Cells(t *testing.T) { latLng := h3.NewLatLng(37.775938728915946, -122.41795063018799) resolution := 9 // between 0 (biggest cell) and 15 (smallest cell) cell := h3.LatLngToCell(latLng, resolution) fmt.Printf("%s", cell) // Output: // 8928308280fffff } func TestH3VertxDistance(t *testing.T) { point0 := coordinate{40.690058601, -74.044151762} point1 := coordinate{40.689907695, -74.045061792} dist := Distance(point0, point1) fmt.Printf("distance: %f\n", dist) }