This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am scaraveos on github. | |
* I am scaraveos (https://keybase.io/scaraveos) on keybase. | |
* I have a public key whose fingerprint is B854 018E 7C5C C6EB 393F E19F D07F 0280 53AA 7543 | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculates distance in meters between 2 GPS coordinates | |
# Ported to Ruby from the Android SDK source | |
# Original paper explaning the process: http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf | |
# Arguments p1, p2 are instances of the class Point below: | |
# class Point | |
# attr_accessor :lat, :lon | |
# end | |
def android_distance_port(p1, p2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculates the distance in meters between 2 GPS coordinates | |
# http://en.wikipedia.org/wiki/Haversine_formula | |
# Arguments p1, p2 are instances of the class Point below: | |
# class Point | |
# attr_accessor :lat, :lon | |
# end | |
def haversine_distance(p1, p2) | |
lat1 = p1.lat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Enter latitude in decimal degrees:" | |
lat_deg = gets.to_f | |
puts "Enter longitude in decimal degrees:" | |
lon_deg = gets.to_f | |
lon_rad = (lon_deg / 180.0 * Math::PI) | |
lat_rad = (lat_deg / 180.0 * Math::PI) | |
sm_a = 6378137.0 | |
x = sm_a * lon_rad | |
y = sm_a * Math.log((Math.sin(lat_rad) + 1) / Math.cos(lat_rad)) |