Documentation ¶
Overview ¶
Package quadtree A Quadtree is a spatial index structure for efficient range querying
of items bounded by 2D rectangles.
Index ¶
- Constants
- func ComputeQuadLevel(env *envelope.Envelope) int
- func EnsureExtent(itemEnv *envelope.Envelope, minExtent float64) *envelope.Envelope
- func IsZeroWidth(min, max float64) bool
- func SubnodeIndex(env *envelope.Envelope, centrex, centrey float64) int
- type IntervalSize
- type Key
- type Node
- func (n *Node) Add(item interface{})
- func (n *Node) CreateSubnode(index int) *Node
- func (n *Node) Depth() int
- func (n *Node) Find(searchEnv *envelope.Envelope) *Node
- func (n *Node) GetNode(searchEnv *envelope.Envelope) *Node
- func (n *Node) GetSubnode(index int) *Node
- func (n *Node) HasChildren() bool
- func (n *Node) HasItems() bool
- func (n *Node) InsertNode(node *Node)
- func (n *Node) IsEmpty() bool
- func (n *Node) IsPrunable() bool
- func (n *Node) IsSearchMatch(searchEnv *envelope.Envelope) bool
- func (n *Node) NodeCount() int
- func (n *Node) Remove(itemEnv *envelope.Envelope, item interface{}) bool
- func (n *Node) Size() int
- func (n *Node) Visit(searchEnv *envelope.Envelope, visitor index.ItemVisitor)
- func (n *Node) VisitItems(searchEnv, nodeEnv *envelope.Envelope, visitor index.ItemVisitor)
- type Quadtree
- func (q *Quadtree) CollectStats(itemEnv *envelope.Envelope)
- func (q *Quadtree) Depth() int
- func (q *Quadtree) Insert(itemEnv *envelope.Envelope, item interface{}) error
- func (q *Quadtree) IsEmpty() bool
- func (q *Quadtree) Query(searchEnv *envelope.Envelope) interface{}
- func (q *Quadtree) QueryVisitor(searchEnv *envelope.Envelope, visitor index.ItemVisitor) error
- func (q *Quadtree) Remove(itemEnv *envelope.Envelope, item interface{}) bool
- func (q *Quadtree) Size() int
- type Root
- func (r *Root) Insert(itemEnv *envelope.Envelope, item interface{})
- func (r *Root) InsertContained(tree *Node, itemEnv *envelope.Envelope, item interface{})
- func (r *Root) IsSearchMatch(searchEnv *envelope.Envelope) bool
- func (r *Root) Remove(itemEnv *envelope.Envelope, item interface{}) bool
- func (r *Root) Visit(searchEnv *envelope.Envelope, visitor index.ItemVisitor)
Constants ¶
const MinBinaryExponent = -50
MinBinaryExponent ...
Variables ¶
This section is empty.
Functions ¶
func EnsureExtent ¶
EnsureExtent Ensure that the envelope for the inserted item has non-zero extents.
Use the current minExtent to pad the envelope, if necessary
func IsZeroWidth ¶
IsZeroWidth Computes whether the interval [min, max] is effectively zero width.
I.e. the width of the interval is so much less than the location of the interval that the midpoint of the interval cannot be represented precisely.
Types ¶
type IntervalSize ¶
type IntervalSize struct { }
IntervalSize Provides a test for whether an interval is
so small it should be considered as zero for the purposes of inserting it into a binary tree.
type Key ¶
Key A Key is a unique identifier for a node in a quadtree.
It contains a lower-left point and a level number. The level number is the power of two for the size of the node envelope
func (*Key) ComputeKey ¶
ComputeKey return a square envelope containing the argument envelope, whose extent is a power of two and which is based at a power of 2
type Node ¶
type Node struct { Items []interface{} Subnode [4]*Node Env *envelope.Envelope Centrex, Centrey float64 Level int }
Node Represents a node of a Quadtree. Nodes contain
items which have a spatial extent corresponding to the node's position in the quadtree.
func NewNodeEnv ¶ added in v1.0.1
NewNodeEnv ...
func NewNodeExpanded ¶ added in v1.0.1
NewNodeExpanded ...
func (*Node) GetNode ¶
GetNode Returns the subquad containing the envelope searchEnv. Creates the subquad if it does not already exist.
func (*Node) GetSubnode ¶
GetSubnode get the subquad for the index. If it doesn't exist, create it
func (*Node) IsSearchMatch ¶
IsSearchMatch ...
func (*Node) Visit ¶
func (n *Node) Visit(searchEnv *envelope.Envelope, visitor index.ItemVisitor)
Visit ...
func (*Node) VisitItems ¶
func (n *Node) VisitItems(searchEnv, nodeEnv *envelope.Envelope, visitor index.ItemVisitor)
VisitItems ...
type Quadtree ¶
Quadtree A Quadtree is a spatial index structure for efficient range querying
of items bounded by 2D rectangles. Geometries can be indexed by using their Envelopes. Any type of Object can also be indexed as long as it has an extent that can be represented by an Envelope.
func NewQuadtree ¶ added in v1.0.1
func NewQuadtree() *Quadtree
NewQuadtree Constructs a Quadtree with zero items.
func (*Quadtree) CollectStats ¶
CollectStats ...
func (*Quadtree) Query ¶
Query Queries the tree and returns items which may lie in the given search envelope.
func (*Quadtree) QueryVisitor ¶
QueryVisitor Queries the tree and visits items which may lie in the given search envelope.
type Root ¶
type Root struct { *Node // contains filtered or unexported fields }
Root QuadRoot is the root of a single Quadtree. It is centred at the origin, and does not have a defined extent.
func (*Root) InsertContained ¶
InsertContained insert an item which is known to be contained in the tree rooted at
the given QuadNode root. Lower levels of the tree will be created if necessary to hold the item.
func (*Root) IsSearchMatch ¶
IsSearchMatch ...