Fix nearby fast-fail

This commit is contained in:
tidwall 2018-11-11 06:26:23 -07:00
parent a160fa0860
commit b2203fcb97
1 changed files with 4 additions and 4 deletions

View File

@ -674,9 +674,9 @@ func (c *Collection) Nearby(
cursor Cursor, cursor Cursor,
iter func(id string, obj geojson.Object, fields []float64) bool, iter func(id string, obj geojson.Object, fields []float64) bool,
) 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 { if circle, ok := target.(*geojson.Circle); ok {
meters := circle.Meters() meters := circle.Meters()
if meters > 0 { if meters > 0 {
center := circle.Center() center := circle.Center()
@ -692,12 +692,12 @@ func (c *Collection) Nearby(
}, },
) )
if !exists { if !exists {
// no candidates
return true return true
} }
return true
} }
} }
// do the kNN operation
alive := true alive := true
center := target.Center() center := target.Center()
var count uint64 var count uint64