Documentation
¶
Index ¶
- type CentroidDistance
- type CentroidGeoDistance
- type CentroidSquaredDistance
- type Cluster
- func ClusterClusters(clusters []*Cluster, distancer ClusterDistancer, threshold float64) []*Cluster
- func ClusterGeoClusters(clusters []*Cluster, threshold float64) []*Cluster
- func ClusterGeoPointers(pointers []geo.Pointer, threshold float64) []*Cluster
- func ClusterPointers(pointers []geo.Pointer, distancer ClusterDistancer, threshold float64) []*Cluster
- func NewCluster(pointers ...geo.Pointer) *Cluster
- func NewClusterWithCentroid(centroid *geo.Point, pointers ...geo.Pointer) *Cluster
- type ClusterDistancer
- type Combiner
- type Sortable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CentroidDistance ¶
type CentroidDistance struct{}
CentroidDistance implements the ClusterDistancer interface where the distance is just the euclidean distance between the cluster centroids.
func (CentroidDistance) ClusterDistance ¶
func (cd CentroidDistance) ClusterDistance(c1, c2 *Cluster) float64
ClusterDistance computes the distance between the cluster centroids.
type CentroidGeoDistance ¶
type CentroidGeoDistance struct{}
CentroidGeoDistance implements the ClusterDistancer interface where the distance is just the geo distance between the Group centroids. If possible, it is recommended to project the lat/lng points into a euclidean space and use CentroidSquaredDistance.
func (CentroidGeoDistance) ClusterDistance ¶
func (cgd CentroidGeoDistance) ClusterDistance(c1, c2 *Cluster) float64
ClusterDistance computes the geo distance between the cluster centroids.
type CentroidSquaredDistance ¶
type CentroidSquaredDistance struct{}
CentroidSquaredDistance implements the ClusterDistancer interface where the distance is just the squared euclidean distance between the cluster centroids. This distancer is recommended over CentroidDistance, just square the threshold.
func (CentroidSquaredDistance) ClusterDistance ¶
func (csd CentroidSquaredDistance) ClusterDistance(c1, c2 *Cluster) float64
ClusterDistance computes the squared euclidean distance between the cluster centroids.
type Cluster ¶
type Cluster struct { Centroid *geo.Point Pointers []geo.Pointer }
A Cluster is a cluster of pointers plus their centroid. It defines a center/centroid for easy centroid distance computation.
func ClusterClusters ¶
func ClusterClusters(clusters []*Cluster, distancer ClusterDistancer, threshold float64) []*Cluster
ClusterClusters can be used if you've already created cluster objects using a prefilterer of something else. Original clusters will be copied so the original set will be unchanged.
func ClusterGeoClusters ¶
ClusterGeoClusters can be used if you've already created clusters objects using a prefilterer of something else.
func ClusterGeoPointers ¶
ClusterGeoPointers will take a set of Pointers and cluster them. It will project the points using mercator, scale the threshold, cluster, and project back. Performace is about 40% than simply using a geo distancer. This may not make sense for all geo datasets.
func ClusterPointers ¶
func ClusterPointers(pointers []geo.Pointer, distancer ClusterDistancer, threshold float64) []*Cluster
ClusterPointers will take a set of Pointers and cluster them using the distancer and threshold.
func NewCluster ¶
func NewCluster(pointers ...geo.Pointer) *Cluster
NewCluster creates the point cluster and finds the center of the given pointers.
func NewClusterWithCentroid ¶
func NewClusterWithCentroid(centroid *geo.Point, pointers ...geo.Pointer) *Cluster
NewClusterWithCentroid creates a point cluster stub from the given centroid and optional pointers.
type ClusterDistancer ¶
A ClusterDistancer defines the how to compute the distance between point clusters.
type Combiner ¶
A Combiner is something that can be combined.
func ClusterCombiners ¶
ClusterCombiners will do a simple hierarchical of the combiners. It will modify the input slice as things will be combined into each other.
type Sortable ¶
type Sortable []*Cluster
Sortable implements the sorting interface allowing for sorting.
func (Sortable) Len ¶
Len returns the length of the sortable cluster. This is to implement the sort interface.
func (Sortable) Less ¶
Less returns truee if i > j, so bigger will be first. This is to implement the sort interface.