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 +4 -4
- data/.travis.yml +14 -7
- data/README.md +9 -0
- data/geospatial.gemspec +3 -3
- data/lib/geospatial/location.rb +3 -0
- data/lib/geospatial/polygon.rb +4 -2
- data/lib/geospatial/version.rb +1 -1
- data/spec/spec_helper.rb +2 -19
- metadata +21 -9
- data/.simplecov +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7192e26af8621237a3727ebdc875df7af056a4ac9bf36dcadba378107c97b6a4
|
4
|
+
data.tar.gz: 833732089ee04ebedaf970430661cb51ec85fc878b1093d9b71440cf8a347327
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
data/lib/geospatial/location.rb
CHANGED
@@ -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
|
data/lib/geospatial/polygon.rb
CHANGED
@@ -98,8 +98,10 @@ module Geospatial
|
|
98
98
|
def simplify(minimum_distance = 1)
|
99
99
|
simplified_points = @points.first(1)
|
100
100
|
|
101
|
-
@points.
|
102
|
-
|
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
|
data/lib/geospatial/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,23 +1,6 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
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.
|
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:
|
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: '
|
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: '
|
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
|
-
|
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
|