Fixed invalid count for nearby queries

closes #489
This commit is contained in:
tidwall 2019-08-22 15:53:09 -07:00
parent 54f14d8b03
commit aedd972516
1 changed files with 1 additions and 2 deletions

View File

@ -409,7 +409,6 @@ func (server *Server) nearestNeighbors(
iter func(id string, o geojson.Object, fields []float64, dist float64, iter func(id string, o geojson.Object, fields []float64, dist float64,
) bool) { ) bool) {
maxDist := target.Haversine() maxDist := target.Haversine()
limit := int(sw.limit)
var items []iterItem var items []iterItem
sw.col.Nearby(target, sw, dl, func(id string, o geojson.Object, fields []float64) bool { sw.col.Nearby(target, sw, dl, func(id string, o geojson.Object, fields []float64) bool {
if server.hasExpired(s.key, id) { if server.hasExpired(s.key, id) {
@ -427,7 +426,7 @@ func (server *Server) nearestNeighbors(
if !keepGoing { if !keepGoing {
return false return false
} }
return len(items) < limit return uint64(len(items)) < sw.limit
}) })
sort.Slice(items, func(i, j int) bool { sort.Slice(items, func(i, j int) bool {
return items[i].dist < items[j].dist return items[i].dist < items[j].dist