geostore

package
v0.0.0-...-03e4fed Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GpsToAbsolute

func GpsToAbsolute(x, y float64) (xAbs, yAbs float64)

GpsToAbsolute converts the x (longitude) and y (latitude) values of gps coordinates to absolute values to be used on a grid that starts with 0,0 in the bottom-right corner, and ends with xMax,yMax in the top-right corner.

Types

type GeoStore

type GeoStore interface {
	Find(lat, long float64) uint64
	FindNearest(lat, long, maxDistance float64, limit int) []uint64
	Insert(node *Node)
	Shutdown() error
	// contains filtered or unexported methods
}

type InMemGeoStore

type InMemGeoStore struct {
	Root *QuadTree
	// contains filtered or unexported fields
}

func NewGeoStoreInMem

func NewGeoStoreInMem(root *QuadTree) *InMemGeoStore

func (*InMemGeoStore) Find

func (g *InMemGeoStore) Find(lat, long float64) uint64

func (*InMemGeoStore) FindNearest

func (g *InMemGeoStore) FindNearest(
	lat, long, maxDistance float64,
	limit int,
) []uint64

Find will return a slice of nodes that are nearest to the provided lat/long coordinates. Currently, we are just going to return the nodes in the same quadrant in which this node would otherwise be inserted and will leave implementing max distance and limit for later.

func (*InMemGeoStore) Insert

func (g *InMemGeoStore) Insert(node *Node)

func (*InMemGeoStore) Shutdown

func (g *InMemGeoStore) Shutdown() error

type Node

type Node struct {
	X, Y float64
	Id   uint64
}

func NewNode

func NewNode(long, lat float64, id uint64) *Node

type QuadTree

type QuadTree struct {
	MaxCapacity int
	Level       int
	Nodes       []*Node
	NW          *QuadTree
	NE          *QuadTree
	SW          *QuadTree
	SE          *QuadTree
	QuadTrees   []*QuadTree
	Quadrant    *Quadrant
	// contains filtered or unexported fields
}

func NewQuadTree

func NewQuadTree(level int, quadrant *Quadrant, maxCapacity int) *QuadTree

type Quadrant

type Quadrant struct {
	XMin, YMin, XMax, YMax float64
}

func NewQuadrant

func NewQuadrant(xMin, yMin, xMax, yMax float64, convertFromGps bool) *Quadrant

type Stack

type Stack[T any] struct {
	// contains filtered or unexported fields
}

func (*Stack[T]) IsEmpty

func (s *Stack[T]) IsEmpty() bool

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() *T

func (*Stack[T]) Push

func (s *Stack[T]) Push(q *T)

Jump to

Keyboard shortcuts

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