Can now accept location

This commit is contained in:
2026-03-08 15:38:28 +08:00
parent 912f9fd0ad
commit 33a7c04e09
12 changed files with 286 additions and 148 deletions

View File

@@ -4,7 +4,7 @@ import (
"fmt"
)
func MatchNearest(p GeoLocation, entries *[]ISearchable, dist float64, limit int) (*QueryObject, error) {
func MatchNearest(p IGeoLocation, entries *[]ISearchable, dist float64, limit int) (*QueryObject, error) {
terms := []*QTerm{
{
@@ -19,9 +19,10 @@ func MatchNearest(p GeoLocation, entries *[]ISearchable, dist float64, limit int
locs.SortByNearest(p)
matches := []ISearchable{}
for i, loc := range *locs {
if i < limit {
matches = append(matches, loc)
for i, item := range *locs {
loc := item.(IGeoLocation)
if i < limit && loc.Dist(p.Lat(), p.Lon()) <= dist {
matches = append(matches, item)
}
}