Added basic i18n

This commit is contained in:
2026-03-10 15:18:34 +08:00
parent 093a8745ac
commit 7d1de5f781
25 changed files with 660 additions and 105 deletions

View File

@@ -4,7 +4,7 @@ import (
"fmt"
)
func MatchNearest(p IGeoLocation, entries *[]ISearchable, dist float64, limit int) (*QueryObject, error) {
func MatchNearest(p IGeoLocation, entries *[]ISearchable, dist float64, fallback_limit int) (*QueryObject, error) {
terms := []*QTerm{
{
@@ -19,12 +19,22 @@ func MatchNearest(p IGeoLocation, entries *[]ISearchable, dist float64, limit in
locs.SortByNearest(p)
matches := []ISearchable{}
for i, item := range *locs {
for _, item := range *locs {
loc := item.(IGeoLocation)
if i < limit && loc.Dist(p.Lat(), p.Lon()) <= dist {
if loc.Dist(p.Lat(), p.Lon()) <= dist {
matches = append(matches, item)
}
}
if len(matches) == 0 {
for i, item := range *locs {
if i < fallback_limit {
matches = append(matches, item)
} else {
break
}
}
}
return &QueryObject{Key: "", Results: &matches, SearchTerms: &terms}, nil
}