-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboundingbox.go
51 lines (41 loc) · 858 Bytes
/
boundingbox.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package spatial
import (
"fmt"
"sync/atomic"
"github.com/dhconnelly/rtreego"
)
type boundingBox struct {
id string
bounds *rtreego.Rect
listener *Listener
}
var (
bboxAutoID uint64 = 0
)
func newBoundingBox(bounds *rtreego.Rect, lstr *Listener) *boundingBox {
id := atomic.AddUint64(&bboxAutoID, 1)
return &boundingBox{
id: fmt.Sprintf("bbx:%d", id),
bounds: bounds,
listener: lstr,
}
}
func (b boundingBox) ID() string {
return b.id
}
func (b boundingBox) Bounds() *rtreego.Rect {
return b.bounds
}
func (b boundingBox) Type() IndexableType {
return itBoundingBox
}
func (b boundingBox) Ref() interface{} {
return nil
}
func collectListeners(boxes []boundingBox) map[*Listener]*Listener {
lmap := make(map[*Listener]*Listener)
for _, box := range boxes {
lmap[box.listener] = box.listener
}
return lmap
}