Class: GeoDistance::Spherical
- Inherits:
-
DistanceFormula
- Object
- DistanceFormula
- GeoDistance::Spherical
- Defined in:
- lib/geo-distance/spherical.rb
Class Method Summary collapse
Methods inherited from DistanceFormula
Constructor Details
This class inherits a constructor from GeoDistance::DistanceFormula
Class Method Details
.distance(lat1, lon1, lat2, lon2) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/geo-distance/spherical.rb', line 6 def self.distance( lat1, lon1, lat2, lon2) from_longitude = lon1.to_radians from_latitude = lat1.to_radians to_longitude = lon2.to_radians to_latitude = lat2.to_radians c = Math.acos( Math.sin(from_latitude) * Math.sin(to_latitude) + Math.cos(from_latitude) * Math.cos(to_latitude) * Math.cos(to_longitude - from_longitude) ) #* EARTH_RADIUS[units.to_sym] GeoDistance::Distance.new c end |