Module: GeoUnits::Numeric
- Included in:
- Numeric
- Defined in:
- lib/geo_units/numeric.rb,
lib/geo_units/numeric/dms.rb,
lib/geo_units/numeric/normalizer.rb
Defined Under Namespace
Modules: Dms, Normalizer
Instance Method Summary collapse
- #is_between?(lower, upper) ⇒ Boolean
-
#to_deg ⇒ Object
(also: #to_degrees, #as_deg, #as_degrees, #in_deg, #in_degrees)
Converts radians to numeric (signed) degrees latitude (north to south) from equator 90 up then -90 down (equator again) = 180 then 180 for south = 360 total longitude (west to east) east 180, west -180 = 360 total.
- #to_lat ⇒ Object
- #to_lng ⇒ Object
-
#to_precision(precision) ⇒ Object
(also: #to_fixed)
Formats the significant digits of a number, using only fixed-point notation (no exponential).
-
#to_rad ⇒ Object
(also: #to_radians, #as_rad, #as_radians, #in_rad, #in_radians)
Converts numeric degrees to radians.
Instance Method Details
#is_between?(lower, upper) ⇒ Boolean
13 14 15 |
# File 'lib/geo_units/numeric.rb', line 13 def is_between? lower, upper (lower..upper).cover? self end |
#to_deg ⇒ Object Also known as: to_degrees, as_deg, as_degrees, in_deg, in_degrees
Converts radians to numeric (signed) degrees latitude (north to south) from equator 90 up then -90 down (equator again) = 180 then 180 for south = 360 total longitude (west to east) east 180, west -180 = 360 total
31 32 33 |
# File 'lib/geo_units/numeric.rb', line 31 def to_deg self * 180 / Math::PI end |
#to_lat ⇒ Object
5 6 7 |
# File 'lib/geo_units/numeric.rb', line 5 def to_lat normalize_lat end |
#to_lng ⇒ Object
9 10 11 |
# File 'lib/geo_units/numeric.rb', line 9 def to_lng normalize_lng end |
#to_precision(precision) ⇒ Object Also known as: to_fixed
Formats the significant digits of a number, using only fixed-point notation (no exponential)
45 46 47 |
# File 'lib/geo_units/numeric.rb', line 45 def to_precision precision self.round(precision).to_s end |
#to_rad ⇒ Object Also known as: to_radians, as_rad, as_radians, in_rad, in_radians
Converts numeric degrees to radians
18 19 20 |
# File 'lib/geo_units/numeric.rb', line 18 def to_rad self * Math::PI / 180 end |