h3 3.5.0 → 3.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +6 -4
- data/README.md +7 -7
- data/h3.gemspec +1 -0
- data/lib/h3.rb +8 -23
- data/lib/h3/bindings/base.rb +1 -0
- data/lib/h3/geo_json.rb +1 -1
- data/lib/h3/hierarchy.rb +27 -9
- data/lib/h3/indexing.rb +25 -7
- data/lib/h3/inspection.rb +77 -25
- data/lib/h3/miscellaneous.rb +27 -9
- data/lib/h3/traversal.rb +27 -9
- data/lib/h3/unidirectional_edges.rb +70 -15
- data/lib/h3/version.rb +1 -1
- data/spec/hierarchy_spec.rb +13 -13
- data/spec/indexing_spec.rb +15 -15
- data/spec/inspection_spec.rb +17 -17
- data/spec/miscellaneous_spec.rb +6 -6
- data/spec/traversal_spec.rb +6 -6
- data/spec/unidirectional_edges_spec.rb +18 -18
- metadata +16 -3
- data/lib/h3/bindings.rb +0 -12
data/spec/inspection_spec.rb
CHANGED
@@ -1,47 +1,47 @@
|
|
1
1
|
RSpec.describe H3 do
|
2
2
|
include_context "constants"
|
3
3
|
|
4
|
-
describe ".
|
4
|
+
describe ".resolution" do
|
5
5
|
let(:h3_index) { valid_h3_index }
|
6
6
|
let(:result) { 8 }
|
7
7
|
|
8
|
-
subject(:
|
8
|
+
subject(:resolution) { H3.resolution(h3_index) }
|
9
9
|
|
10
10
|
it { is_expected.to eq(result) }
|
11
11
|
end
|
12
12
|
|
13
|
-
describe ".
|
13
|
+
describe ".base_cell" do
|
14
14
|
let(:h3_index) { valid_h3_index }
|
15
15
|
let(:result) { 12 }
|
16
16
|
|
17
|
-
subject(:
|
17
|
+
subject(:base_cell) { H3.base_cell(h3_index) }
|
18
18
|
|
19
19
|
it { is_expected.to eq(result) }
|
20
20
|
end
|
21
21
|
|
22
|
-
describe ".
|
22
|
+
describe ".from_string" do
|
23
23
|
let(:h3_index) { "8928308280fffff"}
|
24
24
|
let(:result) { h3_index.to_i(16) }
|
25
25
|
|
26
|
-
subject(:
|
26
|
+
subject(:from_string) { H3.from_string(h3_index) }
|
27
27
|
|
28
28
|
it { is_expected.to eq(result) }
|
29
29
|
end
|
30
30
|
|
31
|
-
describe ".
|
31
|
+
describe ".to_string" do
|
32
32
|
let(:h3_index) { "8928308280fffff".to_i(16) }
|
33
33
|
let(:result) { h3_index.to_s(16) }
|
34
34
|
|
35
|
-
subject(:
|
35
|
+
subject(:to_string) { H3.to_string(h3_index) }
|
36
36
|
|
37
37
|
it { is_expected.to eq(result) }
|
38
38
|
end
|
39
39
|
|
40
|
-
describe ".
|
40
|
+
describe ".valid?" do
|
41
41
|
let(:h3_index) { valid_h3_index }
|
42
42
|
let(:result) { true }
|
43
43
|
|
44
|
-
subject(:
|
44
|
+
subject(:valid?) { H3.valid?(h3_index) }
|
45
45
|
|
46
46
|
it { is_expected.to eq(result) }
|
47
47
|
|
@@ -51,16 +51,16 @@ RSpec.describe H3 do
|
|
51
51
|
let(:result) { false }
|
52
52
|
|
53
53
|
it "returns the expected result" do
|
54
|
-
expect(
|
54
|
+
expect(valid?).to eq(result)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
describe ".
|
59
|
+
describe ".class_3_resolution?" do
|
60
60
|
let(:h3_index) { "8928308280fffff".to_i(16) }
|
61
61
|
let(:result) { true }
|
62
62
|
|
63
|
-
subject(:
|
63
|
+
subject(:class_3_resolution) { H3.class_3_resolution?(h3_index) }
|
64
64
|
|
65
65
|
it { is_expected.to eq(result) }
|
66
66
|
|
@@ -72,11 +72,11 @@ RSpec.describe H3 do
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
describe ".
|
75
|
+
describe ".pentagon?" do
|
76
76
|
let(:h3_index) { "821c07fffffffff".to_i(16) }
|
77
77
|
let(:result) { true }
|
78
78
|
|
79
|
-
subject(:
|
79
|
+
subject(:pentagon?) { H3.pentagon?(h3_index) }
|
80
80
|
|
81
81
|
it { is_expected.to eq(result) }
|
82
82
|
|
@@ -104,11 +104,11 @@ RSpec.describe H3 do
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
describe ".
|
107
|
+
describe ".faces" do
|
108
108
|
let(:h3_index) { "8928308280fffff".to_i(16) }
|
109
109
|
let(:result) { [7] }
|
110
110
|
|
111
|
-
subject(:
|
111
|
+
subject(:faces) { H3.faces(h3_index) }
|
112
112
|
|
113
113
|
it { is_expected.to eq(result) }
|
114
114
|
|
data/spec/miscellaneous_spec.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
RSpec.describe H3 do
|
2
2
|
include_context "constants"
|
3
3
|
|
4
|
-
describe ".
|
4
|
+
describe ".hexagon_count" do
|
5
5
|
let(:resolution) { 2 }
|
6
6
|
let(:result) { 5882 }
|
7
7
|
|
8
|
-
subject(:
|
8
|
+
subject(:hexagon_count) { H3.hexagon_count(resolution) }
|
9
9
|
|
10
10
|
it { is_expected.to eq(result) }
|
11
11
|
|
@@ -14,7 +14,7 @@ RSpec.describe H3 do
|
|
14
14
|
let(:result) { false }
|
15
15
|
|
16
16
|
it "returns the expected result" do
|
17
|
-
expect {
|
17
|
+
expect { hexagon_count }.to raise_error(ArgumentError)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -73,12 +73,12 @@ RSpec.describe H3 do
|
|
73
73
|
it { is_expected.to eq(result) }
|
74
74
|
end
|
75
75
|
|
76
|
-
describe ".
|
76
|
+
describe ".base_cells" do
|
77
77
|
let(:count) { 122 }
|
78
|
-
subject(:
|
78
|
+
subject(:base_cells) { H3.base_cells }
|
79
79
|
|
80
80
|
it "has 122 base cells" do
|
81
|
-
expect(
|
81
|
+
expect(base_cells.count).to eq(count)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
data/spec/traversal_spec.rb
CHANGED
@@ -331,27 +331,27 @@ RSpec.describe H3 do
|
|
331
331
|
end
|
332
332
|
end
|
333
333
|
|
334
|
-
describe ".
|
334
|
+
describe ".distance" do
|
335
335
|
let(:origin) { "89283082993ffff".to_i(16) }
|
336
336
|
let(:destination) { "89283082827ffff".to_i(16) }
|
337
337
|
let(:result) { 5 }
|
338
338
|
|
339
|
-
subject(:
|
339
|
+
subject(:distance) { H3.distance(origin, destination) }
|
340
340
|
|
341
341
|
it { is_expected.to eq(result) }
|
342
342
|
end
|
343
343
|
|
344
|
-
describe ".
|
344
|
+
describe ".line_size" do
|
345
345
|
let(:origin) { "89283082993ffff".to_i(16) }
|
346
346
|
let(:destination) { "89283082827ffff".to_i(16) }
|
347
347
|
let(:result) { 6 }
|
348
348
|
|
349
|
-
subject(:h3_line_size) { H3.
|
349
|
+
subject(:h3_line_size) { H3.line_size(origin, destination) }
|
350
350
|
|
351
351
|
it { is_expected.to eq(result) }
|
352
352
|
end
|
353
353
|
|
354
|
-
describe ".
|
354
|
+
describe ".line" do
|
355
355
|
let(:origin) { "89283082993ffff".to_i(16) }
|
356
356
|
let(:destination) { "89283082827ffff".to_i(16) }
|
357
357
|
let(:result) do
|
@@ -361,7 +361,7 @@ RSpec.describe H3 do
|
|
361
361
|
].map { |i| i.to_i(16) }
|
362
362
|
end
|
363
363
|
|
364
|
-
subject(:
|
364
|
+
subject(:line) { H3.line(origin, destination) }
|
365
365
|
|
366
366
|
it { is_expected.to eq(result) }
|
367
367
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
RSpec.describe H3 do
|
2
2
|
include_context "constants"
|
3
3
|
|
4
|
-
describe ".
|
4
|
+
describe ".neighbors?" do
|
5
5
|
let(:origin) { "8928308280fffff".to_i(16) }
|
6
6
|
let(:destination) { "8928308280bffff".to_i(16) }
|
7
7
|
let(:result) { true }
|
8
8
|
|
9
|
-
subject(:
|
9
|
+
subject(:neighbors?) { H3.neighbors?(origin, destination) }
|
10
10
|
|
11
11
|
it { is_expected.to eq(result) }
|
12
12
|
|
@@ -18,21 +18,21 @@ RSpec.describe H3 do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
describe ".
|
21
|
+
describe ".unidirectional_edge" do
|
22
22
|
let(:origin) { "8928308280fffff".to_i(16) }
|
23
23
|
let(:destination) { "8928308280bffff".to_i(16) }
|
24
24
|
let(:result) { "16928308280fffff".to_i(16) }
|
25
25
|
|
26
|
-
subject(:
|
26
|
+
subject(:unidirectional_edge) { H3.unidirectional_edge(origin, destination) }
|
27
27
|
|
28
28
|
it { is_expected.to eq(result) }
|
29
29
|
end
|
30
30
|
|
31
|
-
describe ".
|
31
|
+
describe ".unidirectional_edge_valid?" do
|
32
32
|
let(:edge) { "11928308280fffff".to_i(16) }
|
33
33
|
let(:result) { true }
|
34
34
|
|
35
|
-
subject(:h3_unidirectional_edge_valid?) { H3.
|
35
|
+
subject(:h3_unidirectional_edge_valid?) { H3.unidirectional_edge_valid?(edge) }
|
36
36
|
|
37
37
|
it { is_expected.to eq(result) }
|
38
38
|
|
@@ -62,24 +62,24 @@ RSpec.describe H3 do
|
|
62
62
|
it { is_expected.to eq(result) }
|
63
63
|
end
|
64
64
|
|
65
|
-
describe ".
|
65
|
+
describe ".origin_and_destination_from_unidirectional_edge" do
|
66
66
|
let(:h3_index) { "11928308280fffff".to_i(16) }
|
67
67
|
let(:expected_indexes) do
|
68
68
|
%w(8928308280fffff 8928308283bffff).map { |i| i.to_i(16) }
|
69
69
|
end
|
70
70
|
|
71
|
-
subject(:
|
72
|
-
H3.
|
71
|
+
subject(:origin_and_destination_from_unidirectional_edge) do
|
72
|
+
H3.origin_and_destination_from_unidirectional_edge(h3_index)
|
73
73
|
end
|
74
74
|
|
75
75
|
it "has two expected h3 indexes" do
|
76
|
-
expect(
|
76
|
+
expect(origin_and_destination_from_unidirectional_edge).to eq(expected_indexes)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
describe ".
|
81
|
-
subject(:
|
82
|
-
H3.
|
80
|
+
describe ".unidirectional_edges_from_hexagon" do
|
81
|
+
subject(:unidirectional_edges_from_hexagon) do
|
82
|
+
H3.unidirectional_edges_from_hexagon(h3_index)
|
83
83
|
end
|
84
84
|
|
85
85
|
context "when index is a hexagon" do
|
@@ -87,7 +87,7 @@ RSpec.describe H3 do
|
|
87
87
|
let(:count) { 6 }
|
88
88
|
|
89
89
|
it "has six expected edges" do
|
90
|
-
expect(
|
90
|
+
expect(unidirectional_edges_from_hexagon.count).to eq(count)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
@@ -96,21 +96,21 @@ RSpec.describe H3 do
|
|
96
96
|
let(:count) { 5 }
|
97
97
|
|
98
98
|
it "has five expected edges" do
|
99
|
-
expect(
|
99
|
+
expect(unidirectional_edges_from_hexagon.count).to eq(count)
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
describe ".
|
104
|
+
describe ".unidirectional_edge_boundary" do
|
105
105
|
let(:edge) { "11928308280fffff".to_i(16) }
|
106
106
|
let(:expected) do
|
107
107
|
[[37.77820687262237, -122.41971895414808], [37.77652420699321, -122.42079024541876]]
|
108
108
|
end
|
109
109
|
|
110
|
-
subject(:
|
110
|
+
subject(:unidirectional_edge_boundary) { H3.unidirectional_edge_boundary(edge) }
|
111
111
|
|
112
112
|
it "matches expected coordinates" do
|
113
|
-
|
113
|
+
unidirectional_edge_boundary.zip(expected) do |(lat, lon), (exp_lat, exp_lon)|
|
114
114
|
expect(lat).to be_within(0.000001).of(exp_lat)
|
115
115
|
expect(lon).to be_within(0.000001).of(exp_lon)
|
116
116
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: h3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lachlan Laycock
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-08-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
@@ -39,6 +39,20 @@ dependencies:
|
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '2.1'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: zeitwerk
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 2.1.9
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.1.9
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: coveralls
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -374,7 +388,6 @@ files:
|
|
374
388
|
- ext/h3/src/website/static/index.html
|
375
389
|
- h3.gemspec
|
376
390
|
- lib/h3.rb
|
377
|
-
- lib/h3/bindings.rb
|
378
391
|
- lib/h3/bindings/base.rb
|
379
392
|
- lib/h3/bindings/private.rb
|
380
393
|
- lib/h3/bindings/structs.rb
|
data/lib/h3/bindings.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require "h3/bindings/base"
|
2
|
-
require "h3/bindings/structs"
|
3
|
-
require "h3/bindings/types"
|
4
|
-
require "h3/bindings/private"
|
5
|
-
|
6
|
-
module H3
|
7
|
-
# Internal bindings related modules and classes.
|
8
|
-
#
|
9
|
-
# These are intended to be used by the library's public methods
|
10
|
-
# and not to be used directly by client code.
|
11
|
-
module Bindings; end
|
12
|
-
end
|