haversine_distance 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 33a5cc7a9b2f8a1c5abeb5fd1bbad6fc24a2d223
4
+ data.tar.gz: 8dc6953cf85c7fadcedb3be063e29ac2420a696b
5
+ SHA512:
6
+ metadata.gz: 5f4e8d0bce55daca260f3d7cd09fd16bead882cf63dcd783ecdb2bd44ed4be0a6bd8b528c296290bd8c7786d307f7d177f6534c9e841227d1c5ae04ed118af45
7
+ data.tar.gz: a170d9898c2be030493f3368262729103f14f73883e9d3b2bd14f867d6bed42340d82d2a67173e1a5e434e4083544a5d403e9d7a45fdd24ac5eae6c8be01798f
data/README CHANGED
@@ -14,7 +14,7 @@ You can totally install it as a Gem
14
14
 
15
15
  Haversine is readily available as a Ruby gem.
16
16
 
17
- $ [sudo] gem install haversine
17
+ $ [sudo] gem install haversine_distance
18
18
 
19
19
  The Haversine source is available at GitHub:
20
20
 
data/README.markdown CHANGED
@@ -14,7 +14,7 @@ You can totally install it as a Gem
14
14
 
15
15
  Haversine is readily available as a Ruby gem.
16
16
 
17
- $ [sudo] gem install haversine
17
+ $ [sudo] gem install haversine_distance
18
18
 
19
19
  The Haversine source is available at GitHub:
20
20
 
data/haversine.gemspec CHANGED
@@ -7,9 +7,9 @@ Gem::Specification.new do |s|
7
7
  s.version = Haversine::VERSION
8
8
  s.authors = ["Jirapong Nanta"]
9
9
  s.email = ["jirapong.nanta@gmail.com"]
10
- s.homepage = "https://github.com/Jirapong/Haversine"
10
+ s.homepage = "https://github.com/jirapong/haversine_distance"
11
11
  s.summary = "Haversine is a formula to calculate the great-circle distance between two points"
12
- s.description = "Because Earth is not flat!"
12
+ s.description = "Because Earth is not flat! km_distance = Haversine.distance(lat_a, lng_a, lat_b, lng_b)"
13
13
 
14
14
  s.rubyforge_project = "haversine"
15
15
 
data/lib/haversine.rb CHANGED
@@ -12,6 +12,15 @@ class Float
12
12
  end
13
13
  end
14
14
 
15
+ class Fixnum
16
+ RADIAN_PER_DEGREE = Math::PI / 180.0
17
+
18
+ def toRad
19
+ return self * RADIAN_PER_DEGREE
20
+ end
21
+ end
22
+
23
+
15
24
  module Haversine
16
25
  EARTH_RADIUS_MI = 3963.19
17
26
  EARTH_RADIUS_KM = 6371.00
@@ -1,3 +1,3 @@
1
1
  module Haversine
2
- VERSION = "0.9.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -11,8 +11,8 @@ class HaversineTest < Test::Unit::TestCase
11
11
  lat_b = 49.008
12
12
  lng_b = 2.549
13
13
 
14
- km = Haversine.distance(lat_a, lng_a, lat_b, lng_b);
15
- assert_equal(359.3823602146921, km);
14
+ km = Haversine.distance(lat_a, lng_a, lat_b, lng_b)
15
+ assert_equal(359.3823602146921, km)
16
16
  end
17
17
 
18
18
  def test_distance_in_mi
@@ -22,8 +22,52 @@ class HaversineTest < Test::Unit::TestCase
22
22
  lat_b = 49.008
23
23
  lng_b = 2.549
24
24
 
25
- mi = Haversine.distance_in_mile(lat_a, lng_a, lat_b, lng_b);
26
- assert_equal(223.5599711472713, mi);
25
+ mi = Haversine.distance_in_mile(lat_a, lng_a, lat_b, lng_b)
26
+ assert_equal(223.5599711472713, mi)
27
+ end
28
+
29
+ def test_distance_float_in_km
30
+ lat_a = 51.0
31
+ lng_a = 0.235
32
+
33
+ lat_b = 49
34
+ lng_b = 2.549
35
+
36
+ km = Haversine.distance(lat_a, lng_a, lat_b, lng_b)
37
+ assert_equal(277.11934670861064, km)
38
+ end
39
+
40
+ def test_distance_float_in_mi
41
+ lat_a = 51.0
42
+ lng_a = 0.235
43
+
44
+ lat_b = 49.0
45
+ lng_b = 2.549
46
+
47
+ mi = Haversine.distance_in_mile(lat_a, lng_a, lat_b, lng_b)
48
+ assert_equal(172.38685036604906, mi)
49
+ end
50
+
51
+ def test_distance_integer_in_km
52
+ lat_a = 51
53
+ lng_a = 0.235
54
+
55
+ lat_b = 49
56
+ lng_b = 2.549
57
+
58
+ km = Haversine.distance(lat_a, lng_a, lat_b, lng_b)
59
+ assert_equal(277.11934670861064, km)
60
+ end
61
+
62
+ def test_distance_integer_in_mi
63
+ lat_a = 51
64
+ lng_a = 0.235
65
+
66
+ lat_b = 49
67
+ lng_b = 2.549
68
+
69
+ mi = Haversine.distance_in_mile(lat_a, lng_a, lat_b, lng_b)
70
+ assert_equal(172.38685036604906, mi)
27
71
  end
28
72
 
29
73
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haversine_distance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jirapong Nanta
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-12-03 00:00:00.000000000 Z
11
+ date: 2014-07-22 00:00:00.000000000 Z
13
12
  dependencies: []
14
- description: Because Earth is not flat!
13
+ description: Because Earth is not flat! km_distance = Haversine.distance(lat_a, lng_a,
14
+ lat_b, lng_b)
15
15
  email:
16
16
  - jirapong.nanta@gmail.com
17
17
  executables: []
@@ -27,29 +27,28 @@ files:
27
27
  - lib/haversine.rb
28
28
  - lib/haversine/version.rb
29
29
  - test/test_haversine.rb
30
- homepage: https://github.com/Jirapong/Haversine
30
+ homepage: https://github.com/jirapong/haversine_distance
31
31
  licenses: []
32
+ metadata: {}
32
33
  post_install_message:
33
34
  rdoc_options: []
34
35
  require_paths:
35
36
  - lib
36
37
  required_ruby_version: !ruby/object:Gem::Requirement
37
- none: false
38
38
  requirements:
39
- - - ! '>='
39
+ - - '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  required_rubygems_version: !ruby/object:Gem::Requirement
43
- none: false
44
43
  requirements:
45
- - - ! '>='
44
+ - - '>='
46
45
  - !ruby/object:Gem::Version
47
46
  version: '0'
48
47
  requirements: []
49
48
  rubyforge_project: haversine
50
- rubygems_version: 1.8.10
49
+ rubygems_version: 2.0.14
51
50
  signing_key:
52
- specification_version: 3
51
+ specification_version: 4
53
52
  summary: Haversine is a formula to calculate the great-circle distance between two
54
53
  points
55
54
  test_files: