insidetree

package module
v0.0.0-...-1aba251 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2020 License: BSD-3-Clause Imports: 2 Imported by: 1

README

Build Status

insidetree

This datastructure is specialized in indexing S2 cells to perform stab queries (Point in Polygons).

For explanations about s2 and the tree used in this package look at this great blogpost

It's an alternative of using an interval tree like in this other project exposed in this blogpost.

tree := NewTree()

// index you cells using Index()
tree.Index(cell, "Red building")

// test for cell of any levels 
insideCell := s2.CellIDFromLatLng(s2.LatLngFromDegrees(46.83808, -71.28046))
results := tree.Stab(insideCell)
// results[0] == "Red Building"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node is the graph unit

func (*Node) SubNodes

func (n *Node) SubNodes() []*Node

SubNodes returns the 4 subnodes if existing

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

Tree root stores nodes starting by the 6 faces of the cube

func NewTree

func NewTree() *Tree

NewTree returns a new tree ready for use

func (*Tree) Index

func (t *Tree) Index(c s2.CellID, v interface{})

Index a cell

func (*Tree) Mask

func (t *Tree) Mask(c s2.CellID) []interface{}

Mask looks for all value masked by a cell and sub cells

func (*Tree) Stab

func (t *Tree) Stab(c s2.CellID) []interface{}

Stab look through the tree for matching sub cells

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL