Example #1
0
func NewCoordNode(latitude, longitude float64, precision int) *CoordNode {
	ghash, _ := geohash.Encode(latitude, longitude, precision)
	return &CoordNode{
		Latitude:  latitude,
		Longitude: longitude,
		Geohash:   ghash,
	}
}
Example #2
0
func (this *Nearest) AddCoord(key string, latitude, longitude float64) {
	ghash, _ := geohash.Encode(latitude, longitude, this.precision)
	coordNode := &CoordNode{
		Latitude:  latitude,
		Longitude: longitude,
		Geohash:   ghash,
	}
	this.AddCoordNode(key, coordNode)
}
Example #3
0
func groupPoints(f *uatparse.UATFrame) map[string][]uatparse.GeoPoint {
	// Index all of the points by GeoHash. Group points together.
	res := make(map[string][]uatparse.GeoPoint)
	precision := 5 // 6 maybe, 0.000687.
	for _, p := range f.Points {
		hash, _ := geohash.Encode(p.Lat, p.Lon, precision)
		if r, ok := res[hash]; ok {
			r = append(r, p)
			res[hash] = r
		} else {
			res[hash] = []uatparse.GeoPoint{p}
		}
	}
	return res
}