mirror of https://github.com/tidwall/tile38.git
parent
bd572b0d38
commit
b47187349b
|
@ -4,6 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"math"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
|
@ -14,7 +15,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tidwall/buntdb"
|
"github.com/tidwall/buntdb"
|
||||||
"github.com/tidwall/geojson"
|
"github.com/tidwall/geojson/geometry"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
"github.com/tidwall/redcon"
|
"github.com/tidwall/redcon"
|
||||||
"github.com/tidwall/resp"
|
"github.com/tidwall/resp"
|
||||||
|
@ -213,11 +214,23 @@ func (s *Server) getQueueCandidates(d *commandDetails) []*Hook {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// search the hook spatial tree
|
// search the hook spatial tree
|
||||||
for _, obj := range []geojson.Object{d.obj, d.oldObj} {
|
// build a rectangle that fills the old and new which will be enough to
|
||||||
if obj == nil {
|
// handle "enter", "inside", "exit", and "cross" detections.
|
||||||
continue
|
var rect geometry.Rect
|
||||||
|
if d.oldObj != nil {
|
||||||
|
rect = d.oldObj.Rect()
|
||||||
|
if d.obj != nil {
|
||||||
|
r2 := d.obj.Rect()
|
||||||
|
rect.Min.X = math.Min(rect.Min.X, r2.Min.X)
|
||||||
|
rect.Min.Y = math.Min(rect.Min.Y, r2.Min.Y)
|
||||||
|
rect.Max.X = math.Max(rect.Max.X, r2.Max.X)
|
||||||
|
rect.Max.Y = math.Max(rect.Max.Y, r2.Max.Y)
|
||||||
|
}
|
||||||
|
} else if d.obj != nil {
|
||||||
|
rect = d.obj.Rect()
|
||||||
|
} else {
|
||||||
|
return candidates
|
||||||
}
|
}
|
||||||
rect := obj.Rect()
|
|
||||||
s.hookTree.Search(
|
s.hookTree.Search(
|
||||||
[2]float64{rect.Min.X, rect.Min.Y},
|
[2]float64{rect.Min.X, rect.Min.Y},
|
||||||
[2]float64{rect.Max.X, rect.Max.Y},
|
[2]float64{rect.Max.X, rect.Max.Y},
|
||||||
|
@ -239,7 +252,6 @@ func (s *Server) getQueueCandidates(d *commandDetails) []*Hook {
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
|
||||||
return candidates
|
return candidates
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue