geospatial 1.12.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46655140f5da1a76565f09afb88784d5b7649b1603e21f1c03bbd6f106949a44
4
- data.tar.gz: eacbf6a8aabb6b2cacdbdc243a1879c1a58d31e9f9964c46635f54880d18b542
3
+ metadata.gz: 7192e26af8621237a3727ebdc875df7af056a4ac9bf36dcadba378107c97b6a4
4
+ data.tar.gz: 833732089ee04ebedaf970430661cb51ec85fc878b1093d9b71440cf8a347327
5
5
  SHA512:
6
- metadata.gz: 77dc08c1bc0441bbb1df97395454892f4bcd610dd7706eca9b884bd228594b60335763e45d222bef819e58d22a579b154e88e2ee0fa6a90603e44990480c0bd4
7
- data.tar.gz: 236392df8641f5c37a3022249e4253587352fcd5024180fc36b5f4171525a66218433b114805b7762836c134da7d1fd40ab8c52b2b560e86786eb84d2f10d365
6
+ metadata.gz: ea63ff5c6dfa08038b891f2df6e3d0e78a77151834a9655a8f8dee85eca08d603860c99566f8d47b1ce0d45d60bd42fa2d09da187884f92e1ee637a21e7aef2c
7
+ data.tar.gz: 1c28ff01ced07bddb5091eea5aeadce0ebf4772752d3317a55ba3fcb8605b49573fb186b2dd27334930b0cffa5dfec5caf851c47aeb3468b1984bd401872f754
data/.travis.yml CHANGED
@@ -1,13 +1,20 @@
1
1
  language: ruby
2
+ dist: xenial
2
3
  cache: bundler
3
- rvm:
4
- - 2.3
5
- - 2.4
6
- - 2.5
7
- - 2.6
8
- - jruby-head
9
- - ruby-head
4
+
10
5
  matrix:
6
+ include:
7
+ - rvm: 2.3
8
+ - rvm: 2.4
9
+ - rvm: 2.5
10
+ - rvm: 2.6
11
+ - rvm: 2.6
12
+ env: COVERAGE=PartialSummary,Coveralls
13
+ - rvm: truffleruby
14
+ - rvm: jruby-head
15
+ env: JRUBY_OPTS="--debug -X+O"
16
+ - rvm: ruby-head
11
17
  allow_failures:
18
+ - rvm: truffleruby
12
19
  - rvm: ruby-head
13
20
  - rvm: jruby-head
data/README.md CHANGED
@@ -73,6 +73,15 @@ The Hilbert curve is multi-dimensional and therefore can represent multi-dimensi
73
73
 
74
74
  Mathematically speaking, it's possible to [compose curves together](https://github.com/cne1x/sfseize) to form curves of different precision/properties. However, how these fit together generally is a bit more complex, especially in terms of exploring the curve via traversal.
75
75
 
76
+ ### Finding the distance between two locations
77
+
78
+ ```ruby
79
+ lake_tekapo = Geospatial::Location.new(170.53, -43.89) # Lake Tekapo, New Zealand.
80
+ lake_alex = Geospatial::Location.new(170.45, -43.94) # Lake Alex, New Zealand.
81
+ distance = lake_alex.distance_from(lake_tekapo)
82
+ puts distance # 8479.056408162045 meters
83
+ ```
84
+
76
85
  ## Contributing
77
86
 
78
87
  1. Fork it
data/geospatial.gemspec CHANGED
@@ -16,9 +16,9 @@ Gem::Specification.new do |spec|
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
-
19
+
20
+ spec.add_development_dependency "covered"
20
21
  spec.add_development_dependency "rspec", "~> 3.6"
21
-
22
- spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "rake"
24
24
  end
@@ -173,6 +173,7 @@ module Geospatial
173
173
  return d
174
174
  end
175
175
 
176
+ # @return [Numeric] bearing in degrees.
176
177
  def bearing_from(other)
177
178
  lon1 = other.longitude * D2R
178
179
  lat1 = other.latitude * D2R
@@ -185,6 +186,8 @@ module Geospatial
185
186
  ) * R2D
186
187
  end
187
188
 
189
+ # @param distance [Numeric] distance in meters.
190
+ # @param bearing [Numeric] bearing in degrees.
188
191
  def location_by(bearing, distance)
189
192
  lon1 = self.longitude * D2R
190
193
  lat1 = self.latitude * D2R
@@ -98,8 +98,10 @@ module Geospatial
98
98
  def simplify(minimum_distance = 1)
99
99
  simplified_points = @points.first(1)
100
100
 
101
- @points.each do |point|
102
- if yield(simplified_points.last, point)
101
+ @points.each_with_index do |point, index|
102
+ next_point = @points[(index+1) % @points.size]
103
+
104
+ if yield(simplified_points.last, point, next_point)
103
105
  simplified_points << point
104
106
  end
105
107
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Geospatial
22
- VERSION = "1.12.0"
22
+ VERSION = "1.13.0"
23
23
  end
data/spec/spec_helper.rb CHANGED
@@ -1,23 +1,6 @@
1
1
 
2
- if ENV['COVERAGE'] || ENV['TRAVIS']
3
- begin
4
- require 'simplecov'
5
-
6
- SimpleCov.start do
7
- add_filter "/spec/"
8
- end
9
-
10
- if ENV['TRAVIS']
11
- require 'coveralls'
12
- Coveralls.wear!
13
- end
14
- rescue LoadError
15
- warn "Could not load simplecov: #{$!}"
16
- end
17
- end
18
-
19
- require "bundler/setup"
20
- require "geospatial"
2
+ require 'covered/rspec'
3
+ require 'geospatial'
21
4
 
22
5
  RSpec.configure do |config|
23
6
  # Enable flags like --only-failures and --next-failure
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geospatial
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-05 00:00:00.000000000 Z
11
+ date: 2019-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: covered
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -28,16 +42,16 @@ dependencies:
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: '1.6'
47
+ version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: '1.6'
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -61,7 +75,6 @@ extra_rdoc_files: []
61
75
  files:
62
76
  - ".gitignore"
63
77
  - ".rspec"
64
- - ".simplecov"
65
78
  - ".travis.yml"
66
79
  - Gemfile
67
80
  - README.md
@@ -124,8 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
137
  - !ruby/object:Gem::Version
125
138
  version: '0'
126
139
  requirements: []
127
- rubyforge_project:
128
- rubygems_version: 2.7.8
140
+ rubygems_version: 3.0.4
129
141
  signing_key:
130
142
  specification_version: 4
131
143
  summary: Provides abstractions for dealing with geographical locations efficiently
data/.simplecov DELETED
@@ -1,9 +0,0 @@
1
-
2
- SimpleCov.start do
3
- add_filter "/spec/"
4
- end
5
-
6
- if ENV['TRAVIS']
7
- require 'coveralls'
8
- Coveralls.wear!
9
- end