From b969e7343976589d55641ef12902e47f85d9fc2c Mon Sep 17 00:00:00 2001 From: re Date: Mon, 12 Dec 2022 15:28:16 +0300 Subject: [PATCH] fix repo --- README.md | 4 ++-- base/knn.go | 2 +- go.mod | 4 ++-- go.sum | 4 ++-- rtree.go | 16 +++++++++++----- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index bce5bf8..19af94d 100644 --- a/README.md +++ b/README.md @@ -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 =========================== -[![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. It has support for 1-20 dimensions, and can store and search multidimensions interchangably in the same tree. diff --git a/base/knn.go b/base/knn.go index 6b26df3..cc5f1e6 100644 --- a/base/knn.go +++ b/base/knn.go @@ -1,7 +1,7 @@ package base import ( - "github.com/tidwall/tinyqueue" + "git.internal/re/tinyqueue" ) type queueItem struct { diff --git a/go.mod b/go.mod index 9fa4967..8166705 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ -module github.com/tidwall/rtred +module git.internal/re/rtred go 1.15 -require github.com/tidwall/tinyqueue v0.1.1 +require git.internal/re/tinyqueue v0.1.3 diff --git a/go.sum b/go.sum index 0fbfb4d..91f6db5 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,2 @@ -github.com/tidwall/tinyqueue v0.1.1 h1:SpNEvEggbpyN5DIReaJ2/1ndroY8iyEGxPYxoSaymYE= -github.com/tidwall/tinyqueue v0.1.1/go.mod h1:O/QNHwrnjqr6IHItYrzoHAKYhBkLI67Q096fQP5zMYw= +git.internal/re/tinyqueue v0.1.3 h1:4EKqZhzHLgoE7qp3+Jy4fLTJ+VXYdnREYiErcW6/Tds= +git.internal/re/tinyqueue v0.1.3/go.mod h1:xwfmZ1Jo/JI0eXLc78eGZv+kEtJipgyui683yVTh7fc= diff --git a/rtree.go b/rtree.go index 89522ca..65a085b 100644 --- a/rtree.go +++ b/rtree.go @@ -4,13 +4,15 @@ import ( "math" "sync" - "github.com/tidwall/rtred/base" + "git.internal/re/rtred/base" ) -type Iterator func(item Item) bool -type Item interface { - Rect(ctx interface{}) (min []float64, max []float64) -} +type ( + Iterator func(item Item) bool + Item interface { + Rect(ctx interface{}) (min []float64, max []float64) + } +) type RTree struct { dims int @@ -85,12 +87,14 @@ func (tr *RTree) Remove(item Item) { tr.used-- } } + func (tr *RTree) Reset() { for i := 0; i < len(tr.trs); i++ { tr.trs[i] = nil } tr.used = 0 } + func (tr *RTree) Count() int { var count int 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 { amin := 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() } + func knn(btr *base.RTree, min, max []float64, center bool, dims int, iter func(item interface{}, dist float64) bool) bool { amin := make([]float64, dims) amax := make([]float64, dims)