Skip to content

Commit

Permalink
go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
dhconnelly committed Mar 15, 2012
1 parent 45b155b commit 3a1747d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions rtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ func (tree *Rtree) Size() int {
// node represents a tree node of an Rtree.
type node struct {
parent *node
leaf bool
leaf bool
entries []entry
}

// entry represents a spatial index record stored in a tree node.
type entry struct {
bb *Rect // bounding-box of all children of this entry
child *node
obj *Spatial
bb *Rect // bounding-box of all children of this entry
child *node
obj *Spatial
}

// Any type that implements Spatial can be stored in an Rtree and queried.
Expand Down Expand Up @@ -156,17 +156,17 @@ func (n *node) split(minGroupSize int) (left, right *node) {
next := pickNext(left, right, remaining)
e := remaining[next]

if len(remaining) + len(left.entries) <= minGroupSize {
if len(remaining)+len(left.entries) <= minGroupSize {
assign(e, left)
} else if len(remaining) + len(right.entries) <= minGroupSize {
} else if len(remaining)+len(right.entries) <= minGroupSize {
assign(e, right)
} else {
assignGroup(e, left, right)
}

remaining = append(remaining[:next], remaining[next+1:]...)
}

return
}

Expand Down
18 changes: 9 additions & 9 deletions rtree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ func mustRect(p Point, widths []float64) *Rect {
return r
}

var chooseLeafTests = []struct{
var chooseLeafTests = []struct {
bb0, bb1, bb2 *Rect // leaf bounding boxes
exp int // expected chosen leaf
desc string
exp int // expected chosen leaf
desc string
}{
{
mustRect(Point{1, 1, 1}, []float64{1, 1, 1}),
Expand Down Expand Up @@ -56,13 +56,13 @@ func TestChooseLeaf(t *testing.T) {
for _, test := range chooseLeafTests {
rt := Rtree{}
rt.root = node{}

leaf0 := &node{&rt.root, true, []entry{}}
entry0 := entry{test.bb0, leaf0, nil}

leaf1 := &node{&rt.root, true, []entry{}}
entry1 := entry{test.bb1, leaf1, nil}

leaf2 := &node{&rt.root, true, []entry{}}
entry2 := entry{test.bb2, leaf2, nil}

Expand Down Expand Up @@ -200,7 +200,7 @@ func TestAdjustTreeNoPreviousSplit(t *testing.T) {
entries := []entry{r00, r01, r10}
n := node{&rt.root, false, entries}
rt.root.entries = []entry{entry{bb: Point{0, 0}.ToRect(0), child: &n}}

rt.adjustTree(&n, nil)

e := &rt.root.entries[0]
Expand All @@ -217,7 +217,7 @@ func TestAdjustTreeNoSplit(t *testing.T) {
r01 := entry{bb: mustRect(Point{0, 1}, []float64{1, 1})}
left := node{&rt.root, false, []entry{r00, r01}}
leftEntry := entry{bb: Point{0, 0}.ToRect(0), child: &left}

r10 := entry{bb: mustRect(Point{1, 0}, []float64{1, 1})}
r11 := entry{bb: mustRect(Point{1, 1}, []float64{1, 1})}
right := node{&rt.root, false, []entry{r10, r11}}
Expand Down Expand Up @@ -250,7 +250,7 @@ func TestAdjustTreeSplitParent(t *testing.T) {
r01 := entry{bb: mustRect(Point{0, 1}, []float64{1, 1})}
left := node{&rt.root, false, []entry{r00, r01}}
leftEntry := entry{bb: Point{0, 0}.ToRect(0), child: &left}

r10 := entry{bb: mustRect(Point{1, 0}, []float64{1, 1})}
r11 := entry{bb: mustRect(Point{1, 1}, []float64{1, 1})}
right := node{&rt.root, false, []entry{r10, r11}}
Expand Down

0 comments on commit 3a1747d

Please sign in to comment.