h3 3.5.1 → 3.6.0
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 +3 -3
- data/ext/h3/src/.travis.yml +15 -4
- data/ext/h3/src/CHANGELOG.md +7 -0
- data/ext/h3/src/CMakeLists.txt +15 -0
- data/ext/h3/src/README.md +5 -6
- data/ext/h3/src/VERSION +1 -1
- data/ext/h3/src/docs/api/hierarchy.md +8 -0
- data/ext/h3/src/docs/api/misc.md +18 -0
- data/ext/h3/src/scripts/coverage.sh.in +7 -3
- data/ext/h3/src/src/apps/miscapps/generateBaseCellNeighbors.c +2 -2
- data/ext/h3/src/src/apps/miscapps/generateNumHexagons.c +0 -2
- data/ext/h3/src/src/apps/testapps/testCompact.c +12 -0
- data/ext/h3/src/src/apps/testapps/testH3Distance.c +1 -50
- data/ext/h3/src/src/apps/testapps/testH3DistanceExhaustive.c +83 -0
- data/ext/h3/src/src/apps/testapps/testH3Line.c +1 -84
- data/ext/h3/src/src/apps/testapps/testH3LineExhaustive.c +114 -0
- data/ext/h3/src/src/apps/testapps/testH3ToCenterChild.c +67 -0
- data/ext/h3/src/src/apps/testapps/testH3ToChildren.c +14 -2
- data/ext/h3/src/src/apps/testapps/testH3ToLocalIj.c +12 -230
- data/ext/h3/src/src/apps/testapps/testH3ToLocalIjExhaustive.c +264 -0
- data/ext/h3/src/src/apps/testapps/testPentagonIndexes.c +57 -0
- data/ext/h3/src/src/h3lib/include/constants.h +2 -0
- data/ext/h3/src/src/h3lib/include/h3api.h.in +20 -0
- data/ext/h3/src/src/h3lib/lib/algos.c +5 -5
- data/ext/h3/src/src/h3lib/lib/faceijk.c +3 -3
- data/ext/h3/src/src/h3lib/lib/h3Index.c +69 -6
- data/ext/h3/src/src/h3lib/lib/localij.c +4 -4
- data/ext/h3/src/src/h3lib/lib/polygon.c +1 -2
- data/h3.gemspec +1 -1
- data/lib/h3/bindings/private.rb +1 -0
- data/lib/h3/hierarchy.rb +15 -0
- data/lib/h3/miscellaneous.rb +25 -0
- data/lib/h3/version.rb +1 -1
- data/spec/hierarchy_spec.rb +10 -0
- data/spec/miscellaneous_spec.rb +28 -0
- metadata +9 -4
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright 2018 Uber Technologies, Inc.
|
2
|
+
* Copyright 2018-2019 Uber Technologies, Inc.
|
3
3
|
*
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
* you may not use this file except in compliance with the License.
|
@@ -139,8 +139,8 @@ int h3ToLocalIjk(H3Index origin, H3Index h3, CoordIJK* out) {
|
|
139
139
|
int baseCell = H3_GET_BASE_CELL(h3);
|
140
140
|
|
141
141
|
// Direction from origin base cell to index base cell
|
142
|
-
Direction dir =
|
143
|
-
Direction revDir =
|
142
|
+
Direction dir = CENTER_DIGIT;
|
143
|
+
Direction revDir = CENTER_DIGIT;
|
144
144
|
if (originBaseCell != baseCell) {
|
145
145
|
dir = _getBaseCellDirection(originBaseCell, baseCell);
|
146
146
|
if (dir == INVALID_DIGIT) {
|
@@ -290,7 +290,7 @@ int localIjkToH3(H3Index origin, const CoordIJK* ijk, H3Index* out) {
|
|
290
290
|
|
291
291
|
// check for res 0/base cell
|
292
292
|
if (res == 0) {
|
293
|
-
if (ijk->i > 1 || ijk->
|
293
|
+
if (ijk->i > 1 || ijk->j > 1 || ijk->k > 1) {
|
294
294
|
// out of range input
|
295
295
|
return 1;
|
296
296
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright 2018 Uber Technologies, Inc.
|
2
|
+
* Copyright 2018-2019 Uber Technologies, Inc.
|
3
3
|
*
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
* you may not use this file except in compliance with the License.
|
@@ -18,7 +18,6 @@
|
|
18
18
|
*/
|
19
19
|
|
20
20
|
#include "polygon.h"
|
21
|
-
#include <assert.h>
|
22
21
|
#include <float.h>
|
23
22
|
#include <math.h>
|
24
23
|
#include <stdbool.h>
|
data/h3.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
|
15
15
|
spec.add_runtime_dependency "ffi", "~> 1.9"
|
16
16
|
spec.add_runtime_dependency "rgeo-geojson", "~> 2.1"
|
17
|
-
spec.add_runtime_dependency "zeitwerk", "~> 2.1
|
17
|
+
spec.add_runtime_dependency "zeitwerk", "~> 2.1"
|
18
18
|
|
19
19
|
spec.add_development_dependency "coveralls", "~> 0.8"
|
20
20
|
spec.add_development_dependency "rake", "~> 12.3"
|
data/lib/h3/bindings/private.rb
CHANGED
@@ -10,6 +10,7 @@ module H3
|
|
10
10
|
attach_function :compact, [H3IndexesIn, H3IndexesOut, :size], :bool
|
11
11
|
attach_function :destroy_linked_polygon, :destroyLinkedPolygon, [LinkedGeoPolygon], :void
|
12
12
|
attach_function :geo_to_h3, :geoToH3, [GeoCoord, Resolution], :h3_index
|
13
|
+
attach_function :get_pentagon_indexes, :getPentagonIndexes, [:int, H3IndexesOut], :void
|
13
14
|
attach_function :h3_faces, :h3GetFaces, %i[h3_index output_buffer], :void
|
14
15
|
attach_function :h3_indexes_from_unidirectional_edge,
|
15
16
|
:getH3IndexesFromUnidirectionalEdge,
|
data/lib/h3/hierarchy.rb
CHANGED
@@ -39,6 +39,21 @@ module H3
|
|
39
39
|
# @return [Integer] Maximum number of child hexagons possible at given resolution.
|
40
40
|
attach_function :max_children, :maxH3ToChildrenSize, [:h3_index, Resolution], :int
|
41
41
|
|
42
|
+
# @!method center_child(h3_index, child_resolution)
|
43
|
+
#
|
44
|
+
# Returns the center child (finer) index contained by the given index
|
45
|
+
# at the given resolution.
|
46
|
+
#
|
47
|
+
# @param [Integer] h3_index A valid H3 index.
|
48
|
+
# @param [Integer] child_resoluton The desired resolution of the center child hexagon.
|
49
|
+
#
|
50
|
+
# @example Find center child hexagon.
|
51
|
+
# H3.center_child(613196570357137407, 10)
|
52
|
+
# 622203769609814015
|
53
|
+
#
|
54
|
+
# @return [Integer] H3 index of center child hexagon.
|
55
|
+
attach_function :center_child, :h3ToCenterChild, [:h3_index, Resolution], :h3_index
|
56
|
+
|
42
57
|
# @deprecated Please use {#max_children} instead.
|
43
58
|
def max_h3_to_children_size(h3_index, resolution)
|
44
59
|
max_children(h3_index, resolution)
|
data/lib/h3/miscellaneous.rb
CHANGED
@@ -113,6 +113,18 @@ module H3
|
|
113
113
|
# @return [Integer] The number of resolution 0 hexagons (base cells).
|
114
114
|
attach_function :base_cell_count, :res0IndexCount, [], :int
|
115
115
|
|
116
|
+
# @!method pentagon_count
|
117
|
+
#
|
118
|
+
# Number of pentagon H3 indexes per resolution.
|
119
|
+
# This is always 12, but provided as a convenience.
|
120
|
+
#
|
121
|
+
# @example Return the number of pentagons
|
122
|
+
# H3.pentagon_count
|
123
|
+
# 12
|
124
|
+
#
|
125
|
+
# @return [Integer] The number of pentagons per resolution.
|
126
|
+
attach_function :pentagon_count, :pentagonIndexCount, [], :int
|
127
|
+
|
116
128
|
# @deprecated Please use {#base_cell_count} instead.
|
117
129
|
def res_0_index_count
|
118
130
|
base_cell_count
|
@@ -132,6 +144,19 @@ module H3
|
|
132
144
|
out.read
|
133
145
|
end
|
134
146
|
|
147
|
+
# Returns all pentagon indexes at the given resolution.
|
148
|
+
#
|
149
|
+
# @example Return all pentagons at resolution 4.
|
150
|
+
# H3.pentagons(4)
|
151
|
+
# [594615896891195391, 594967740612083711, ..., 598591730937233407]
|
152
|
+
#
|
153
|
+
# @return [Array<Integer>] All pentagon indexes at the given resolution.
|
154
|
+
def pentagons(resolution)
|
155
|
+
out = H3Indexes.of_size(pentagon_count)
|
156
|
+
Bindings::Private.get_pentagon_indexes(resolution, out)
|
157
|
+
out.read
|
158
|
+
end
|
159
|
+
|
135
160
|
# @deprecated Please use {#base_cells} instead.
|
136
161
|
def res_0_indexes
|
137
162
|
base_cells
|
data/lib/h3/version.rb
CHANGED
data/spec/hierarchy_spec.rb
CHANGED
@@ -172,4 +172,14 @@ RSpec.describe H3 do
|
|
172
172
|
end
|
173
173
|
end
|
174
174
|
end
|
175
|
+
|
176
|
+
describe ".center_child" do
|
177
|
+
let(:h3_index) { "8828308299fffff".to_i(16) }
|
178
|
+
let(:resolution) { 10 }
|
179
|
+
let(:result) { "8a2830829807fff".to_i(16) }
|
180
|
+
|
181
|
+
subject(:center_child) { H3.center_child(h3_index, resolution) }
|
182
|
+
|
183
|
+
it { is_expected.to eq result }
|
184
|
+
end
|
175
185
|
end
|
data/spec/miscellaneous_spec.rb
CHANGED
@@ -81,4 +81,32 @@ RSpec.describe H3 do
|
|
81
81
|
expect(base_cells.count).to eq(count)
|
82
82
|
end
|
83
83
|
end
|
84
|
+
|
85
|
+
describe ".pentagon_count" do
|
86
|
+
let(:count) { 12 }
|
87
|
+
subject(:pentagon_count) { H3.pentagon_count }
|
88
|
+
|
89
|
+
it "has 12 pentagons per resolution" do
|
90
|
+
expect(pentagon_count).to eq(count)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe ".pentagons" do
|
95
|
+
let(:resolution) { 4 }
|
96
|
+
let(:expected) do
|
97
|
+
[
|
98
|
+
594615896891195391, 594967740612083711,
|
99
|
+
595319584332972031, 595812165542215679,
|
100
|
+
596199193635192831, 596515852983992319,
|
101
|
+
596691774844436479, 597008434193235967,
|
102
|
+
597395462286213119, 597888043495456767,
|
103
|
+
598239887216345087, 598591730937233407
|
104
|
+
]
|
105
|
+
end
|
106
|
+
subject(:pentagons) { H3.pentagons(resolution) }
|
107
|
+
|
108
|
+
it "returns pentagons at the given resolution" do
|
109
|
+
expect(pentagons).to eq(expected)
|
110
|
+
end
|
111
|
+
end
|
84
112
|
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.
|
4
|
+
version: 3.6.0
|
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-08-
|
12
|
+
date: 2019-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 2.1
|
48
|
+
version: '2.1'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 2.1
|
55
|
+
version: '2.1'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: coveralls
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -225,16 +225,20 @@ files:
|
|
225
225
|
- ext/h3/src/src/apps/testapps/testGeoToH3.c
|
226
226
|
- ext/h3/src/src/apps/testapps/testH3Api.c
|
227
227
|
- ext/h3/src/src/apps/testapps/testH3Distance.c
|
228
|
+
- ext/h3/src/src/apps/testapps/testH3DistanceExhaustive.c
|
228
229
|
- ext/h3/src/src/apps/testapps/testH3GetFaces.c
|
229
230
|
- ext/h3/src/src/apps/testapps/testH3Index.c
|
230
231
|
- ext/h3/src/src/apps/testapps/testH3Line.c
|
232
|
+
- ext/h3/src/src/apps/testapps/testH3LineExhaustive.c
|
231
233
|
- ext/h3/src/src/apps/testapps/testH3NeighborRotations.c
|
232
234
|
- ext/h3/src/src/apps/testapps/testH3SetToLinkedGeo.c
|
233
235
|
- ext/h3/src/src/apps/testapps/testH3SetToVertexGraph.c
|
236
|
+
- ext/h3/src/src/apps/testapps/testH3ToCenterChild.c
|
234
237
|
- ext/h3/src/src/apps/testapps/testH3ToChildren.c
|
235
238
|
- ext/h3/src/src/apps/testapps/testH3ToGeo.c
|
236
239
|
- ext/h3/src/src/apps/testapps/testH3ToGeoBoundary.c
|
237
240
|
- ext/h3/src/src/apps/testapps/testH3ToLocalIj.c
|
241
|
+
- ext/h3/src/src/apps/testapps/testH3ToLocalIjExhaustive.c
|
238
242
|
- ext/h3/src/src/apps/testapps/testH3ToParent.c
|
239
243
|
- ext/h3/src/src/apps/testapps/testH3UniEdge.c
|
240
244
|
- ext/h3/src/src/apps/testapps/testHexRanges.c
|
@@ -242,6 +246,7 @@ files:
|
|
242
246
|
- ext/h3/src/src/apps/testapps/testKRing.c
|
243
247
|
- ext/h3/src/src/apps/testapps/testLinkedGeo.c
|
244
248
|
- ext/h3/src/src/apps/testapps/testMaxH3ToChildrenSize.c
|
249
|
+
- ext/h3/src/src/apps/testapps/testPentagonIndexes.c
|
245
250
|
- ext/h3/src/src/apps/testapps/testPolyfill.c
|
246
251
|
- ext/h3/src/src/apps/testapps/testPolygon.c
|
247
252
|
- ext/h3/src/src/apps/testapps/testVec2d.c
|