gis-distance 1.0.2 → 1.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ada8cb52ba2e522d5315e73c94a72b9c766b53bd24e37d72448ffdaed26abdc
4
- data.tar.gz: 1cd738a5fed67d46ffe50358d3a72db781fe2d5f17e73e0cece9b6244d7f0127
3
+ metadata.gz: afa5f1131b787db92e5e13a3992c471e8381167b926dc942eea37a398a8dc01a
4
+ data.tar.gz: 60996c27a828f65302c80afc8e15ae3bfc327b7f49a4283fa130a6fd6e476492
5
5
  SHA512:
6
- metadata.gz: 7b34a028b93f9d24d25c5d6bfb3a154e2948ad4f9e2862c485abfb5fb62ba490e342f8d830735c198ee0fc211519e882bea031ea2c000c7a933eae1d89dca8ef
7
- data.tar.gz: d49169c3d2f9e433a17d082259ffa5cabe52ed4f63a8d92be13ce29f3906148d55f3cfc02c8646a645f98fb012f14ea7967db9c0c4890110e8ea8c46fce940b3
6
+ metadata.gz: f2ab85690778cb6b8c2a70b28f473b7fbdc5ec088ccdbc97282cfc0a47c0719ad2fd80f294d8b6eff8ff6d34ab38edfa3df54864cc1194ba9a53371c820dddae
7
+ data.tar.gz: 26dd4b737786902955c447fe6e7537116786be6c57ecada17bbe8151f59ee767230699b767f45242f5fe08320983eb1fa182d3cf3a2d7b27e55d9a2e99f5a9d2
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md ADDED
@@ -0,0 +1,24 @@
1
+ ## 1.2.0 - 3-Oct-2024
2
+ * Added support for the vicenty formula, and the rvicenty gem is now a
3
+ runtime dependency.
4
+ * Dropped Ruby 2.x from the github test matrix. It will still work with
5
+ older versions of Ruby, however.
6
+ * Some minor updates to the README.md.
7
+
8
+ ## 1.1.0 - 27-Feb-2021
9
+ * Switched from test-unit to rspec.
10
+ * Added a Gemfile.
11
+
12
+ ## 1.0.2 - 22-Mar-2018
13
+ * Added 'cosines' as a supported formula. This will use the Law of cosines
14
+ to calculate the distance.
15
+ * Added metadata to the gemspec.
16
+ * Added a cert.
17
+ * Rakefile now assumes Rubygems 2.x, and other minor updates.
18
+ * Added a gis-distance.rb file for convenience.
19
+
20
+ ## 1.0.1 - 26-Oct-2014
21
+ * Updated gemspec, Rakefile.
22
+
23
+ ## 1.0.0 - 10-Oct-2009
24
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -1,6 +1,7 @@
1
- * CHANGES
2
- * MANIFEST
3
- * README
1
+ * CHANGES.md
2
+ * MANIFEST.md
3
+ * README.md
4
+ * Gemfile
4
5
  * Rakefile
5
6
  * gis-distance.gemspec
