`import "github.com/dhconnelly/rtreego"`

Package rtreego is a library for efficiently storing and querying spatial data.

- type Comparator
- type DimError
- type DistError
- type Filter
- type Point
- type Rect
- func NewRect(p Point, lengths []float64) (r *Rect, err error)
- func NewRectFromPoints(minPoint, maxPoint Point) (r *Rect, err error)
- func (r *Rect) Equal(other *Rect) bool
- func (r *Rect) LengthsCoord(i int) float64
- func (r *Rect) PointCoord(i int) float64
- func (r *Rect) Size() float64
- func (r *Rect) String() string
- type Rtree
- func NewTree(dim, min, max int, objs ...Spatial) *Rtree
- func (tree *Rtree) Delete(obj Spatial) bool
- func (tree *Rtree) DeleteWithComparator(obj Spatial, cmp Comparator) bool
- func (tree *Rtree) Depth() int
- func (tree *Rtree) GetAllBoundingBoxes() []*Rect
- func (tree *Rtree) Insert(obj Spatial)
- func (tree *Rtree) NearestNeighbor(p Point) Spatial
- func (tree *Rtree) NearestNeighbors(k int, p Point, filters ...Filter) []Spatial
- func (tree *Rtree) SearchIntersect(bb *Rect, filters ...Filter) []Spatial
- func (tree *Rtree) SearchIntersectWithLimit(k int, bb *Rect) []Spatial
- func (tree *Rtree) Size() int
- func (tree *Rtree) String() string
- type Spatial

Comparator compares two spatials and returns whether they are equal.

DimError represents a failure due to mismatched dimensions.

DistError is an improper distance measurement. It implements the error and is generated when a distance-related assertion fails.

Filter is an interface for filtering leaves during search. The parameters should be treated as read-only. If refuse is true, the current entry will not be added to the result set. If abort is true, the search is aborted and the current result set will be returned.

LimitFilter checks if the results have reached the limit size and aborts if so.

Point represents a point in n-dimensional Euclidean space.

ToRect constructs a rectangle containing p with side lengths 2*tol.

❖

```
type Rect struct {
// contains filtered or unexported fields
}
```

Rect represents a subset of n-dimensional Euclidean space of the form [a1, b1] x [a2, b2] x ... x [an, bn], where ai < bi for all 1 <= i <= n.

NewRect constructs and returns a pointer to a Rect given a corner point and the lengths of each dimension. The point p should be the most-negative point on the rectangle (in every dimension) and every length should be positive.

NewRectFromPoints constructs and returns a pointer to a Rect given a corner points.

Equal returns true if the two rectangles are equal

LengthsCoord returns the coordinate of the lengths of the rectangle at i

PointCoord returns the coordinate of the point of the rectangle at i

Size computes the measure of a rectangle (the product of its side lengths).

❖

type Rtree struct { Dim int MinChildren int MaxChildren int // contains filtered or unexported fields }

Rtree represents an R-tree, a balanced search tree for storing and querying spatial objects. Dim specifies the number of spatial dimensions and MinChildren/MaxChildren specify the minimum/maximum branching factors.

NewTree returns an Rtree. If the number of objects given on initialization is larger than max, the Rtree will be initialized using the Overlap Minimizing Top-down bulk-loading algorithm.

Delete removes an object from the tree. If the object is not found, returns false, otherwise returns true. Uses the default comparator when checking equality.

Implemented per Section 3.3 of "R-trees: A Dynamic Index Structure for Spatial Searching" by A. Guttman, Proceedings of ACM SIGMOD, p. 47-57, 1984.

❖

func (tree *Rtree) DeleteWithComparator(obj Spatial, cmp Comparator) bool

DeleteWithComparator removes an object from the tree using a custom comparator for evaluating equalness. This is useful when you want to remove an object from a tree but don't have a pointer to the original object anymore.

Depth returns the maximum depth of tree.

GetAllBoundingBoxes returning slice of bounding boxes by traversing tree. Slice includes bounding boxes from all non-leaf nodes.

Insert inserts a spatial object into the tree. If insertion causes a leaf node to overflow, the tree is rebalanced automatically.

Implemented per Section 3.2 of "R-trees: A Dynamic Index Structure for Spatial Searching" by A. Guttman, Proceedings of ACM SIGMOD, p. 47-57, 1984.

NearestNeighbor returns the closest object to the specified point. Implemented per "Nearest Neighbor Queries" by Roussopoulos et al

NearestNeighbors gets the closest Spatials to the Point.

SearchIntersect returns all objects that intersect the specified rectangle. Implemented per Section 3.1 of "R-trees: A Dynamic Index Structure for Spatial Searching" by A. Guttman, Proceedings of ACM SIGMOD, p. 47-57, 1984.

SearchIntersectWithLimit is similar to SearchIntersect, but returns immediately when the first k results are found. A negative k behaves exactly like SearchIntersect and returns all the results.

Kept for backwards compatibility, please use SearchIntersect with a LimitFilter.

Size returns the number of objects currently stored in tree.

Spatial is an interface for objects that can be stored in an Rtree and queried.

Package rtreego imports 4 packages (graph) and is imported by 24 packages. Updated 2020-02-18. Refresh now. Tools for package owners.