Documentation ¶
Overview ¶
Package geoindex provides in memory geoindex implementation. It works by splitting the earth surface into grid with fixed size cells and storing data in each cell. The data can be points, count of points, and expiring points/counts. Has Range and K-Nearest queries.
Index ¶
- func BearingTo(p1, p2 Point) float64
- type ClusteringIndex
- func (index *ClusteringIndex) Add(point Point)
- func (index *ClusteringIndex) Clone() *ClusteringIndex
- func (index *ClusteringIndex) KNearest(point Point, k int, maxDistance Meters, accept func(p Point) bool) []Point
- func (index *ClusteringIndex) Range(topLeft Point, bottomRight Point) []Point
- func (index *ClusteringIndex) Remove(id string)
- type CountIndex
- func (countIndex *CountIndex) Add(point Point)
- func (index *CountIndex) Clone() *CountIndex
- func (index *CountIndex) KNearest(point Point, k int, maxDistance Meters, accept func(p Point) bool) []Point
- func (countIndex *CountIndex) Range(topLeft Point, bottomRight Point) []Point
- func (countIndex *CountIndex) Remove(id string)
- type CountPoint
- type Direction
- type GeoPoint
- type Index
- type Meters
- type Minutes
- type Point
- type PointsIndex
- func (points *PointsIndex) Add(point Point)
- func (pi *PointsIndex) Clone() *PointsIndex
- func (points *PointsIndex) Get(id string) Point
- func (points *PointsIndex) GetAll() map[string]Point
- func (points *PointsIndex) KNearest(point Point, k int, maxDistance Meters, accept func(p Point) bool) []Point
- func (points *PointsIndex) PointsWithin(point Point, distance Meters, accept func(p Point) bool) []Point
- func (points *PointsIndex) Range(topLeft Point, bottomRight Point) []Point
- func (points *PointsIndex) Remove(id string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClusteringIndex ¶
type ClusteringIndex struct {
// contains filtered or unexported fields
}
func NewClusteringIndex ¶
func NewClusteringIndex() *ClusteringIndex
NewClusteringIndex creates index that clusters the points at three levels with cell size 0.5, 5 and 500km. Useful for creating maps.
func NewExpiringClusteringIndex ¶
func NewExpiringClusteringIndex(expiration Minutes) *ClusteringIndex
NewExpiringClusteringIndex creates index that clusters the points at three levels with cell size 0.5, 5 and 500km and expires them after expiration minutes.
func (*ClusteringIndex) Clone ¶
func (index *ClusteringIndex) Clone() *ClusteringIndex
func (*ClusteringIndex) KNearest ¶
func (index *ClusteringIndex) KNearest(point Point, k int, maxDistance Meters, accept func(p Point) bool) []Point
KNearest returns the K-Nearest points near point within maxDistance, that match the accept function.
func (*ClusteringIndex) Range ¶
func (index *ClusteringIndex) Range(topLeft Point, bottomRight Point) []Point
Range returns points or count points depending on the size of the topLeft and bottomRight range.
func (*ClusteringIndex) Remove ¶
func (index *ClusteringIndex) Remove(id string)
Remove removes a point.
type CountIndex ¶
type CountIndex struct {
// contains filtered or unexported fields
}
func NewCountIndex ¶
func NewCountIndex(resolution Meters) *CountIndex
NewCountIndex creates an index which counts the points in each cell.
func NewExpiringCountIndex ¶
func NewExpiringCountIndex(resolution Meters, expiration Minutes) *CountIndex
NewExpiringCountIndex creates an index, which maintains an expiring counter for each cell.
func (*CountIndex) Clone ¶
func (index *CountIndex) Clone() *CountIndex
func (*CountIndex) KNearest ¶
func (index *CountIndex) KNearest(point Point, k int, maxDistance Meters, accept func(p Point) bool) []Point
KNearest just to satisfy an interface. Doesn't make much sense for count index.
type CountPoint ¶
type CountPoint struct { *GeoPoint Count interface{} }
func (*CountPoint) String ¶
func (p *CountPoint) String() string
type Direction ¶
type Direction int
func DirectionTo ¶
DirectionTo returns the direction from p1 to p2
type PointsIndex ¶
type PointsIndex struct {
// contains filtered or unexported fields
}
A geoindex that stores points.
func NewExpiringPointsIndex ¶
func NewExpiringPointsIndex(resolution Meters, expiration Minutes) *PointsIndex
NewExpiringPointsIndex creates new PointIndex that expires the points in each cell after expiration minutes.
func NewPointsIndex ¶
func NewPointsIndex(resolution Meters) *PointsIndex
NewPointsIndex creates new PointsIndex that maintains the points in each cell.
func (*PointsIndex) Add ¶
func (points *PointsIndex) Add(point Point)
Add adds a point to the index. If a point with the same Id already exists it gets replaced.
func (*PointsIndex) Clone ¶
func (pi *PointsIndex) Clone() *PointsIndex
func (*PointsIndex) Get ¶
func (points *PointsIndex) Get(id string) Point
Get gets a point from the index given an id.
func (*PointsIndex) GetAll ¶
func (points *PointsIndex) GetAll() map[string]Point
GetAll get all Points from the index as a map from id to point
func (*PointsIndex) KNearest ¶
func (points *PointsIndex) KNearest(point Point, k int, maxDistance Meters, accept func(p Point) bool) []Point
KNearest returns the k nearest points near point within maxDistance that match the accept criteria.
func (*PointsIndex) PointsWithin ¶
func (points *PointsIndex) PointsWithin(point Point, distance Meters, accept func(p Point) bool) []Point
PointsWithin returns all points with distance of point that match the accept criteria.
func (*PointsIndex) Range ¶
func (points *PointsIndex) Range(topLeft Point, bottomRight Point) []Point
Range returns the points within the range defined by top left and bottom right.
func (*PointsIndex) Remove ¶
func (points *PointsIndex) Remove(id string)
Remove removes a point from the index.