Sha256: de3965934572b5b2054c75db940aa5f17a82dc8356a29c2fc5a9e09e4c38ed9c

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

module GeoUnits
  module Converter
    module Units
      def degrees_to_radians(degrees)   
        degrees.to_f * GeoUnits::Constants.radians_per_degree
      end

      def units_sphere_multiplier(units)
        units = GeoUnits.key units
        GeoUnits::Mapsearth_radius_map[units]
      end

      def units_per_latitude_degree(units)
        units = GeoUnits.key units
        GeoUnits::Maps.radian_multiplier[units]
      end

      def pi_div_rad
        GeoUnits::Constants.pi_div_rad
      end

      def units_per_longitude_degree(lat, units)
        miles_per_longitude_degree = (lat * Math.cos(lat * pi_div_rad)).abs 
        units = GeoUnits.key units
        miles_per_longitude_degree.miles_to(units)
      end 
  
      def earth_radius units
        units = GeoUnits.key units
        GeoUnits::Maps.earth_radius_map[units]
      end
      
      def radians_ratio units
        units = GeoUnits.key units
        radians_per_degree * earth_radius(units)
      end
  
      extend self       
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
geo_units-0.3.3 lib/geo_units/converter/units.rb
geo_units-0.3.2 lib/geo_units/converter/units.rb
geo_units-0.3.1.1 lib/geo_units/converter/units.rb
geo_units-0.3.1 lib/geo_units/converter/units.rb