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

29
query/match_locations.go Normal file
View File

@@ -0,0 +1,29 @@
package query
import (
"fmt"
)
func MatchNearest(p GeoLocation, entries *[]ISearchable, dist float64, limit int) (*QueryObject, error) {
terms := []*QTerm{
{
Org: fmt.Sprintf("%f, %f", p.Lat(), p.Lon()),
Value: "",
},
}
var locs *GeoLocations
locs = GeoLocations(*entries).Clean()
locs.SortByNearest(p)
matches := []ISearchable{}
for i, loc := range *locs {
if i < limit {
matches = append(matches, loc)
}
}
return &QueryObject{Key: "", Results: &matches, SearchTerms: &terms}, nil
}