mirror of https://github.com/tidwall/tile38.git
Allow for WHERE for on geofence detection
This commit is contained in:
parent
757db4d509
commit
cc9320e246
|
@ -191,8 +191,10 @@ func (c *Collection) Set(
|
||||||
oldFieldValues = c.fieldValues.get(oldItem.fieldValuesSlot)
|
oldFieldValues = c.fieldValues.get(oldItem.fieldValuesSlot)
|
||||||
newFieldValues = oldFieldValues
|
newFieldValues = oldFieldValues
|
||||||
newItem.fieldValuesSlot = oldItem.fieldValuesSlot
|
newItem.fieldValuesSlot = oldItem.fieldValuesSlot
|
||||||
|
if len(oldFieldValues) > 0 {
|
||||||
|
oldFieldValues = append([]float64{}, oldFieldValues...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if fields == nil {
|
if fields == nil {
|
||||||
if len(values) > 0 {
|
if len(values) > 0 {
|
||||||
newFieldValues = values
|
newFieldValues = values
|
||||||
|
|
|
@ -105,9 +105,18 @@ func fenceMatch(
|
||||||
}
|
}
|
||||||
detect = "roam"
|
detect = "roam"
|
||||||
} else {
|
} else {
|
||||||
|
var nocross bool
|
||||||
// not using roaming
|
// not using roaming
|
||||||
match1 := fenceMatchObject(fence, details.oldObj)
|
match1 := fenceMatchObject(fence, details.oldObj)
|
||||||
|
if match1 {
|
||||||
|
match1, _, _ = sw.testObject(details.id, details.oldObj, details.oldFields)
|
||||||
|
nocross = !match1
|
||||||
|
}
|
||||||
match2 := fenceMatchObject(fence, details.obj)
|
match2 := fenceMatchObject(fence, details.obj)
|
||||||
|
if match2 {
|
||||||
|
match2, _, _ = sw.testObject(details.id, details.obj, details.fields)
|
||||||
|
nocross = !match2
|
||||||
|
}
|
||||||
if match1 && match2 {
|
if match1 && match2 {
|
||||||
detect = "inside"
|
detect = "inside"
|
||||||
} else if match1 && !match2 {
|
} else if match1 && !match2 {
|
||||||
|
@ -121,7 +130,7 @@ func fenceMatch(
|
||||||
if details.command != "fset" {
|
if details.command != "fset" {
|
||||||
// Maybe the old object and new object create a line that crosses the fence.
|
// Maybe the old object and new object create a line that crosses the fence.
|
||||||
// Must detect for that possibility.
|
// Must detect for that possibility.
|
||||||
if details.oldObj != nil {
|
if !nocross && details.oldObj != nil {
|
||||||
ls := geojson.NewLineString(geometry.NewLine(
|
ls := geojson.NewLineString(geometry.NewLine(
|
||||||
[]geometry.Point{
|
[]geometry.Point{
|
||||||
details.oldObj.Center(),
|
details.oldObj.Center(),
|
||||||
|
@ -176,6 +185,7 @@ func fenceMatch(
|
||||||
o: details.obj,
|
o: details.obj,
|
||||||
fields: details.fields,
|
fields: details.fields,
|
||||||
noLock: true,
|
noLock: true,
|
||||||
|
noTest: true,
|
||||||
distance: distance,
|
distance: distance,
|
||||||
distOutput: fence.distance,
|
distOutput: fence.distance,
|
||||||
})
|
})
|
||||||
|
|
|
@ -68,6 +68,7 @@ type ScanWriterParams struct {
|
||||||
distance float64
|
distance float64
|
||||||
distOutput bool // query or fence requested distance output
|
distOutput bool // query or fence requested distance output
|
||||||
noLock bool
|
noLock bool
|
||||||
|
noTest bool
|
||||||
ignoreGlobMatch bool
|
ignoreGlobMatch bool
|
||||||
clip geojson.Object
|
clip geojson.Object
|
||||||
skipTesting bool
|
skipTesting bool
|
||||||
|
@ -373,9 +374,14 @@ func (sw *scanWriter) writeObject(opts ScanWriterParams) bool {
|
||||||
sw.mu.Lock()
|
sw.mu.Lock()
|
||||||
defer sw.mu.Unlock()
|
defer sw.mu.Unlock()
|
||||||
}
|
}
|
||||||
ok, keepGoing, _ := sw.testObject(opts.id, opts.o, opts.fields)
|
|
||||||
if !ok {
|
keepGoing := true
|
||||||
return keepGoing
|
if !opts.noTest {
|
||||||
|
var ok bool
|
||||||
|
ok, keepGoing, _ = sw.testObject(opts.id, opts.o, opts.fields)
|
||||||
|
if !ok {
|
||||||
|
return keepGoing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sw.count++
|
sw.count++
|
||||||
if sw.output == outputCount {
|
if sw.output == outputCount {
|
||||||
|
|
Loading…
Reference in New Issue