diff --git a/lib/geocoder.rb b/lib/geocoder.rb index cc9d64bc709f432197abb34564f074d1dbe82aa1..bf0b1f4a9a12974a16eef2099244265cfb21ff0a 100644 --- a/lib/geocoder.rb +++ b/lib/geocoder.rb @@ -2,6 +2,7 @@ # Add geocoding functionality (via Google) to any object. # module Geocoder + include Math ## # Implementation of 'included' hook method. @@ -207,9 +208,9 @@ module Geocoder dlat = (lat1 - lat2).abs dlon = (lon1 - lon2).abs - a = (Math.sin(dlat / 2))**2 + Math.cos(lat1) * - (Math.sin(dlon / 2))**2 * Math.cos(lat2) - c = 2 * Math.atan2( Math.sqrt(a), Math.sqrt(1-a)) + a = (sin(dlat / 2))**2 + cos(lat1) * + (sin(dlon / 2))**2 * cos(lat2) + c = 2 * atan2( sqrt(a), sqrt(1-a)) c * units[options[:units]] end @@ -217,7 +218,7 @@ module Geocoder # Convert degrees to radians. # def self.to_radians(degrees) - degrees * (Math::PI / 180) + degrees * (PI / 180) end ##