coords

package
v2025.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coords

type Coords[V orb.Pointer] struct {
	// Embeds the ICoords interface for generic spatial operations
	ICoords[V]
	// contains filtered or unexported fields
}

Coords provides a thread-safe wrapper around a quadtree for storing and querying coordinates.

func New

func New[V orb.Pointer]() *Coords[V]

New creates a new Coords instance with default bounds.

func NewWithBounds

func NewWithBounds[V orb.Pointer](bounds orb.Bound) *Coords[V]

NewWithBounds creates a new Coords instance with the specified bounds.

func (*Coords[V]) Add

func (p *Coords[V]) Add(point orb.Pointer) error

Add inserts a point into the quadtree.

func (*Coords[V]) Closest

func (p *Coords[V]) Closest(x, y float64) (V, bool)

Closest returns the closest point to the given coordinates, if any.

func (*Coords[V]) Get

func (p *Coords[V]) Get(point orb.Pointer, fn quadtree.FilterFunc) V

Get returns the value of a point matching the filter from the quadtree.

func (*Coords[V]) Has

func (p *Coords[V]) Has(point orb.Pointer, fn quadtree.FilterFunc) bool

Has returns true if a point matching the filter exists in the quadtree.

func (*Coords[V]) KNearest

func (p *Coords[V]) KNearest(point orb.Point, max int, fn quadtree.FilterFunc, maxDistance float64) []orb.Pointer

KNearest returns up to max nearest points to the given point, filtered and within maxDistance.

func (*Coords[V]) Remove

func (p *Coords[V]) Remove(point orb.Pointer, fn quadtree.FilterFunc) bool

Remove deletes a point matching the filter from the quadtree.

func (*Coords[V]) Replace

func (p *Coords[V]) Replace(point orb.Pointer, fn quadtree.FilterFunc, equalFn CoordsEqualFn) error

Replace removes a point if it exists (and is not equal according to equalFn), then adds the new point.

type CoordsEqualFn

type CoordsEqualFn = func(orb.Pointer, orb.Pointer) bool

CoordsEqualFn must return true if both points are equal.

type CoordsRO

type CoordsRO[V orb.Pointer] struct {
	// Embeds the ICoords interface for generic spatial operations
	ICoords[V]
	// contains filtered or unexported fields
}

CoordsRO provides a read-only wrapper around a quadtree for spatial queries.

func NewReadOnly

func NewReadOnly[V orb.Pointer](points []V) (*CoordsRO[V], error)

NewReadOnly creates a new read-only coordinate store from a slice of points. Returns an error if any point cannot be added to the quadtree.

func (*CoordsRO[V]) Closest

func (p *CoordsRO[V]) Closest(x, y float64) (V, bool)

Closest returns the closest point to the given coordinates, if any.

func (*CoordsRO[V]) Get

func (p *CoordsRO[V]) Get(point orb.Pointer, fn quadtree.FilterFunc) V

Get returns the value of a point matching the filter from the quadtree.

func (*CoordsRO[V]) Has

func (p *CoordsRO[V]) Has(point orb.Pointer, fn quadtree.FilterFunc) bool

Has returns true if a point matching the filter exists in the quadtree.

func (*CoordsRO[V]) KNearest

func (p *CoordsRO[V]) KNearest(point orb.Pointer, max int, fn quadtree.FilterFunc, maxDistance float64) []orb.Pointer

KNearest returns up to max nearest points to the given point, filtered and within maxDistance.

type ICoords

type ICoords[V orb.Pointer] interface {
	ICoordsRO[V]

	Add(orb.Pointer) error
	Remove(orb.Pointer, quadtree.FilterFunc) bool
	Replace(orb.Pointer, quadtree.FilterFunc) error
}

ICoords defines the interface for coordinate storage and spatial queries.

type ICoordsRO added in v2025.6.3

type ICoordsRO[V orb.Pointer] interface {
	Has(orb.Pointer, quadtree.FilterFunc) bool
	Get(orb.Pointer, quadtree.FilterFunc) V

	Closest(float64, float64) (V, bool)
	KNearest(orb.Pointer, int, quadtree.FilterFunc, float64) []orb.Pointer
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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