geospatial 1.4.0 → 1.4.1

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
  SHA1:
3
- metadata.gz: af57f14cdc085ce808e8462af23af0e269797b86
4
- data.tar.gz: f7bc6d182e0b5366a6ada00112c555a35576977b
3
+ metadata.gz: 15f0c8c532fe2f0546030210c5a72d2165049bec
4
+ data.tar.gz: 7ff3bcb66454f109bdd1c0eae8011d7a7594fb45
5
5
  SHA512:
6
- metadata.gz: 20a32b175c72f9989a8ffe6f29fa06637af22fda65d8d61c240d25c701268468248e4e52bc719b33e9f1c3396702fac0c49924e4878fae2d8ff07af8a4564251
7
- data.tar.gz: 471174aee8a1270436599bdfed01d623ff9a3d34dbce7b7221d63b9e266fbfdc5e4da8bd0ca990342a010b68281b7a3fddbd6f5fbfad33757de2ed05fa155c87
6
+ metadata.gz: ad01c05beaab5b05fa37c4a14a4bc2d69e74b59599e01e95d9d9d266a435ce5e147d78bfd58918d5d3eb0e7576d60f4c4fd6895d689c32d1356cced89ebf34c6
7
+ data.tar.gz: f260e9f9b7ab20b6211ce90abdb2e068d4d7913ad8042b322d9c2bf75cc85eb062ae5a144a0075b78d121946d2d7cca65be0545349547568607e444f68bb31bc
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
- --color
2
- --format documentation
1
+ --format documentation
2
+ --warnings
3
+ --require spec_helper
data/.rspec_status ADDED
@@ -0,0 +1,57 @@
1
+ example_id | status | run_time |
2
+ ----------------------------------------------- | ------ | --------------- |
3
+ ./spec/geospatial/box_spec.rb[1:1] | passed | 0.00096 seconds |
4
+ ./spec/geospatial/circle_spec.rb[1:1] | passed | 0.00011 seconds |
5
+ ./spec/geospatial/circle_spec.rb[1:2] | passed | 0.0001 seconds |
6
+ ./spec/geospatial/circle_spec.rb[1:3] | passed | 0.00009 seconds |
7
+ ./spec/geospatial/circle_spec.rb[1:4] | passed | 0.00008 seconds |
8
+ ./spec/geospatial/circle_spec.rb[1:5] | passed | 0.40939 seconds |
9
+ ./spec/geospatial/dimensions_spec.rb[1:1] | passed | 0.0001 seconds |
10
+ ./spec/geospatial/dimensions_spec.rb[1:2] | passed | 0.00006 seconds |
11
+ ./spec/geospatial/distance_spec.rb[1:1] | passed | 0.00005 seconds |
12
+ ./spec/geospatial/distance_spec.rb[1:2] | passed | 0.00005 seconds |
13
+ ./spec/geospatial/distance_spec.rb[1:3] | passed | 0.00005 seconds |
14
+ ./spec/geospatial/distance_spec.rb[1:4] | passed | 0.00005 seconds |
15
+ ./spec/geospatial/distance_spec.rb[1:5] | passed | 0.00004 seconds |
16
+ ./spec/geospatial/distance_spec.rb[1:6] | passed | 0.00006 seconds |
17
+ ./spec/geospatial/distance_spec.rb[1:7] | passed | 0.00007 seconds |
18
+ ./spec/geospatial/filter_spec.rb[1:1] | passed | 0.4025 seconds |
19
+ ./spec/geospatial/filter_spec.rb[1:2] | passed | 0.14153 seconds |
20
+ ./spec/geospatial/hilbert_curve_spec.rb[1:1:1] | passed | 0.00041 seconds |
21
+ ./spec/geospatial/hilbert_curve_spec.rb[1:2:1] | passed | 0.00009 seconds |
22
+ ./spec/geospatial/hilbert_curve_spec.rb[1:3:1] | passed | 0.00007 seconds |
23
+ ./spec/geospatial/hilbert_curve_spec.rb[1:4:1] | passed | 0.00007 seconds |
24
+ ./spec/geospatial/hilbert_curve_spec.rb[2:1:1] | passed | 0.00007 seconds |
25
+ ./spec/geospatial/hilbert_curve_spec.rb[2:2:1] | passed | 0.00007 seconds |
26
+ ./spec/geospatial/hilbert_curve_spec.rb[2:3:1] | passed | 0.00007 seconds |
27
+ ./spec/geospatial/hilbert_curve_spec.rb[2:4:1] | passed | 0.00007 seconds |
28
+ ./spec/geospatial/hilbert_curve_spec.rb[3:1:1] | passed | 0.00009 seconds |
29
+ ./spec/geospatial/hilbert_curve_spec.rb[3:2:1] | passed | 0.00011 seconds |
30
+ ./spec/geospatial/hilbert_curve_spec.rb[3:3:1] | passed | 0.0001 seconds |
31
+ ./spec/geospatial/hilbert_curve_spec.rb[3:4:1] | passed | 0.00011 seconds |
32
+ ./spec/geospatial/hilbert_traverse_spec.rb[1:1] | passed | 0.00025 seconds |
33
+ ./spec/geospatial/hilbert_traverse_spec.rb[2:1] | passed | 0.00384 seconds |
34
+ ./spec/geospatial/index_spec.rb[1:1:1] | passed | 0.00008 seconds |
35
+ ./spec/geospatial/index_spec.rb[1:1:2] | passed | 0.00008 seconds |
36
+ ./spec/geospatial/index_spec.rb[2:1:1] | passed | 0.00012 seconds |
37
+ ./spec/geospatial/index_spec.rb[2:1:2] | passed | 0.00009 seconds |
38
+ ./spec/geospatial/index_spec.rb[3:1:1] | passed | 0.00014 seconds |
39
+ ./spec/geospatial/index_spec.rb[3:1:2] | passed | 0.00014 seconds |
40
+ ./spec/geospatial/location_spec.rb[1:1] | passed | 0.00006 seconds |
41
+ ./spec/geospatial/location_spec.rb[1:2] | passed | 0.00006 seconds |
42
+ ./spec/geospatial/location_spec.rb[2:1] | passed | 0.00006 seconds |
43
+ ./spec/geospatial/map_index_spec.rb[1:1] | passed | 0.00009 seconds |
44
+ ./spec/geospatial/map_index_spec.rb[1:2] | passed | 0.00011 seconds |
45
+ ./spec/geospatial/map_spec.rb[1:1] | passed | 0.45715 seconds |
46
+ ./spec/geospatial/map_spec.rb[1:2] | passed | 0.00018 seconds |
47
+ ./spec/geospatial/map_spec.rb[1:3] | passed | 0.01971 seconds |
48
+ ./spec/geospatial/polygon_spec.rb[1:1] | passed | 0.00007 seconds |
49
+ ./spec/geospatial/polygon_spec.rb[1:2] | passed | 0.00011 seconds |
50
+ ./spec/geospatial/polygon_spec.rb[1:3] | passed | 0.00006 seconds |
51
+ ./spec/geospatial/polygon_spec.rb[1:4] | passed | 0.00007 seconds |
52
+ ./spec/geospatial/polygon_spec.rb[2:1] | passed | 2.09 seconds |
53
+ ./spec/geospatial/polygon_spec.rb[2:2] | passed | 2.09 seconds |
54
+ ./spec/geospatial/polygon_spec.rb[3:1] | passed | 0.14057 seconds |
55
+ ./spec/geospatial/polygon_spec.rb[3:2] | passed | 0.55125 seconds |
56
+ ./spec/geospatial/polygon_spec.rb[4:1] | passed | 0.54482 seconds |
57
+ ./spec/geospatial/polygon_spec.rb[5:1] | passed | 0.48422 seconds |
data/.travis.yml CHANGED
@@ -1,14 +1,18 @@
1
1
  language: ruby
