forked from mirror/rtred
fix repo
This commit is contained in:
parent
fc55586978
commit
b969e73439
|
@ -1,9 +1,9 @@
|
||||||
**This project has been archived, please use [tidwall/rtree](https://github.com/tidwall/rtree) instead.**
|
**This project has been archived, please use [tidwall/rtree](https://git.internal/re/rtree) instead.**
|
||||||
|
|
||||||
RTree implementation for Go
|
RTree implementation for Go
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
[![GoDoc](https://godoc.org/github.com/tidwall/rtred?status.svg)](https://godoc.org/github.com/tidwall/rtred)
|
[![GoDoc](https://godoc.org/git.internal/re/rtred?status.svg)](https://godoc.org/git.internal/re/rtred)
|
||||||
|
|
||||||
This package provides an in-memory R-Tree implementation for Go, useful as a spatial data structure.
|
This package provides an in-memory R-Tree implementation for Go, useful as a spatial data structure.
|
||||||
It has support for 1-20 dimensions, and can store and search multidimensions interchangably in the same tree.
|
It has support for 1-20 dimensions, and can store and search multidimensions interchangably in the same tree.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package base
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/tidwall/tinyqueue"
|
"git.internal/re/tinyqueue"
|
||||||
)
|
)
|
||||||
|
|
||||||
type queueItem struct {
|
type queueItem struct {
|
||||||
|
|
4
go.mod
4
go.mod
|
@ -1,5 +1,5 @@
|
||||||
module github.com/tidwall/rtred
|
module git.internal/re/rtred
|
||||||
|
|
||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require github.com/tidwall/tinyqueue v0.1.1
|
require git.internal/re/tinyqueue v0.1.3
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -1,2 +1,2 @@
|
||||||
github.com/tidwall/tinyqueue v0.1.1 h1:SpNEvEggbpyN5DIReaJ2/1ndroY8iyEGxPYxoSaymYE=
|
git.internal/re/tinyqueue v0.1.3 h1:4EKqZhzHLgoE7qp3+Jy4fLTJ+VXYdnREYiErcW6/Tds=
|
||||||
github.com/tidwall/tinyqueue v0.1.1/go.mod h1:O/QNHwrnjqr6IHItYrzoHAKYhBkLI67Q096fQP5zMYw=
|
git.internal/re/tinyqueue v0.1.3/go.mod h1:xwfmZ1Jo/JI0eXLc78eGZv+kEtJipgyui683yVTh7fc=
|
||||||
|
|
16
rtree.go
16
rtree.go
|
@ -4,13 +4,15 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/tidwall/rtred/base"
|
"git.internal/re/rtred/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Iterator func(item Item) bool
|
type (
|
||||||
type Item interface {
|
Iterator func(item Item) bool
|
||||||
Rect(ctx interface{}) (min []float64, max []float64)
|
Item interface {
|
||||||
}
|
Rect(ctx interface{}) (min []float64, max []float64)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
type RTree struct {
|
type RTree struct {
|
||||||
dims int
|
dims int
|
||||||
|
@ -85,12 +87,14 @@ func (tr *RTree) Remove(item Item) {
|
||||||
tr.used--
|
tr.used--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tr *RTree) Reset() {
|
func (tr *RTree) Reset() {
|
||||||
for i := 0; i < len(tr.trs); i++ {
|
for i := 0; i < len(tr.trs); i++ {
|
||||||
tr.trs[i] = nil
|
tr.trs[i] = nil
|
||||||
}
|
}
|
||||||
tr.used = 0
|
tr.used = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tr *RTree) Count() int {
|
func (tr *RTree) Count() int {
|
||||||
var count int
|
var count int
|
||||||
for _, btr := range tr.trs {
|
for _, btr := range tr.trs {
|
||||||
|
@ -127,6 +131,7 @@ func (tr *RTree) Search(bounds Item, iter Iterator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func search(btr *base.RTree, min, max []float64, dims int, iter Iterator) bool {
|
func search(btr *base.RTree, min, max []float64, dims int, iter Iterator) bool {
|
||||||
amin := make([]float64, dims)
|
amin := make([]float64, dims)
|
||||||
amax := make([]float64, dims)
|
amax := make([]float64, dims)
|
||||||
|
@ -254,6 +259,7 @@ func (tr *RTree) KNN(bounds Item, center bool, iter func(item Item, dist float64
|
||||||
}
|
}
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func knn(btr *base.RTree, min, max []float64, center bool, dims int, iter func(item interface{}, dist float64) bool) bool {
|
func knn(btr *base.RTree, min, max []float64, center bool, dims int, iter func(item interface{}, dist float64) bool) bool {
|
||||||
amin := make([]float64, dims)
|
amin := make([]float64, dims)
|
||||||
amax := make([]float64, dims)
|
amax := make([]float64, dims)
|
||||||
|
|
Loading…
Reference in New Issue