6
7
  * lib/gis-distance.rb
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ [![Ruby](https://github.com/djberg96/gis-distance/actions/workflows/ruby.yml/badge.svg)](https://github.com/djberg96/gis-distance/actions/workflows/ruby.yml)
2
+
3
+ ## Description
4
+ The gis-distance library allows you to calculate geographic distance between
5
+ two points using the formula of your choice.
6
+
7
+ ## Installation
8
+ `gem install gis-distance`
9
+
10
+ ## Adding the trusted cert
11
+ `gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/gis-distance/main/certs/djberg96_pub.pem)`
12
+
13
+ ## Synopsis
14
+ ```ruby
15
+ require 'gis/distance' # or 'gis-distance'
16
+
17
+ # New York to Los Angeles
18
+ gis = GIS::Distance.new(40.47, 73.58, 34.3, 118.15)
19
+
20
+ # Set the formula of your choice
21
+ gis.formula = 'cosines'
22
+ gis.formula = 'haversine'
23
+ gis.formula = 'vincenty'
24
+
25
+ p gis.distance # Kilometers
26
+ p gis.distance.mi # Miles
27
+ ```
28
+
29
+ ## Available Formulas
30
+ * haversine (https://en.wikipedia.org/wiki/Haversine_formula)
31
+ * cosine (https://en.wikipedia.org/wiki/Law_of_cosines)
32
+ * vincenty (https://en.wikipedia.org/wiki/Vincenty%27s_formulae)
33
+
34
+ ## See Also
35
+ http://en.wikipedia.org/wiki/Earth_radius
36
+
37
+ ## Miscellaneous
38
+ Ruby 2.x was dropped from the test matrix as of version 1.2 because of
39
+ incompatibility with bundler. This library should still work fine with
40
+ older versions of Ruby, but you should strongly consider upgrading at this
41
+ point since Ruby 2.x is now EOL.
42
+
43
+ ## License
44
+ Artistic-2.0
45
+
46
+ ## Authors
47
+ * Daniel Berger
48
+ * Ardith Falkner
data/Rakefile CHANGED
@@ -1,18 +1,18 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
- require 'rake/testtask'
4
3
  require 'rbconfig'
5
- include RbConfig
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
6
6
 
7
- CLEAN.include('**/*.gem', '**/*.log')
7
+ CLEAN.include('**/*.gem', '**/*.log', '**/*.lock')
8
8
 
9
9
  namespace 'gem' do
10
10
  desc 'Create the gis-distance gem'
11
11
  task :create => [:clean] do
12
12
  require 'rubygems/package'
13
- spec = eval(IO.read('gis-distance.gemspec'))
13
+ spec = Gem::Specification.load('gis-distance.gemspec')
14
14
  spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
15
- Gem::Package.build(spec, true)
15
+ Gem::Package.build(spec)
16
16
  end
17
17
 
18
18
  desc 'Install the gis-distance gem'
@@ -22,9 +22,14 @@ namespace 'gem' do
22
22
  end
23
23
  end
24
24
 
25
- Rake::TestTask.new do |t|
26
- t.warning = true
27
- t.verbose = true
25
+ RuboCop::RakeTask.new
26
+
27
+ desc "Run the test suite"
28
+ RSpec::Core::RakeTask.new(:spec)
29
+
30
+ # Clean up afterwards
31
+ Rake::Task[:spec].enhance do
32
+ Rake::Task[:clean].invoke
28
33
  end
29
34
 
30
- task :default => :test
35
+ task :default => :spec
data/gis-distance.gemspec CHANGED
@@ -2,25 +2,30 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'gis-distance'
5
- spec.version = '1.0.2'
5
+ spec.version = '1.2.0'
6
6
  spec.authors = ['Daniel J. Berger', 'Ardith Falkner']
7
- spec.license = 'Artistic 2.0'
7
+ spec.license = 'Artistic-2.0'
8
8
  spec.description = 'Calculate the distance between two points on Earth'
9
9
  spec.email = 'djberg96@gmail.com'
10
10
  spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
11
- spec.test_files = ['test/test_gis_distance.rb']
11
+ spec.test_files = Dir['spec/*_spec.rb']
12
12
  spec.homepage = 'http://github.com/djberg96/gis-distance'
13
13
  spec.cert_chain = ['certs/djberg96_pub.pem']
14
14
 
15
- spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
15
+ spec.add_dependency('rvincenty', '~> 0.1.0')
16
+ spec.add_development_dependency('rake')
17
+ spec.add_development_dependency('rspec', '~> 3.9')
18
+ spec.add_development_dependency('rubocop')
19
+ spec.add_development_dependency('rubocop-rspec')
16
20
 
17
21
  spec.metadata = {
18
- 'homepage_uri' => 'https://github.com/djberg96/gis-distance',
19
- 'bug_tracker_uri' => 'https://github.com/djberg96/gis-distance/issues',
20
- 'changelog_uri' => 'https://github.com/djberg96/gis-distance/blob/master/CHANGES',
21
- 'documentation_uri' => 'https://github.com/djberg96/gis-distance/wiki',
22
- 'source_code_uri' => 'https://github.com/djberg96/gis-distance',
23
- 'wiki_uri' => 'https://github.com/djberg96/gis-distance/wiki'
22
+ 'homepage_uri' => 'https://github.com/djberg96/gis-distance',
23
+ 'bug_tracker_uri' => 'https://github.com/djberg96/gis-distance/issues',
24
+ 'changelog_uri' => 'https://github.com/djberg96/gis-distance/blob/main/CHANGES.md',
25
+ 'documentation_uri' => 'https://github.com/djberg96/gis-distance/wiki',
26
+ 'source_code_uri' => 'https://github.com/djberg96/gis-distance',
27
+ 'wiki_uri' => 'https://github.com/djberg96/gis-distance/wiki',
28
+ 'rubygems_mfa_required' => 'true'
24
29
  }
25
30
 
26
31
  spec.summary = <<-EOF
data/lib/gis/distance.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The GIS module serves as a namespace only.
2
4
  module GIS
3
5
  # The Distance class encapsulates methods related to geographic distance.
@@ -6,7 +8,7 @@ module GIS
6
8
  class Error < StandardError; end
7
9
 
8
10
  # The version of the gis-distance library
9
- VERSION = '1.0.2'.freeze
11
+ VERSION = '1.2.0'
10
12
 
11
13
  # Create a new GIS::Distance object using the two sets of coordinates
12
14
  # that are provided.
@@ -28,9 +30,7 @@ module GIS
28
30
 
29
31
  # Returns the radius of the Earth in kilometers. The default is 6367.45.
30
32
  #
31
- def radius
32
- @radius
33
- end
33
+ attr_reader :radius
34
34
 
35
35
  # Sets the radius of the Earth in kilometers. This is variable because
36
36
  # the Earth is not perfectly spherical, and you may wish to adjust it.
@@ -44,9 +44,7 @@ module GIS
44
44
  # See http://en.wikipedia.org/wiki/Earth_radius for more information.
45
45
  #
46
46
  def radius=(kms)
47
- if kms < 6357.0 || kms > 6378.0
48
- raise Error, "Proposed radius '#{kms}' is out of range"
49
- end
47
+ raise Error, "Proposed radius '#{kms}' is out of range" if kms < 6357.0 || kms > 6378.0
50
48
  @radius = kms
51
49
  end
52
50
 
@@ -54,9 +52,7 @@ module GIS
54
52
  # is 'haversine'.
55
53
  #--
56
54
  # See http://en.wikipedia.org/wiki/Haversine_formula for details.
57
- def formula
58
- @formula
59
- end
55
+ attr_reader :formula
60
56
 
61
57
  # Sets the formula to be used internally for calculating the distance.
62
58
  # The default is 'haversine'. Your other option is 'cosines' (i.e. the
@@ -66,12 +62,14 @@ module GIS
66
62
  #
67
63
  def formula=(formula)
68
64
  case formula.to_s.downcase
69
- when 'haversine'
70
- @formula = 'haversine'
71
- when 'cosines'
72
- @formula = 'cosines'
73
- else
74
- raise Error, "Formula '#{formula}' not supported"
65
+ when 'haversine'
66
+ @formula = 'haversine'
67
+ when 'cosines'
68
+ @formula = 'cosines'
69
+ when 'vincenty'
70
+ @formula = 'vincenty'
71
+ else
72
+ raise Error, "Formula '#{formula}' not supported"
75
73
  end
76
74
  end
77
75
 
@@ -80,12 +78,14 @@ module GIS
80
78
  #
81
79
  def distance
82
80
  @distance =
83
- case @formula.to_s.downcase
84
- when 'haversine'
85
- haversine_formula
86
- when 'cosines'
87
- law_of_cosines_formula
88
- end
81
+ case @formula.to_s.downcase
82
+ when 'haversine'
83
+ haversine_formula
84
+ when 'cosines'
85
+ law_of_cosines_formula
86
+ when 'vincenty'
87
+ vincenty_formula
88
+ end
89
89
  end
90
90
 
91
91
  private
@@ -94,19 +94,19 @@ module GIS
94
94
  # 90.0 and -90.0 while longitudes must be between 180.0 and -180.0.
95
95
  #
96
96
  def validate(lat1, lon1, lat2, lon2)
97
- [lat1, lat2].each{ |lat|
97
+ [lat1, lat2].each do |lat|
98
98
  if lat > 90 || lat < -90
99
99
  msg = "Latitude '#{lat}' is invalid - must be between -90 and 90"
100
100
  raise Error, msg
101
101
  end
102
- }
102
+ end
103
103
 
104
- [lon1, lon2].each{ |lon|
104
+ [lon1, lon2].each do |lon|
105
105
  if lon > 180 || lon < -180
106
106
  msg = "Longitude '#{lon}' is invalid - must be between -180 and 180"
107
107
  raise Error, msg
108
108
  end
109
- }
109
+ end
110
110
  end
111
111
 
112
112
  # See https://en.wikipedia.org/wiki/Law_of_cosines
@@ -116,9 +116,9 @@ module GIS
116
116
  sin2 = Math.sin(@latitude2 * Math::PI / 180)
117
117
  cos1 = Math.cos(@latitude1 * Math::PI / 180)
118
118
  cos2 = Math.cos(@latitude2 * Math::PI / 180)
119
- cos3 = Math.cos(@longitude2 * Math::PI / 180 - @longitude1 * Math::PI / 180)
119
+ cos3 = Math.cos((@longitude2 * Math::PI / 180) - (@longitude1 * Math::PI / 180))
120
120
 
121
- Math.acos(sin1 * sin2 + cos1 * cos2 * cos3) * radius
121
+ Math.acos((sin1 * sin2) + (cos1 * cos2 * cos3)) * radius
122
122
  end
123
123
 
124
124
  # See http://en.wikipedia.org/wiki/Haversine_formula
@@ -132,15 +132,21 @@ module GIS
132
132
  dlat = lat2 - lat1
133
133
  dlon = lon2 - lon1
134
134
 
135
- a = ((Math.sin(dlat/2))**2) + (Math.cos(lat1) * Math.cos(lat2) * (Math.sin(dlon/2)) ** 2)
136
- c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a))
135
+ a = (Math.sin(dlat / 2)**2) + (Math.cos(lat1) * Math.cos(lat2) * (Math.sin(dlon / 2)**2))
136
+ c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
137
137
 
138
138
  radius * c
139
139
  end
140
140
 
141
+ # See https://en.wikipedia.org/wiki/Vincenty's_formulae
142
+ def vincenty_formula
143
+ require 'rvincenty'
144
+ RVincenty.distance([@latitude1, @longitude1], [@latitude2, @longitude2]) / 1000.0
145
+ end
146
+
141
147
  # Add a custom method to the base Float class if it isn't already defined.
142
148
  class ::Float
143
- unless self.respond_to?(:mi)
149
+ unless respond_to?(:mi)
144
150
  # Convert miles to kilometers.
145
151
  def mi
146
152
  self * 0.621371192
data/lib/gis-distance.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'gis/distance'
@@ -0,0 +1,124 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspec'
4
+ require 'gis/distance'
5
+
6
+ RSpec.describe GIS::Distance do
7
+ let(:gis){ described_class.new(40.47, 73.58, 34.3, 118.15) }
8
+
9
+ example 'version' do
10
+ expect(GIS::Distance::VERSION).to eq('1.2.0')
11
+ expect(GIS::Distance::VERSION).to be_frozen
12
+ end
13
+
14
+ example 'distance basic functionality' do
15
+ expect(gis).to respond_to(:distance)
16
+ expect{ gis.distance }.not_to raise_error
17
+ expect(gis.distance).to be_a(Float)
18
+ end
19
+
20
+ context 'haversine' do
21
+ before do
22
+ gis.formula = 'haversine'
23
+ end
24
+
25
+ example 'distance method returns expected result' do
26
+ expect(gis.distance).to be_within(0.01).of(3952.39)
27
+ expect(described_class.new(40.47, 73.58, 40.47, 73.58).distance).to eq(0.0)
28
+ end
29
+ end
30
+
31
+ context 'cosines' do
32
+ before do
33
+ gis.formula = 'cosines'
34
+ end
35
+
36
+ example 'distance method returns expected result' do
37
+ expect(gis.distance).to be_within(0.01).of(3952.39)
38
+ expect(described_class.new(40.47, 73.58, 40.47, 73.58).distance).to eq(0.0)
39
+ end
40
+ end
41
+
42
+ context 'vincenty' do
43
+ before do
44
+ gis.formula = 'vincenty'
45
+ end
46
+
47
+ example 'distance method returns expected result' do
48
+ expect(gis.distance).to be_within(0.01).of(3963.40)
49
+ expect(described_class.new(40.47, 73.58, 40.47, 73.58).distance).to eq(0.0)
50
+ end
51
+ end
52
+
53
+ example 'constructor requires four arguments' do
54
+ expect{ described_class.new }.to raise_error(ArgumentError)
55
+ expect{ described_class.new(40.47) }.to raise_error(ArgumentError)
56
+ expect{ described_class.new(40.47, 73.58) }.to raise_error(ArgumentError)
57
+ expect{ described_class.new(40.47, 73.58, 34.3) }.to raise_error(ArgumentError)
58
+ end
59
+
60
+ example 'latitude and longitude must be within range' do
61
+ expect{ described_class.new(91.0, 100.0, 45.0, 45.0) }.to raise_error(GIS::Distance::Error)
62
+ expect{ described_class.new(90.0, 190.0, 45.0, 45.0) }.to raise_error(GIS::Distance::Error)
63
+ end
64
+
65
+ example 'radius basic functionality' do
66
+ expect(gis).to respond_to(:radius)
67
+ expect{ gis.radius }.not_to raise_error
68
+ expect(gis.radius).to be_a(Float)
69
+ end
70
+
71
+ example 'default radius returns expected value' do
72
+ expect(gis.radius).to eq(6367.45)
73
+ end
74
+
75
+ example 'radius does not accept an argument' do
76
+ expect{ gis.radius(1) }.to raise_error(ArgumentError)
77
+ end
78
+
79
+ example 'radius setter basic functionality' do
80
+ expect(gis).to respond_to(:radius=)
81
+ expect{ gis.radius = 6368.0 }.not_to raise_error
82
+ expect(gis.radius).to eq(6368.0)
83
+ end
84
+
85
+ example 'radius value must be within a certain range' do
86
+ expect{ gis.radius = 6200 }.to raise_error(GIS::Distance::Error)
87
+ expect{ gis.radius = 6400 }.to raise_error(GIS::Distance::Error)
88
+ end
89
+
90
+ example 'formula basic functionality' do
91
+ expect(gis).to respond_to(:formula)
92
+ expect{ gis.formula }.not_to raise_error
93
+ expect(gis.formula).to be_a(String)
94
+ end
95
+
96
+ example 'formula default value' do
97
+ expect(gis.formula).to eq('haversine')
98
+ end
99
+
100
+ example 'formula setter basic functionality' do
101
+ expect(gis).to respond_to(:formula=)
102
+ expect{ gis.formula = 'haversine' }.not_to raise_error
103
+ end
104
+
105
+ example 'formula setter validates value' do
106
+ expect{ gis.formula(1) }.to raise_error(ArgumentError)
107
+ expect{ gis.formula = 'foo' }.to raise_error(GIS::Distance::Error)
108
+ end
109
+
110
+ example 'mi basic functionality' do
111
+ expect(gis.distance).to respond_to(:mi)
112
+ expect{ gis.distance.mi }.not_to raise_error
113
+ expect(gis.distance.mi).to be_a(Float)
114
+ end
115
+
116
+ example 'mi behaves as expected' do
117
+ expect(gis.distance).to be > gis.distance.mi
118
+ expect(gis.distance.mi).to be_within(0.1).of(2455.9)
119
+ end
120
+
121
+ example 'mi_expected_errors' do
122
+ expect{ gis.distance.mi(1) }.to raise_error(ArgumentError)
123
+ end
124
+ end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gis-distance
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
8
  - Ardith Falkner
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain:
12
12
  - |
@@ -36,41 +36,106 @@ cert_chain:
36
36
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
37
37
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
38
38
  -----END CERTIFICATE-----
39
- date: 2018-03-22 00:00:00.000000000 Z
40
- dependencies: []
39
+ date: 2024-10-03 00:00:00.000000000 Z
40
+ dependencies:
41
+ - !ruby/object:Gem::Dependency
42
+ name: rvincenty
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
41
111
  description: Calculate the distance between two points on Earth
42
112
  email: djberg96@gmail.com
43
113
  executables: []
44
114
  extensions: []
45
- extra_rdoc_files:
46
- - README
47
- - CHANGES
48
- - MANIFEST
115
+ extra_rdoc_files: []
49
116
  files:
50
- - certs
117
+ - CHANGES.md
118
+ - Gemfile
119
+ - MANIFEST.md
120
+ - README.md
121
+ - Rakefile
51
122
  - certs/djberg96_pub.pem
52
- - CHANGES
53
123
  - gis-distance.gemspec
54
- - lib
55
- - lib/gis
56
- - lib/gis/distance.rb
57
124
  - lib/gis-distance.rb
58
- - MANIFEST
59
- - Rakefile
60
- - README
61
- - test
62
- - test/test_gis_distance.rb
125
+ - lib/gis/distance.rb
126
+ - spec/gis_distance_spec.rb
63
127
  homepage: http://github.com/djberg96/gis-distance
64
128
  licenses:
65
- - Artistic 2.0
129
+ - Artistic-2.0
66
130
  metadata:
67
131
  homepage_uri: https://github.com/djberg96/gis-distance
68
132
  bug_tracker_uri: https://github.com/djberg96/gis-distance/issues
69
- changelog_uri: https://github.com/djberg96/gis-distance/blob/master/CHANGES
133
+ changelog_uri: https://github.com/djberg96/gis-distance/blob/main/CHANGES.md
70
134
  documentation_uri: https://github.com/djberg96/gis-distance/wiki
71
135
  source_code_uri: https://github.com/djberg96/gis-distance
72
136
  wiki_uri: https://github.com/djberg96/gis-distance/wiki
73
- post_install_message:
137
+ rubygems_mfa_required: 'true'
138
+ post_install_message:
74
139
  rdoc_options: []
75
140
  require_paths:
76
141
  - lib
@@ -85,11 +150,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
150
  - !ruby/object:Gem::Version
86
151
  version: '0'
87
152
  requirements: []
88
- rubyforge_project:
89
- rubygems_version: 2.7.6
90
- signing_key:
153
+ rubygems_version: 3.5.16
154
+ signing_key:
91
155
  specification_version: 4
92
156
  summary: The gis-distance library provides a simple interface for calculating the
93
157
  distance between two points on Earth using latitude and longitude.
94
158
  test_files:
95
- - test/test_gis_distance.rb
159
+ - spec/gis_distance_spec.rb
metadata.gz.sig CHANGED
Binary file
data/CHANGES DELETED
@@ -1,13 +0,0 @@
1
- == 1.0.2 - 22-Mar-2018
2
- * Added 'cosines' as a supported formula. This will use the Law of cosines
3
- to calculate the distance.
4
- * Added metadata to the gemspec.
5
- * Added a cert.
6
- * Rakefile now assumes Rubygems 2.x, and other minor updates.
7
- * Added a gis-distance.rb file for convenience.
8
-
9
- == 1.0.1 - 26-Oct-2014
10
- * Updated gemspec, Rakefile.
11
-
12
- == 1.0.0 - 10-Oct-2009
13
- * Initial release
data/README DELETED
@@ -1,26 +0,0 @@
1
- == Description
2
- The gis-distance library allows you to calculate geographic distance between
3
- two points using the formula of your choice.
4
-
5
- == Installation
6
- gem install gis-distance
7
-
8
- == Synopsis
9
- require 'gis/distance' # or 'gis-distance'
10
-
11
- # New York to Los Angeles
12
- gis = GIS::Distance.new(40.47, 73.58, 34.3, 118.15)
13
-
14
- # Set the formula of your choice
15
- gis.formula = 'cosines'
16
- gis.formula = 'haversine'
17
-
18
- p gis.distance # Kilometers
19
- p gis.distance.mi # Miles
20
-
21
- == License
22
- Artistic 2.0
23
-
24
- == Authors
25
- * Daniel Berger
26
- * Ardith Falkner
@@ -1,99 +0,0 @@
1
- require 'test/unit'
2
- require 'gis/distance'
3
-
4
- class TC_GIS_Distance < Test::Unit::TestCase
5
- def setup
6
- @gis = GIS::Distance.new(40.47, 73.58, 34.3, 118.15)
7
- end
8
-
9
- def test_version
10
- assert_equal('1.0.2', GIS::Distance::VERSION)
11
- assert_true(GIS::Distance::VERSION.frozen?)
12
- end
13
-
14
- def test_distance_basic_functionality
15
- assert_respond_to(@gis, :distance)
16
- assert_nothing_raised{ @gis.distance }
17
- assert_kind_of(Float, @gis.distance)
18
- end
19
-
20
- def test_distance
21
- assert_in_delta(0.01, 3952.39, @gis.distance)
22
- assert_equal(0.0, GIS::Distance.new(40.47, 73.58, 40.47, 73.58).distance)
23
- end
24
-
25
- def test_distance_expected_argument_errors
26
- assert_raise(ArgumentError){ GIS::Distance.new }
27
- assert_raise(ArgumentError){ GIS::Distance.new(40.47) }
28
- assert_raise(ArgumentError){ GIS::Distance.new(40.47, 73.58) }
29
- assert_raise(ArgumentError){ GIS::Distance.new(40.47, 73.58, 34.3) }
30
- end
31
-
32
- def test_distance_expected_range_errors
33
- assert_raise(GIS::Distance::Error){ GIS::Distance.new(91.0, 100.0, 45.0, 45.0) }
34
- assert_raise(GIS::Distance::Error){ GIS::Distance.new(90.0, 190.0, 45.0, 45.0) }
35
- end
36
-
37
- def test_radius_basic_functionality
38
- assert_respond_to(@gis, :radius)
39
- assert_nothing_raised{ @gis.radius }
40
- assert_kind_of(Float, @gis.radius)
41
- end
42
-
43
- def test_default_radius
44
- assert_equal(6367.45, @gis.radius)
45
- end
46
-
47
- def test_radius_expected_errors
48
- assert_raise(ArgumentError){ @gis.radius(1) }
49
- end
50
-
51
- def test_radius_setter_basic_functionality
52
- assert_respond_to(@gis, :radius=)
53
- assert_nothing_raised{ @gis.radius = 6368.0 }
54
- assert_equal(6368.0, @gis.radius)
55
- end
56
-
57
- def test_radius_setter_expected_errors
58
- assert_raise(GIS::Distance::Error){ @gis.radius = 6200 }
59
- assert_raise(GIS::Distance::Error){ @gis.radius = 6400 }
60
- end
61
-
62
- def test_formula_basic_functionality
63
- assert_respond_to(@gis, :formula)
64
- assert_nothing_raised{ @gis.formula }
65
- assert_kind_of(String, @gis.formula)
66
- end
67
-
68
- def test_formula
69
- assert_equal('haversine', @gis.formula)
70
- end
71
-
72
- def test_formula_setter_basic_functionality
73
- assert_respond_to(@gis, :formula=)
74
- assert_nothing_raised{ @gis.formula = 'haversine' }
75
- end
76
-
77
- def test_formula_expected_errors
78
- assert_raise(ArgumentError){ @gis.formula(1) }
79
- assert_raise(GIS::Distance::Error){ @gis.formula = 'foo' }
80
- end
81
-
82
- def test_mi_basic_functionality
83
- assert_respond_to(@gis.distance, :mi)
84
- assert_nothing_raised{ @gis.distance.mi }
85
- assert_kind_of(Float, @gis.distance.mi)
86
- end
87
-
88
- def test_mi
89
- assert(@gis.distance > @gis.distance.mi)
90
- end
91
-
92
- def test_mi_expected_errors
93
- assert_raise(ArgumentError){ @gis.distance.mi(1) }
94
- end
95
-
96
- def teardown
97
- @gis = nil
98
- end
99
- end