Documentation ¶
Overview ¶
Package cluster implements DBScan clustering on (lat, lon) using K-D Tree
Index ¶
- Constants
- func DistanceSpherical(p1, p2 *Point) float64
- func DistanceSphericalFast(p1, p2 *Point) float64
- func FastCos(x float64) float64
- func FastSine(x float64) float64
- func Inside(innerMin, innerMax, outerMin, outerMax *Point) bool
- func RegionQuery(points PointList, P *Point, eps float64) []int
- type Cluster
- type EpsFunction
- type KDTree
- type Point
- type PointList
- type T
Constants ¶
const ( // DegreeRad is coefficient to translate from degrees to radians DegreeRad = math.Pi / 180.0 // EarthR is earth radius in km EarthR = 6371.0 )
Variables ¶
This section is empty.
Functions ¶
func DistanceSpherical ¶
DistanceSpherical is a spherical (optimized) distance between two points
Result is distance in kilometers
func DistanceSphericalFast ¶
DistanceSphericalFast calculates spherical distance with fast cosine without sqrt and normalization to Earth radius/radians
To get real distance in km, take sqrt and multiply result by EarthR*DegreeRad
In this library eps (distance) is adjusted so that we don't need to do sqrt and multiplication
func FastSine ¶
FastSine caclulates sinus approximated to parabola
Taken from: http://forum.devmaster.net/t/fast-and-accurate-sine-cosine/9648
Types ¶
type Cluster ¶
Cluster is a result of DBScan work
func DBScan ¶
DBScan clusters incoming points into clusters with params (eps, minPoints)
eps is clustering radius in km minPoints in minimum number of points in eps-neighbourhood (density)
func (*Cluster) CentroidAndBounds ¶
CentroidAndBounds calculates center and cluster bounds
type EpsFunction ¶
EpsFunction is a function that returns eps based on point pt
type KDTree ¶
KDTree is implementation of K-D Tree, with Points separated from nodes.
Nodes (T) hold only indices into Points slice