From b2203fcb975a96dd59a4dc231edc7a4383852b7c Mon Sep 17 00:00:00 2001 From: tidwall Date: Sun, 11 Nov 2018 06:26:23 -0700 Subject: [PATCH] Fix nearby fast-fail --- internal/collection/collection.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/collection/collection.go b/internal/collection/collection.go index ed8555ce..d8fe0515 100644 --- a/internal/collection/collection.go +++ b/internal/collection/collection.go @@ -674,9 +674,9 @@ func (c *Collection) Nearby( cursor Cursor, iter func(id string, obj geojson.Object, fields []float64) bool, ) bool { - + // First look to see if there's at least one candidate in the circle's + // outer rectangle. This is a fast-fail operation. if circle, ok := target.(*geojson.Circle); ok { - meters := circle.Meters() if meters > 0 { center := circle.Center() @@ -692,12 +692,12 @@ func (c *Collection) Nearby( }, ) if !exists { + // no candidates return true } - return true } } - + // do the kNN operation alive := true center := target.Center() var count uint64