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 ¶
- type ClusteringIndex
- type CountIndex
- type CountPoint
- type GeoPoint
- type Index
- type Meters
- type Minutes
- type Point
- type PointsIndex
- func (points *PointsIndex) Add(point Point)
- 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) Range(topLeft Point, bottomRight Point) []Point
- func (points *PointsIndex) Remove(id string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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) 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) 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 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 NewExpiringPointsIndexWithCallback ¶
func NewExpiringPointsIndexWithCallback(resolution Meters, expiration Minutes, callback func(point Point)) *PointsIndex
NewExpiringPointsIndex creates new PointIndex that expires the points in each cell after expiration minutes. the callback will be called when the point gets deleted
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) 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) 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.