Can now accept location
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user