ds

package
v0.0.0-...-82e51c3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DistanceOnEarth

func DistanceOnEarth(location1, location2 GeoLocation) float64

func EuclideanDistance

func EuclideanDistance(location1, location2 GeoLocation) float64

func NewMap

func NewMap() *concurrentMap

Types

type GeoLocation

type GeoLocation interface {
	Lat() float64
	Long() float64
	DistanceTo(location GeoLocation) float64
	IntersectsRectangle(Rectangle, int) bool
}

type Position

type Position struct {
	Latitude, Longitude float64
}

func NewPosition

func NewPosition(lat float64, long float64) *Position

func (Position) DistanceTo

func (p Position) DistanceTo(location GeoLocation) float64

func (Position) IntersectsRectangle

func (p Position) IntersectsRectangle(r Rectangle, radiusInMetres int) bool

func (Position) Lat

func (p Position) Lat() float64

func (Position) Long

func (p Position) Long() float64

type QuadTree

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

func NewQuadTree

func NewQuadTree(height int) *QuadTree

func (*QuadTree) Delete

func (q *QuadTree) Delete(locationID string) error

func (*QuadTree) Get

func (q *QuadTree) Get(locationID string) (QuadTreeLeaf, error)

func (QuadTree) GetAllLocations

func (q QuadTree) GetAllLocations() QuadTreeSnapshot

func (*QuadTree) GetNearbyLocations

func (q *QuadTree) GetNearbyLocations(location Position, radiusInMetres, limit int) []QuadTreeNeighborResult

func (*QuadTree) Insert

func (q *QuadTree) Insert(locationID string, location Position, data map[string]interface{})

func (*QuadTree) Update

func (q *QuadTree) Update(locationID string, location Position, data map[string]interface{}) error

func (*QuadTree) UpdateData

func (q *QuadTree) UpdateData(locationID string, data map[string]interface{}) error

func (*QuadTree) UpdateLocation

func (q *QuadTree) UpdateLocation(locationID string, location Position) error

type QuadTreeLeaf

type QuadTreeLeaf struct {
	Location   Position               `json:"location"`
	LocationID string                 `json:"locationID"`
	Data       map[string]interface{} `json:"data"`
}

func NewQuadTreeLeaf

func NewQuadTreeLeaf(location Position, locationID string, data map[string]interface{}) *QuadTreeLeaf

func (QuadTreeLeaf) GetLocation

func (q QuadTreeLeaf) GetLocation() Position

func (QuadTreeLeaf) GetLocationID

func (q QuadTreeLeaf) GetLocationID() string

type QuadTreeNeighborResult

type QuadTreeNeighborResult struct {
	Leaf     QuadTreeLeaf `json:"Leaf"`
	Distance float64      `json:"Distance"`
}

func NewQuadTreeNeighborResult

func NewQuadTreeNeighborResult(leaf QuadTreeLeaf, distance float64) *QuadTreeNeighborResult

type QuadTreeNode

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

func NewQuadTreeNode

func NewQuadTreeNode(boundingBox Rectangle, children *[4]*QuadTreeNode, isLeaf bool, leaves *map[string]*QuadTreeLeaf, parent *QuadTreeNode) *QuadTreeNode

type QuadTreeSnapshot

type QuadTreeSnapshot map[string]QuadTreeLeaf

type Quadrille

type Quadrille interface {
	Insert(string, Position, map[string]interface{})
	Delete(string) error
	Update(string, Position, map[string]interface{}) error
	UpdateLocation(string, Position) error
	UpdateData(string, map[string]interface{}) error
	GetNearbyLocations(Position, int, int) []QuadTreeNeighborResult
	Get(string) (QuadTreeLeaf, error)
	GetAllLocations() QuadTreeSnapshot
}

type Rectangle

type Rectangle interface {
	Corner1() GeoLocation
	Corner2() GeoLocation
	GetAllCorners() [4]GeoLocation
	GetNearestCorner(location GeoLocation) GeoLocation
	GetQuadrants() [4]Rectangle
}

func NewRectangle

func NewRectangle(corner1, corner2 GeoLocation) Rectangle

Jump to

Keyboard shortcuts

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