class GeoDistance::Spherical
Public Class Methods
distance(*args)
click to toggle source
# File lib/geo-distance/formula/spherical.rb, line 28 def self.distance *args from, to, units = get_points(args) return 0.0 if from == to #return 0.0 if points are have the same coordinates c = Math.acos( Math.sin(degrees_to_radians(from.lat)) * Math.sin(degrees_to_radians(to.lat)) + Math.cos(degrees_to_radians(from.lat)) * Math.cos(degrees_to_radians(to.lat)) * Math.cos(degrees_to_radians(to.lng) - degrees_to_radians(from.lng)) ).to_deg units ? c.radians_to(units) : c rescue Errno::EDOM 0.0 end