Added basic i18n
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user