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

Instance Method Details

#is_between?(lower, upper) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/geo_units/numeric.rb', line 13

def is_between? lower, upper
  (lower..upper).cover? self
end

#to_degObject 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_latObject



5
6
7
# File 'lib/geo_units/numeric.rb', line 5

def to_lat
  normalize_lat
end

#to_lngObject



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)

Parameters:

  • precision: (Number)

    Number of significant digits to appear in the returned string



45
46
47
# File 'lib/geo_units/numeric.rb', line 45

def to_precision precision
  self.round(precision).to_s
end

#to_radObject 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