removing piBy180 from critical path
@@ -88,6 +88,8 @@ func hsin(theta float64) float64 {
return math.Pow(math.Sin(theta/2), 2)
}
+var piBy180 = math.Pi / 180
+
// Haversine Distance Formula
// http://en.wikipedia.org/wiki/Haversine_formula
// from https://gist.github.com/cdipaolo/d3f8db3848278b49db68
@@ -95,10 +97,10 @@ func distanceBetween(lat1, lon1, lat2, lon2 float64) float64 {
// convert to radians
// must cast radius as float to multiply later
var la1, lo1, la2, lo2, r float64
- la1 = lat1 * math.Pi / 180
- lo1 = lon1 * math.Pi / 180
- la2 = lat2 * math.Pi / 180
- lo2 = lon2 * math.Pi / 180
+ la1 = lat1 * piBy180
+ lo1 = lon1 * piBy180
+ la2 = lat2 * piBy180
+ lo2 = lon2 * piBy180
r = 6378100 // Earth radius in METERS
