haversine_formula 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/haversine_formula.rb +14 -0
  2. metadata +46 -0
@@ -0,0 +1,14 @@
1
+ include Math
2
+
3
+ R = 6367.45 # radius of the Earth, in kilometers
4
+
5
+ def deg2rad(lat, lon) # converts degrees to radians
6
+ [lat * PI / 180, lon * PI / 180]
7
+ end
8
+
9
+ def distance(start_coords, end_coords)
10
+ lat1, lon1 = deg2rad *start_coords
11
+ lat2, lon2 = deg2rad *end_coords
12
+ 2 * R * asin(sqrt(sin((lat2-lat1)/2)**2 + cos(lat1) * cos(lat2) * sin((lon2 - lon1)/2)**2)) # Haversine formula
13
+ end
14
+
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: haversine_formula
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Charlie Redwood
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-09-03 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Gem for calculating the distance between 2 GPS coords
15
+ email: charlie.Redwood@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/haversine_formula.rb
21
+ homepage: http://rubygems.org/gems/haversine_formula
22
+ licenses:
23
+ - MIT
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 1.8.23
43
+ signing_key:
44
+ specification_version: 3
45
+ summary: Haversine formula gem
46
+ test_files: []