mirror of https://github.com/tidwall/tile38.git
Include "distance" to output when user specifically requests
fixes #599
This commit is contained in:
parent
84a5120bc3
commit
40105e6b7e
|
@ -177,6 +177,7 @@ func fenceMatch(
|
||||||
fields: details.fields,
|
fields: details.fields,
|
||||||
noLock: true,
|
noLock: true,
|
||||||
distance: distance,
|
distance: distance,
|
||||||
|
distOutput: fence.distance,
|
||||||
})
|
})
|
||||||
|
|
||||||
if sw.wr.Len() == 0 {
|
if sw.wr.Len() == 0 {
|
||||||
|
|
|
@ -66,6 +66,7 @@ type ScanWriterParams struct {
|
||||||
o geojson.Object
|
o geojson.Object
|
||||||
fields []float64
|
fields []float64
|
||||||
distance float64
|
distance float64
|
||||||
|
distOutput bool // query or fence requested distance output
|
||||||
noLock bool
|
noLock bool
|
||||||
ignoreGlobMatch bool
|
ignoreGlobMatch bool
|
||||||
clip geojson.Object
|
clip geojson.Object
|
||||||
|
@ -433,7 +434,7 @@ func (sw *scanWriter) writeObject(opts ScanWriterParams) bool {
|
||||||
|
|
||||||
wr.WriteString(jsfields)
|
wr.WriteString(jsfields)
|
||||||
|
|
||||||
if opts.distance > 0 {
|
if opts.distOutput || opts.distance > 0 {
|
||||||
wr.WriteString(`,"distance":` + strconv.FormatFloat(opts.distance, 'f', -1, 64))
|
wr.WriteString(`,"distance":` + strconv.FormatFloat(opts.distance, 'f', -1, 64))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +497,7 @@ func (sw *scanWriter) writeObject(opts ScanWriterParams) bool {
|
||||||
vals = append(vals, resp.ArrayValue(fvals))
|
vals = append(vals, resp.ArrayValue(fvals))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if opts.distance > 0 {
|
if opts.distOutput || opts.distance > 0 {
|
||||||
vals = append(vals, resp.FloatValue(opts.distance))
|
vals = append(vals, resp.FloatValue(opts.distance))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -380,6 +380,7 @@ func (server *Server) cmdNearby(msg *Message) (res resp.Value, err error) {
|
||||||
o: o,
|
o: o,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
distance: meters,
|
distance: meters,
|
||||||
|
distOutput: s.distance,
|
||||||
noLock: true,
|
noLock: true,
|
||||||
ignoreGlobMatch: true,
|
ignoreGlobMatch: true,
|
||||||
skipTesting: true,
|
skipTesting: true,
|
||||||
|
|
Loading…
Reference in New Issue