コード例 #1
0
func newRectangeFromRect(rect rtree.Rectangle) *rectangle {
	r := &rectangle{}
	x, y := rect.LowerLeft()
	r.xlow = x
	r.ylow = y

	x, y = rect.UpperRight()
	r.xhigh = x
	r.yhigh = y

	return r
}
コード例 #2
0
func equal(r1, r2 rtree.Rectangle) bool {
	xlow1, ylow1 := r1.LowerLeft()
	xhigh2, yhigh2 := r2.UpperRight()

	xhigh1, yhigh1 := r1.UpperRight()
	xlow2, ylow2 := r2.LowerLeft()

	return xlow1 == xlow2 && xhigh1 == xhigh2 && ylow1 == ylow2 && yhigh1 == yhigh2
}
コード例 #3
0
func (r *rectangle) adjust(rect rtree.Rectangle) {
	x, y := rect.LowerLeft()
	if x < r.xlow {
		r.xlow = x
	}
	if y < r.ylow {
		r.ylow = y
	}

	x, y = rect.UpperRight()
	if x > r.xhigh {
		r.xhigh = x
	}

	if y > r.yhigh {
		r.yhigh = y
	}
}
コード例 #4
0
ファイル: hilbert.go プロジェクト: amareshp/go-datastructures
func getCenter(rect rtree.Rectangle) (int32, int32) {
	xlow, ylow := rect.LowerLeft()
	xhigh, yhigh := rect.UpperRight()

	return (xhigh + xlow) / 2, (yhigh + ylow) / 2
}
コード例 #5
0
func intersect(rect1 *rectangle, rect2 rtree.Rectangle) bool {
	xhigh2, yhigh2 := rect2.UpperRight()
	xlow2, ylow2 := rect2.LowerLeft()

	return xhigh2 >= rect1.xlow && xlow2 <= rect1.xhigh && yhigh2 >= rect1.ylow && ylow2 <= rect1.yhigh
}