Module: Fdc::GeoLocation
- Defined in:
- lib/fdc/utilities.rb
Overview
Helper functions for geocoordinate conversion
Class Method Summary collapse
-
.to_dec(long, lat) ⇒ Float
Convert geocoordinates from mindec notation of IGC to dec notation.
Class Method Details
.to_dec(long, lat) ⇒ Float
Convert geocoordinates from mindec notation of IGC to dec notation
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fdc/utilities.rb', line 17 def GeoLocation.to_dec(long, lat) long_m = long.match(/^(\d{3})((\d{2})(\d{3}))(E|W)/) lat_m = lat.match(/^(\d{2})((\d{2})(\d{3}))(N|S)/) # Convert minutes to decimal long_dec = long_m[1].to_f + (long_m[2].to_f / 1000 / 60) lat_dec = lat_m[1].to_f + (lat_m[2].to_f / 1000 / 60) # Change signs according to direction long_dec *= (-1) if long_m[5] == "W" lat_dec *= (-1) if lat_m[5] == "S" return long_dec, lat_dec end |