Refactoring codes for more tg message types

This commit is contained in:
2026-03-07 22:16:14 +08:00
parent a396a381b5
commit 912f9fd0ad
26 changed files with 771 additions and 472 deletions

33
query/geo_test.go Normal file
View File

@@ -0,0 +1,33 @@
package query
import (
"fmt"
"testing"
)
type City struct {
Name string
NoWords
GeoLocation
}
func TestGeo(t *testing.T) {
B := GeoLocations{
City{Name: "Osaka", GeoLocation: GeoLocation{34.6937, 135.5023}},
City{Name: "Nagoya", GeoLocation: GeoLocation{35.1815, 136.9066}},
City{Name: "Sapporo", GeoLocation: GeoLocation{43.0618, 141.3545}},
City{Name: "Yokohama", GeoLocation: GeoLocation{35.4437, 139.6380}},
}
// Reference point A (Tokyo)
A := GeoLocation{35.6895, 139.6917}
// Sort by distance
B.SortByNearest(A)
// Print result
for _, loc := range B {
fmt.Printf("%s: %.2f km\n", loc.(City).Name, loc.Dist(A.Lat(), A.Lon())/1000)
}
}