Sha256: 5fd2b09be64aab24c7a48c6bf95a17705826e1158243a984df3ebd62f10f76cf

Contents?: true

Size: 903 Bytes

Versions: 7

Compression:

Stored size: 903 Bytes

Contents

module GeoUnits
  module UnitConversions
    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 units_per_longitude_degree(lat, units)
      miles_per_longitude_degree = (latitude_degrees * 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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
geo_units-0.3.4 lib/geo_units/unit_conversions.rb
geo_units-0.3.3 lib/geo_units/unit_conversions.rb
geo_units-0.3.2 lib/geo_units/unit_conversions.rb
geo_units-0.3.1.1 lib/geo_units/unit_conversions.rb
geo_units-0.3.1 lib/geo_units/unit_conversions.rb
geo_units-0.2.6 lib/geo_units/unit_conversions.rb
geo_units-0.2.5 lib/geo_units/unit_conversions.rb