// GreatCircleDistance calculates the Haversine distance between two points.
// Used to verify distance-based search.
// https://github.com/kellydunn/golang-geo/blob/master/point.go
GreatCircleDistance calculates the Haversine distance between two points.
Used to verify distance-based search.
// GreatCircleDistance calculates the Haversine distance between two points . // Used to verify distance - based search . // https : // github . com / kellydunn / golang - geo / blob / master / point . go
func (p *Point) GreatCircleDistance(p2 *Point) float64 {
	dLat := (p2.Lat - p.Lat) * (math.Pi / 180.0)
	dLon := (p2.Lng - p.Lng) * (math.Pi / 180.0)
	lat1 := p.Lat * (math.Pi / 180.0)
	lat2 := p2.Lat * (math.Pi / 180.0)
	a1 := math.Sin(dLat/2) * math.Sin(dLat/2)
	a2 := math.Sin(dLon/2) * math.Sin(dLon/2) * math.Cos(lat1) * math.Cos(lat2)
	a := a1 + a2
	c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
	return EARTH_RADIUS * c
}
func ( p * Point ) GreatCircleDistance ( p2 * Point ) float64 { dLat := ( p2 . Lat - p . Lat ) * ( math . Pi / 180.0 ) dLon := ( p2 . Lng - p . Lng ) * ( math . Pi / 180.0 ) lat1 := p . Lat * ( math . Pi / 180.0 ) lat2 := p2 . Lat * ( math . Pi / 180.0 ) a1 := math . Sin ( dLat / 2 ) * math . Sin ( dLat / 2 ) a2 := math . Sin ( dLon / 2 ) * math . Sin ( dLon / 2 ) * math . Cos ( lat1 ) * math . Cos ( lat2 ) a := a1 + a2 c := 2 * math . Atan2 ( math . Sqrt ( a ) , math . Sqrt ( 1 - a ) ) return EARTH_RADIUS * c }
GreatCircleDistance calculates the Haversine distance between two points.
GreatCircleDistance calculates the Haversine distance between two points .