2
2
  sudo: false
3
+ dist: trusty
4
+ cache: bundler
3
5
  rvm:
4
- - 2.1.8
5
- - 2.2.4
6
- - 2.3.0
6
+ - 2.0
7
+ - 2.1
8
+ - 2.2
9
+ - 2.3
10
+ - 2.4
11
+ - jruby-head
7
12
  - ruby-head
8
- - rbx-2
9
- env: COVERAGE=true
13
+ - rbx-3
10
14
  matrix:
11
- fast_finish: true
12
15
  allow_failures:
13
- - rvm: "ruby-head"
14
- - rvm: "rbx-2"
16
+ - rvm: ruby-head
17
+ - rvm: jruby-head
18
+ - rvm: rbx-3
data/geospatial.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
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 "rspec", "~> 3.4"
20
+ spec.add_development_dependency "rspec", "~> 3.6"
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.6"
23
23
  spec.add_development_dependency "rake"
@@ -20,7 +20,6 @@
20
20
 
21
21
  require_relative '../dimensions'
22
22
  require_relative '../index'
23
- require_relative 'traverse'
24
23
 
25
24
  module Geospatial
26
25
  module Hilbert
@@ -55,10 +54,38 @@ module Geospatial
55
54
 
56
55
  # This is a helper entry point for traversing Hilbert space.
