mirror of https://github.com/tidwall/tile38.git
Minor refactoring
This commit is contained in:
parent
2383594048
commit
18d7398d50
|
@ -423,18 +423,17 @@ func (server *Server) nearestNeighbors(
|
||||||
if !match {
|
if !match {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
var dist float64
|
var dist, max_dist float64
|
||||||
if s.distance {
|
if s.distance {
|
||||||
dist = o.Distance(target)
|
dist = o.Distance(target)
|
||||||
if target.Meters() > 0 && dist > target.Meters() {
|
max_dist = target.Meters()
|
||||||
return false
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// don't need actual distances, use haversine as proxy for sorting
|
// don't need actual distances, use haversine as proxy for sorting
|
||||||
dist = target.HaversineTo(o.Center())
|
dist = target.HaversineTo(o.Center())
|
||||||
if target.Haversine() > 0 && dist > target.Haversine() {
|
max_dist = target.Haversine()
|
||||||
return false
|
}
|
||||||
}
|
if max_dist > 0 && dist > max_dist {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
items = append(items, iterItem{id: id, o: o, fields: fields, dist: dist})
|
items = append(items, iterItem{id: id, o: o, fields: fields, dist: dist})
|
||||||
if !keepGoing {
|
if !keepGoing {
|
||||||
|
|
Loading…
Reference in New Issue