h3 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +19 -0
- data/.gitignore +3 -0
- data/.rspec +1 -0
- data/.rubocop.yml +255 -0
- data/.travis.yml +19 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +42 -0
- data/LICENSE.md +21 -0
- data/README.md +51 -0
- data/Rakefile +3 -0
- data/h3.gemspec +21 -0
- data/lib/h3.rb +36 -0
- data/lib/h3/bindings.rb +12 -0
- data/lib/h3/bindings/base.rb +15 -0
- data/lib/h3/bindings/private.rb +32 -0
- data/lib/h3/bindings/structs.rb +59 -0
- data/lib/h3/geo_json.rb +169 -0
- data/lib/h3/hierarchy.rb +160 -0
- data/lib/h3/indexing.rb +80 -0
- data/lib/h3/inspection.rb +105 -0
- data/lib/h3/miscellaneous.rb +99 -0
- data/lib/h3/regions.rb +239 -0
- data/lib/h3/traversal.rb +287 -0
- data/lib/h3/unidirectional_edges.rb +146 -0
- data/lib/h3/version.rb +3 -0
- data/spec/geo_json_spec.rb +118 -0
- data/spec/hierarchy_spec.rb +159 -0
- data/spec/indexing_spec.rb +92 -0
- data/spec/inspection_spec.rb +90 -0
- data/spec/miscellaneous_spec.rb +75 -0
- data/spec/region_spec.rb +71 -0
- data/spec/spec_helper.rb +100 -0
- data/spec/support/fixtures/australia.json +1 -0
- data/spec/support/fixtures/banbury.json +1 -0
- data/spec/support/fixtures/banbury_feature.json +93 -0
- data/spec/support/fixtures/banbury_feature_collection.json +98 -0
- data/spec/support/fixtures/banbury_out.json +1 -0
- data/spec/support/fixtures/banbury_without_holes.json +1 -0
- data/spec/support/shared_contexts/constants.rb +4 -0
- data/spec/traversal_spec.rb +343 -0
- data/spec/unidirectional_edges_spec.rb +119 -0
- metadata +155 -0
@@ -0,0 +1,119 @@
|
|
1
|
+
RSpec.describe H3 do
|
2
|
+
include_context "constants"
|
3
|
+
|
4
|
+
describe ".h3_indexes_neighbors?" do
|
5
|
+
let(:origin) { "8928308280fffff".to_i(16) }
|
6
|
+
let(:destination) { "8928308280bffff".to_i(16) }
|
7
|
+
let(:result) { true }
|
8
|
+
|
9
|
+
subject(:h3_indexes_neighbors?) { H3.h3_indexes_neighbors?(origin, destination) }
|
10
|
+
|
11
|
+
it { is_expected.to eq(result) }
|
12
|
+
|
13
|
+
context "when the indexes aren't neighbors" do
|
14
|
+
let(:destination) { "89283082993ffff".to_i(16) }
|
15
|
+
let(:result) { false }
|
16
|
+
|
17
|
+
it { is_expected.to eq(result) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe ".h3_unidirectional_edge" do
|
22
|
+
let(:origin) { "8928308280fffff".to_i(16) }
|
23
|
+
let(:destination) { "8928308280bffff".to_i(16) }
|
24
|
+
let(:result) { "16928308280fffff".to_i(16) }
|
25
|
+
|
26
|
+
subject(:h3_unidirectional_edge) { H3.h3_unidirectional_edge(origin, destination) }
|
27
|
+
|
28
|
+
it { is_expected.to eq(result) }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe ".h3_unidirectional_edge_valid?" do
|
32
|
+
let(:edge) { "11928308280fffff".to_i(16) }
|
33
|
+
let(:result) { true }
|
34
|
+
|
35
|
+
subject(:h3_unidirectional_edge_valid?) { H3.h3_unidirectional_edge_valid?(edge) }
|
36
|
+
|
37
|
+
it { is_expected.to eq(result) }
|
38
|
+
|
39
|
+
context "when the h3 index is not a valid unidirectional edge" do
|
40
|
+
let(:edge) { "8928308280fffff".to_i(16) }
|
41
|
+
let(:result) { false }
|
42
|
+
|
43
|
+
it { is_expected.to eq(result) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe ".origin_from_unidirectional_edge" do
|
48
|
+
let(:edge) { "11928308280fffff".to_i(16) }
|
49
|
+
let(:result) { "8928308280fffff".to_i(16) }
|
50
|
+
|
51
|
+
subject(:origin_from_unidirectional_edge) { H3.origin_from_unidirectional_edge(edge) }
|
52
|
+
|
53
|
+
it { is_expected.to eq(result) }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe ".destination_from_unidirectional_edge" do
|
57
|
+
let(:edge) { "11928308280fffff".to_i(16) }
|
58
|
+
let(:result) { "8928308283bffff".to_i(16) }
|
59
|
+
|
60
|
+
subject(:destination_from_unidirectional_edge) { H3.destination_from_unidirectional_edge(edge) }
|
61
|
+
|
62
|
+
it { is_expected.to eq(result) }
|
63
|
+
end
|
64
|
+
|
65
|
+
describe ".h3_indexes_from_unidirectional_edge" do
|
66
|
+
let(:h3_index) { "11928308280fffff".to_i(16) }
|
67
|
+
let(:expected_indexes) do
|
68
|
+
%w(8928308280fffff 8928308283bffff).map { |i| i.to_i(16) }
|
69
|
+
end
|
70
|
+
|
71
|
+
subject(:h3_indexes_from_unidirectional_edge) do
|
72
|
+
H3.h3_indexes_from_unidirectional_edge(h3_index)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "has two expected h3 indexes" do
|
76
|
+
expect(h3_indexes_from_unidirectional_edge).to eq(expected_indexes)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe ".h3_unidirectional_edges_from_hexagon" do
|
81
|
+
subject(:h3_unidirectional_edges_from_hexagon) do
|
82
|
+
H3.h3_unidirectional_edges_from_hexagon(h3_index)
|
83
|
+
end
|
84
|
+
|
85
|
+
context "when index is a hexagon" do
|
86
|
+
let(:h3_index) { "8928308280fffff".to_i(16) }
|
87
|
+
let(:count) { 6 }
|
88
|
+
|
89
|
+
it "has six expected edges" do
|
90
|
+
expect(h3_unidirectional_edges_from_hexagon.count).to eq(count)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context "when index is a pentagon" do
|
95
|
+
let(:h3_index) { "821c07fffffffff".to_i(16) }
|
96
|
+
let(:count) { 5 }
|
97
|
+
|
98
|
+
it "has five expected edges" do
|
99
|
+
expect(h3_unidirectional_edges_from_hexagon.count).to eq(count)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe ".h3_unidirectional_edge_boundary" do
|
105
|
+
let(:edge) { "11928308280fffff".to_i(16) }
|
106
|
+
let(:expected) do
|
107
|
+
[[37.77820687262237, -122.41971895414808], [37.77652420699321, -122.42079024541876]]
|
108
|
+
end
|
109
|
+
|
110
|
+
subject(:h3_unidirectional_edge_boundary) { H3.h3_unidirectional_edge_boundary(edge) }
|
111
|
+
|
112
|
+
it "matches expected coordinates" do
|
113
|
+
h3_unidirectional_edge_boundary.zip(expected) do |(lat, lon), (exp_lat, exp_lon)|
|
114
|
+
expect(lat).to be_within(0.000001).of(exp_lat)
|
115
|
+
expect(lon).to be_within(0.000001).of(exp_lon)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: h3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lachlan Laycock
|
8
|
+
- Sean Handley
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2018-12-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ffi
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.9'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.9'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rgeo-geojson
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '2.1'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '2.1'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '12.3'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '12.3'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.8'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.8'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: yard
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.9'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.9'
|
84
|
+
description:
|
85
|
+
email: l.laycock@stuart.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".codeclimate.yml"
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".rubocop.yml"
|
94
|
+
- ".travis.yml"
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- LICENSE.md
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- h3.gemspec
|
101
|
+
- lib/h3.rb
|
102
|
+
- lib/h3/bindings.rb
|
103
|
+
- lib/h3/bindings/base.rb
|
104
|
+
- lib/h3/bindings/private.rb
|
105
|
+
- lib/h3/bindings/structs.rb
|
106
|
+
- lib/h3/geo_json.rb
|
107
|
+
- lib/h3/hierarchy.rb
|
108
|
+
- lib/h3/indexing.rb
|
109
|
+
- lib/h3/inspection.rb
|
110
|
+
- lib/h3/miscellaneous.rb
|
111
|
+
- lib/h3/regions.rb
|
112
|
+
- lib/h3/traversal.rb
|
113
|
+
- lib/h3/unidirectional_edges.rb
|
114
|
+
- lib/h3/version.rb
|
115
|
+
- spec/geo_json_spec.rb
|
116
|
+
- spec/hierarchy_spec.rb
|
117
|
+
- spec/indexing_spec.rb
|
118
|
+
- spec/inspection_spec.rb
|
119
|
+
- spec/miscellaneous_spec.rb
|
120
|
+
- spec/region_spec.rb
|
121
|
+
- spec/spec_helper.rb
|
122
|
+
- spec/support/fixtures/australia.json
|
123
|
+
- spec/support/fixtures/banbury.json
|
124
|
+
- spec/support/fixtures/banbury_feature.json
|
125
|
+
- spec/support/fixtures/banbury_feature_collection.json
|
126
|
+
- spec/support/fixtures/banbury_out.json
|
127
|
+
- spec/support/fixtures/banbury_without_holes.json
|
128
|
+
- spec/support/shared_contexts/constants.rb
|
129
|
+
- spec/traversal_spec.rb
|
130
|
+
- spec/unidirectional_edges_spec.rb
|
131
|
+
homepage: https://github.com/StuartApp/h3_ruby
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">"
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '2.3'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.7.3
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: C Bindings for Uber's H3 library
|
155
|
+
test_files: []
|