57
56
  def traverse(&block)
58
- if block_given?
59
- self.class.traverse_recurse(@order, @rotation, 0, @origin, @size, &block)
60
- else
61
- self.class.to_enum(:traverse_recurse, @order, @rotation, 0, @origin, @size)
57
+ return to_enum(:traverse) unless block_given?
58
+
59
+ traverse_recurse(@order-1, 0, 0, self.origin, self.size, &block)
60
+ end
61
+
62
+ def bit_width
63
+ @dimensions.count
64
+ end
65
+
66
+ # Traversal enumerates all regions of a curve, top-down.
67
+ def traverse_recurse(order, mask, value, origin, size, &block)
68
+ half_size = size.collect{|value| value * 0.5}.freeze
69
+ prefix_mask = (1 << order) | mask
70
+
71
+ (2**bit_width).times do |prefix|
72
+ # These both do the same thing, not sure which one is faster:
73
+ child_value = (value << @dimensions.count) | prefix
74
+ prefix = child_value << (order*bit_width)
75
+
76
+ index = HilbertIndex.from_integral(prefix, bit_width, @order).to_ordinal
77
+
78
+ index = index & prefix_mask
79
+
80
+ child_origin = @dimensions.unmap(index.axes).freeze
81
+
82
+ # puts "yield(#{child_origin}, #{half_size}, #{prefix}, #{order})"
83
+ # We avoid calling traverse_recurse simply to hit the callback on the leaf nodes:
84
+ result = yield child_origin, half_size, prefix, order
85
+
86
+ if order > 0 and result != :skip
87
+ self.traverse_recurse(order - 1, prefix_mask, child_value, child_origin, half_size, &block)
88
+ end
62
89
  end
63
90
  end
64
91
 
@@ -46,10 +46,6 @@ module Geospatial
46
46
  VALID_LATITUDE = MIN_LATITUDE...MAX_LATITUDE
47
47
 
48
48
  class << self
49
- def [] (longitude:, latitude:)
50
- self.new(longitude, latitude)
51
- end
52
-
53
49
  def from_ecef(x, y, z)
54
50
  # Constants (WGS ellipsoid)
55
51
  a = WGS84_A
@@ -64,7 +60,7 @@ module Geospatial
64
60
  lon = Math::atan2(y, x)
65
61
  lat = Math::atan2((z+ep*ep*b*(Math::sin(th) ** 3)), (p-e*e*a*(Math::cos(th)**3)))
66
62
 
67
- n = a / Math::sqrt(1.0-e*e*(Math::sin(lat) ** 2))
63
+ # n = a / Math::sqrt(1.0-e*e*(Math::sin(lat) ** 2))
68
64
  # alt = p / Math::cos(lat)-n
69
65
 
70
66
  return self.new(lat*R2D, lon*R2D)
@@ -21,7 +21,8 @@
21
21
  require_relative 'location'
22
22
  require_relative 'box'
