mirror of https://github.com/tidwall/tile38.git
Pass Circle into nearestNeighbor.
This commit is contained in:
parent
33530075a4
commit
c673fa01d5
|
@ -390,7 +390,7 @@ func (c *Controller) cmdNearby(msg *server.Message) (res resp.Value, err error)
|
||||||
ignoreGlobMatch: true,
|
ignoreGlobMatch: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
c.nearestNeighbors(&s, sw, s.obj, &matched, iter)
|
c.nearestNeighbors(&s, sw, s.obj.(*geojson.Circle), &matched, iter)
|
||||||
}
|
}
|
||||||
sw.writeFoot()
|
sw.writeFoot()
|
||||||
if msg.OutputType == server.JSON {
|
if msg.OutputType == server.JSON {
|
||||||
|
@ -408,7 +408,7 @@ type iterItem struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) nearestNeighbors(
|
func (c *Controller) nearestNeighbors(
|
||||||
s *liveFenceSwitches, sw *scanWriter, target geojson.Object, matched *uint32,
|
s *liveFenceSwitches, sw *scanWriter, target *geojson.Circle, matched *uint32,
|
||||||
iter func(id string, o geojson.Object, fields []float64, dist *float64,
|
iter func(id string, o geojson.Object, fields []float64, dist *float64,
|
||||||
) bool) {
|
) bool) {
|
||||||
limit := int(sw.cursor + sw.limit)
|
limit := int(sw.cursor + sw.limit)
|
||||||
|
@ -425,7 +425,7 @@ func (c *Controller) nearestNeighbors(
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
dist := o.Distance(target)
|
dist := o.Distance(target)
|
||||||
if target.(*geojson.Circle).Meters() > 0 && dist > target.(*geojson.Circle).Meters() {
|
if target.Meters() > 0 && dist > target.Meters() {
|
||||||
return false
|
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})
|
||||||
|
|
Loading…
Reference in New Issue