|
1 | 1 | require "bigdecimal" |
2 | 2 |
|
3 | | -RSpec.describe H3Ruby do |
| 3 | +RSpec.describe H3 do |
4 | 4 | let(:valid_h3_index) { "8819429a9dfffff".to_i(16) } |
5 | 5 | let(:too_long_number) { 10_000_000_000_000_000_000_000 } |
6 | 6 |
|
7 | 7 | describe ".max_kring_size" do |
8 | 8 | let(:k) { 2 } |
9 | 9 | let(:result) { 19 } |
10 | 10 |
|
11 | | - subject(:max_kring_size) { H3Ruby.max_kring_size(k) } |
| 11 | + subject(:max_kring_size) { H3.max_kring_size(k) } |
12 | 12 |
|
13 | 13 | it { is_expected.to eq(result) } |
14 | 14 |
|
|
34 | 34 | let(:coords) { [53.959130, -1.079230]} |
35 | 35 | let(:result) { valid_h3_index } |
36 | 36 |
|
37 | | - subject(:geo_to_h3) { H3Ruby.geo_to_h3(coords, resolution) } |
| 37 | + subject(:geo_to_h3) { H3.geo_to_h3(coords, resolution) } |
38 | 38 |
|
39 | 39 | it { is_expected.to eq(result) } |
40 | 40 |
|
|
67 | 67 | let(:h3_index) { valid_h3_index } |
68 | 68 | let(:result) { [53.95860421941974, -1.081195647095136] } |
69 | 69 |
|
70 | | - subject(:h3_to_geo) { H3Ruby.h3_to_geo(h3_index) } |
| 70 | + subject(:h3_to_geo) { H3.h3_to_geo(h3_index) } |
71 | 71 |
|
72 | 72 | it { is_expected.to eq(result) } |
73 | 73 |
|
|
92 | 92 | let(:h3_index) { valid_h3_index } |
93 | 93 | let(:result) { true } |
94 | 94 |
|
95 | | - subject(:h3_valid?) { H3Ruby.h3_valid?(h3_index) } |
| 95 | + subject(:h3_valid?) { H3.h3_valid?(h3_index) } |
96 | 96 |
|
97 | 97 | it { is_expected.to eq(result) } |
98 | 98 |
|
|
111 | 111 | let(:resolution) { 2 } |
112 | 112 | let(:result) { 5882 } |
113 | 113 |
|
114 | | - subject(:num_hexagons) { H3Ruby.num_hexagons(resolution) } |
| 114 | + subject(:num_hexagons) { H3.num_hexagons(resolution) } |
115 | 115 |
|
116 | 116 | it { is_expected.to eq(result) } |
117 | 117 |
|
|
129 | 129 | let(:degs) { 100 } |
130 | 130 | let(:result) { 1.7453292519943295 } |
131 | 131 |
|
132 | | - subject(:degs_to_rads) { H3Ruby.degs_to_rads(degs) } |
| 132 | + subject(:degs_to_rads) { H3.degs_to_rads(degs) } |
133 | 133 |
|
134 | 134 | it { is_expected.to eq(result) } |
135 | 135 | end |
|
138 | 138 | let(:rads) { 1.7453292519943295 } |
139 | 139 | let(:result) { 100 } |
140 | 140 |
|
141 | | - subject(:rads_to_degs) { H3Ruby.rads_to_degs(rads) } |
| 141 | + subject(:rads_to_degs) { H3.rads_to_degs(rads) } |
142 | 142 |
|
143 | 143 | it { is_expected.to eq(result) } |
144 | 144 | end |
|
147 | 147 | let(:resolution) { 2 } |
148 | 148 | let(:result) { 86745.85403 } |
149 | 149 |
|
150 | | - subject(:hex_area_km2) { H3Ruby.hex_area_km2(resolution) } |
| 150 | + subject(:hex_area_km2) { H3.hex_area_km2(resolution) } |
151 | 151 |
|
152 | 152 | it { is_expected.to eq(result) } |
153 | 153 | end |
|
156 | 156 | let(:resolution) { 2 } |
157 | 157 | let(:result) { 86745854035.0 } |
158 | 158 |
|
159 | | - subject(:hex_area_m2) { H3Ruby.hex_area_m2(resolution) } |
| 159 | + subject(:hex_area_m2) { H3.hex_area_m2(resolution) } |
160 | 160 |
|
161 | 161 | it { is_expected.to eq(result) } |
162 | 162 | end |
|
165 | 165 | let(:resolution) { 2 } |
166 | 166 | let(:result) { 158.2446558 } |
167 | 167 |
|
168 | | - subject(:edge_length_km) { H3Ruby.edge_length_km(resolution) } |
| 168 | + subject(:edge_length_km) { H3.edge_length_km(resolution) } |
169 | 169 |
|
170 | 170 | it { is_expected.to eq(result) } |
171 | 171 | end |
|
174 | 174 | let(:resolution) { 2 } |
175 | 175 | let(:result) { 158244.6558 } |
176 | 176 |
|
177 | | - subject(:edge_length_m) { H3Ruby.edge_length_m(resolution) } |
| 177 | + subject(:edge_length_m) { H3.edge_length_m(resolution) } |
178 | 178 |
|
179 | 179 | it { is_expected.to eq(result) } |
180 | 180 | end |
|
183 | 183 | let(:h3_index) { "8928308280fffff".to_i(16) } |
184 | 184 | let(:result) { true } |
185 | 185 |
|
186 | | - subject(:h3_res_class_3) { H3Ruby.h3_res_class_3?(h3_index) } |
| 186 | + subject(:h3_res_class_3) { H3.h3_res_class_3?(h3_index) } |
187 | 187 |
|
188 | 188 | it { is_expected.to eq(result) } |
189 | 189 |
|
|
199 | 199 | let(:h3_index) { "821c07fffffffff".to_i(16) } |
200 | 200 | let(:result) { true } |
201 | 201 |
|
202 | | - subject(:h3_pentagon?) { H3Ruby.h3_pentagon?(h3_index) } |
| 202 | + subject(:h3_pentagon?) { H3.h3_pentagon?(h3_index) } |
203 | 203 |
|
204 | 204 | it { is_expected.to eq(result) } |
205 | 205 |
|
|
215 | 215 | let(:edge) { "11928308280fffff".to_i(16) } |
216 | 216 | let(:result) { true } |
217 | 217 |
|
218 | | - subject(:h3_unidirectional_edge_valid?) { H3Ruby.h3_unidirectional_edge_valid?(edge) } |
| 218 | + subject(:h3_unidirectional_edge_valid?) { H3.h3_unidirectional_edge_valid?(edge) } |
219 | 219 |
|
220 | 220 | it { is_expected.to eq(result) } |
221 | 221 |
|
|
231 | 231 | let(:h3_index) { valid_h3_index } |
232 | 232 | let(:result) { 8 } |
233 | 233 |
|
234 | | - subject(:h3_resolution) { H3Ruby.h3_resolution(h3_index) } |
| 234 | + subject(:h3_resolution) { H3.h3_resolution(h3_index) } |
235 | 235 |
|
236 | 236 | it { is_expected.to eq(result) } |
237 | 237 | end |
|
240 | 240 | let(:h3_index) { valid_h3_index } |
241 | 241 | let(:result) { 12 } |
242 | 242 |
|
243 | | - subject(:h3_base_cell) { H3Ruby.h3_base_cell(h3_index) } |
| 243 | + subject(:h3_base_cell) { H3.h3_base_cell(h3_index) } |
244 | 244 |
|
245 | 245 | it { is_expected.to eq(result) } |
246 | 246 | end |
|
249 | 249 | let(:edge) { "11928308280fffff".to_i(16) } |
250 | 250 | let(:result) { "8928308280fffff".to_i(16) } |
251 | 251 |
|
252 | | - subject(:origin_from_unidirectional_edge) { H3Ruby.origin_from_unidirectional_edge(edge) } |
| 252 | + subject(:origin_from_unidirectional_edge) { H3.origin_from_unidirectional_edge(edge) } |
253 | 253 |
|
254 | 254 | it { is_expected.to eq(result) } |
255 | 255 | end |
|
258 | 258 | let(:edge) { "11928308280fffff".to_i(16) } |
259 | 259 | let(:result) { "8928308283bffff".to_i(16) } |
260 | 260 |
|
261 | | - subject(:destination_from_unidirectional_edge) { H3Ruby.destination_from_unidirectional_edge(edge) } |
| 261 | + subject(:destination_from_unidirectional_edge) { H3.destination_from_unidirectional_edge(edge) } |
262 | 262 |
|
263 | 263 | it { is_expected.to eq(result) } |
264 | 264 | end |
|
268 | 268 | let(:destination) { "89283082827ffff".to_i(16) } |
269 | 269 | let(:result) { 5 } |
270 | 270 |
|
271 | | - subject(:h3_distance) { H3Ruby.h3_distance(origin, destination) } |
| 271 | + subject(:h3_distance) { H3.h3_distance(origin, destination) } |
272 | 272 |
|
273 | 273 | it { is_expected.to eq(result) } |
274 | 274 | end |
|
278 | 278 | let(:parent_resolution) { 8 } |
279 | 279 | let(:result) { 698351615 } |
280 | 280 |
|
281 | | - subject(:h3_to_parent) { H3Ruby.h3_to_parent(h3_index, parent_resolution) } |
| 281 | + subject(:h3_to_parent) { H3.h3_to_parent(h3_index, parent_resolution) } |
282 | 282 |
|
283 | 283 | it { is_expected.to eq(result) } |
284 | 284 | end |
|
288 | 288 | let(:child_resolution) { 10 } |
289 | 289 | let(:result) { 7 } |
290 | 290 |
|
291 | | - subject(:max_h3_to_children_size) { H3Ruby.max_h3_to_children_size(h3_index, child_resolution) } |
| 291 | + subject(:max_h3_to_children_size) { H3.max_h3_to_children_size(h3_index, child_resolution) } |
292 | 292 |
|
293 | 293 | it { is_expected.to eq(result) } |
294 | 294 | end |
|
298 | 298 | let(:destination) { "8928308280bffff".to_i(16) } |
299 | 299 | let(:result) { true } |
300 | 300 |
|
301 | | - subject(:h3_indexes_neighbors?) { H3Ruby.h3_indexes_neighbors?(origin, destination) } |
| 301 | + subject(:h3_indexes_neighbors?) { H3.h3_indexes_neighbors?(origin, destination) } |
302 | 302 |
|
303 | 303 | it { is_expected.to eq(result) } |
304 | 304 |
|
|
315 | 315 | let(:destination) { "8928308280bffff".to_i(16) } |
316 | 316 | let(:result) { "16928308280fffff".to_i(16) } |
317 | 317 |
|
318 | | - subject(:h3_unidirectional_edge) { H3Ruby.h3_unidirectional_edge(origin, destination) } |
| 318 | + subject(:h3_unidirectional_edge) { H3.h3_unidirectional_edge(origin, destination) } |
319 | 319 |
|
320 | 320 | it { is_expected.to eq(result) } |
321 | 321 | end |
|
324 | 324 | let(:h3_index) { "8928308280fffff"} |
325 | 325 | let(:result) { h3_index.to_i(16) } |
326 | 326 |
|
327 | | - subject(:string_to_h3) { H3Ruby.string_to_h3(h3_index) } |
| 327 | + subject(:string_to_h3) { H3.string_to_h3(h3_index) } |
328 | 328 |
|
329 | 329 | it { is_expected.to eq(result) } |
330 | 330 | end |
|
333 | 333 | let(:h3_index) { "8928308280fffff" } |
334 | 334 | let(:result) { h3_index.to_i(16) } |
335 | 335 |
|
336 | | - subject(:string_to_h3) { H3Ruby.string_to_h3(h3_index) } |
| 336 | + subject(:string_to_h3) { H3.string_to_h3(h3_index) } |
337 | 337 |
|
338 | 338 | it { is_expected.to eq(result) } |
339 | 339 | end |
|
342 | 342 | let(:h3_index) { "8928308280fffff".to_i(16) } |
343 | 343 | let(:result) { h3_index.to_s(16) } |
344 | 344 |
|
345 | | - subject(:h3_to_string) { H3Ruby.h3_to_string(h3_index) } |
| 345 | + subject(:h3_to_string) { H3.h3_to_string(h3_index) } |
346 | 346 |
|
347 | 347 | it { is_expected.to eq(result) } |
348 | 348 | end |
|
0 commit comments