23
23
  require_relative 'filter'
24
- require_relative 'hilbert/traverse'
24
+
25
+ require_relative 'hilbert/curve'
25
26
 
26
27
  module Geospatial
27
28
  # A point is a location on a map with a specific hash representation based on the map. A point might store multi-dimentional data (e.g. longitude, latitude, time) which is hashed to a single column.
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Geospatial
22
- VERSION = "1.4.0"
22
+ VERSION = "1.4.1"
23
23
  end
@@ -1,5 +1,5 @@
1
1
 
2
- require 'geospatial/hilbert/traverse'
2
+ require 'geospatial/hilbert/curve'
3
3
 
4
4
  require_relative 'sorted'
5
5
 
@@ -0,0 +1,29 @@
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"
21
+
22
+ RSpec.configure do |config|
23
+ # Enable flags like --only-failures and --next-failure
24
+ config.example_status_persistence_file_path = ".rspec_status"
25
+
26
+ config.expect_with :rspec do |c|
27
+ c.syntax = :expect
28
+ end
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geospatial
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-04 00:00:00.000000000 Z
11
+ date: 2017-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.4'
19
+ version: '3.6'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.4'
26
+ version: '3.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -61,6 +61,7 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
63
  - ".rspec"
64
+ - ".rspec_status"
64
65
  - ".simplecov"
65
66
  - ".travis.yml"
66
67
  - Gemfile
@@ -76,7 +77,6 @@ files:
76
77
  - lib/geospatial/filter.rb
77
78
  - lib/geospatial/hilbert.rb
78
79
  - lib/geospatial/hilbert/curve.rb
79
- - lib/geospatial/hilbert/traverse.rb
80
80
  - lib/geospatial/index.rb
81
81
  - lib/geospatial/interleave.rb
82
82
  - lib/geospatial/location.rb
@@ -99,6 +99,7 @@ files:
99
99
  - spec/geospatial/sorted.rb
100
100
  - spec/geospatial/visualization.rb
101
101
  - spec/geospatial/world.png
102
+ - spec/spec_helper.rb
102
103
  homepage: https://github.com/ioquatix/geospatial
103
104
  licenses:
104
105
  - MIT
@@ -139,3 +140,4 @@ test_files:
139
140
  - spec/geospatial/sorted.rb
140
141
  - spec/geospatial/visualization.rb
141
142
  - spec/geospatial/world.png
143
+ - spec/spec_helper.rb
@@ -1,63 +0,0 @@
1
- # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
20
-
21
- require_relative 'curve'
22
-
23
- module Geospatial
24
- module Hilbert
25
- class Curve
26
- def traverse(&block)
27
- return to_enum(:traverse) unless block_given?
28
-
29
- traverse_recurse(@order-1, 0, 0, self.origin, self.size, &block)
30
- end
31
-
32
- def bit_width
33
- @dimensions.count
34
- end
35
-
36
- # Traversal enumerates all regions of a curve, top-down.
37
- def traverse_recurse(order, mask, value, origin, size, &block)
38
- half_size = size.collect{|value| value * 0.5}.freeze
39
- prefix_mask = (1 << order) | mask
40
-
41
- (2**bit_width).times do |prefix|
42
- # These both do the same thing, not sure which one is faster:
43
- child_value = (value << @dimensions.count) | prefix
44
- prefix = child_value << (order*bit_width)
45
-
46
- index = HilbertIndex.from_integral(prefix, bit_width, @order).to_ordinal
47
-
48
- index = index & prefix_mask
49
-
50
- child_origin = @dimensions.unmap(index.axes).freeze
51
-
52
- # puts "yield(#{child_origin}, #{half_size}, #{prefix}, #{order})"
53
- # We avoid calling traverse_recurse simply to hit the callback on the leaf nodes:
54
- result = yield child_origin, half_size, prefix, order
55
-
56
- if order > 0 and result != :skip
57
- self.traverse_recurse(order - 1, prefix_mask, child_value, child_origin, half_size, &block)
58
- end
59
- end
60
- end
61
- end
62
- end
63
- end