h3 3.4.4 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +2 -1
  5. data/ext/h3/Makefile +1 -1
  6. data/ext/h3/src/.gitignore +2 -1
  7. data/ext/h3/src/CHANGELOG.md +9 -0
  8. data/ext/h3/src/CMakeLists.txt +72 -45
  9. data/ext/h3/src/RELEASE.md +2 -1
  10. data/ext/h3/src/VERSION +1 -1
  11. data/ext/h3/src/docs/api/hierarchy.md +2 -0
  12. data/ext/h3/src/docs/api/indexing.md +3 -1
  13. data/ext/h3/src/docs/api/inspection.md +20 -0
  14. data/ext/h3/src/docs/api/misc.md +2 -0
  15. data/ext/h3/src/docs/api/regions.md +2 -0
  16. data/ext/h3/src/docs/api/traversal.md +2 -0
  17. data/ext/h3/src/docs/api/uniedge.md +2 -0
  18. data/ext/h3/src/docs/community/bindings.md +4 -0
  19. data/ext/h3/src/docs/community/tutorials.md +12 -0
  20. data/ext/h3/src/scripts/update_version.sh +50 -0
  21. data/ext/h3/src/src/apps/applib/include/args.h +122 -0
  22. data/ext/h3/src/src/apps/applib/include/utility.h +5 -62
  23. data/ext/h3/src/src/apps/applib/lib/args.c +216 -0
  24. data/ext/h3/src/src/apps/applib/lib/utility.c +40 -206
  25. data/ext/h3/src/src/apps/filters/geoToH3.c +7 -9
  26. data/ext/h3/src/src/apps/filters/h3ToComponents.c +50 -47
  27. data/ext/h3/src/src/apps/filters/h3ToGeo.c +7 -30
  28. data/ext/h3/src/src/apps/filters/h3ToGeoBoundary.c +7 -27
  29. data/ext/h3/src/src/apps/filters/h3ToLocalIj.c +42 -25
  30. data/ext/h3/src/src/apps/filters/hexRange.c +43 -24
  31. data/ext/h3/src/src/apps/filters/kRing.c +4 -4
  32. data/ext/h3/src/src/apps/filters/localIjToH3.c +63 -21
  33. data/ext/h3/src/src/apps/miscapps/h3ToGeoBoundaryHier.c +68 -44
  34. data/ext/h3/src/src/apps/miscapps/h3ToGeoHier.c +68 -43
  35. data/ext/h3/src/src/apps/miscapps/h3ToHier.c +48 -37
  36. data/ext/h3/src/src/apps/testapps/mkRandGeo.c +32 -27
  37. data/ext/h3/src/src/apps/testapps/mkRandGeoBoundary.c +33 -28
  38. data/ext/h3/src/src/apps/testapps/testH3GetFaces.c +136 -0
  39. data/ext/h3/src/src/h3lib/include/faceijk.h +19 -7
  40. data/ext/h3/src/src/h3lib/include/h3api.h.in +12 -1
  41. data/ext/h3/src/src/h3lib/lib/algos.c +7 -2
  42. data/ext/h3/src/src/h3lib/lib/faceijk.c +135 -103
  43. data/ext/h3/src/src/h3lib/lib/h3Index.c +86 -5
  44. data/lib/h3/bindings/private.rb +1 -0
  45. data/lib/h3/inspection.rb +34 -0
  46. data/lib/h3/version.rb +1 -1
  47. data/spec/inspection_spec.rb +33 -1
  48. metadata +6 -2
@@ -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 :h3_faces, :h3GetFaces, %i[h3_index output_buffer], :void
13
14
  attach_function :h3_indexes_from_unidirectional_edge,
14
15
  :getH3IndexesFromUnidirectionalEdge,
15
16
  [:h3_index, H3IndexesOut], :void
data/lib/h3/inspection.rb CHANGED
@@ -101,5 +101,39 @@ module H3
101
101
  Bindings::Private.h3_to_string(h3_index, h3_str, H3_TO_STR_BUF_SIZE)
102
102
  h3_str.read_string
103
103
  end
104
+
105
+ # @!method max_face_count(h3_index)
106
+ #
107
+ # Returns the maximum number of icosahedron faces the given H3 index may intersect.
108
+ #
109
+ # @param [Integer] h3_index A H3 index.
110
+ #
111
+ # @example Check maximum faces
112
+ # H3.max_face_count(585961082523222015)
113
+ # 5
114
+ #
115
+ # @return [Integer] Maximum possible number of faces
116
+ attach_function :max_face_count, :maxFaceCount, %i[h3_index], :int
117
+
118
+ # void h3GetFaces(H3Index h, int* out);
119
+
120
+ # @!method h3_faces(h3_index)
121
+ #
122
+ # Find all icosahedron faces intersected by a given H3 index.
123
+ #
124
+ # @param [Integer] h3_index A H3 index.
125
+ #
126
+ # @example Find icosahedron faces for given index
127
+ # H3.h3_faces(585961082523222015)
128
+ # [1, 2, 6, 7, 11]
129
+ #
130
+ # @return [Array<Integer>] Faces. Faces are represented as integers from 0-19, inclusive.
131
+ def h3_faces(h3_index)
132
+ max_faces = max_face_count(h3_index)
133
+ out = FFI::MemoryPointer.new(:int, max_faces)
134
+ Bindings::Private.h3_faces(h3_index, out)
135
+ # The C function returns a sparse array whose holes are represented by -1.
136
+ out.read_array_of_int(max_faces).reject(&:negative?).sort
137
+ end
104
138
  end
105
139
  end
data/lib/h3/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module H3
2
- VERSION = "3.4.4".freeze
2
+ VERSION = "3.5.0".freeze
3
3
  end
@@ -87,4 +87,36 @@ RSpec.describe H3 do
87
87
  it { is_expected.to eq(result) }
88
88
  end
89
89
  end
90
- end
90
+
91
+ describe ".max_face_count" do
92
+ let(:h3_index) { "8928308280fffff".to_i(16) }
93
+ let(:result) { 2 }
94
+
95
+ subject(:max_face_count) { H3.max_face_count(h3_index) }
96
+
97
+ it { is_expected.to eq(result) }
98
+
99
+ context "when the h3 index is a pentagon" do
100
+ let(:h3_index) { "821c07fffffffff".to_i(16) }
101
+ let(:result) { 5 }
102
+
103
+ it { is_expected.to eq(result) }
104
+ end
105
+ end
106
+
107
+ describe ".h3_faces" do
108
+ let(:h3_index) { "8928308280fffff".to_i(16) }
109
+ let(:result) { [7] }
110
+
111
+ subject(:max_face_count) { H3.h3_faces(h3_index) }
112
+
113
+ it { is_expected.to eq(result) }
114
+
115
+ context "when the h3 index is a pentagon" do
116
+ let(:h3_index) { "821c07fffffffff".to_i(16) }
117
+ let(:result) { [1, 2, 6, 7, 11] }
118
+
119
+ it { is_expected.to eq(result) }
120
+ end
121
+ end
122
+ 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.4
4
+ version: 3.5.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-06-04 00:00:00.000000000 Z
12
+ date: 2019-07-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -169,10 +169,13 @@ files:
169
169
  - ext/h3/src/scripts/binding_functions.sh
170
170
  - ext/h3/src/scripts/coverage.sh.in
171
171
  - ext/h3/src/scripts/publish_website.sh
172
+ - ext/h3/src/scripts/update_version.sh
173
+ - ext/h3/src/src/apps/applib/include/args.h
172
174
  - ext/h3/src/src/apps/applib/include/benchmark.h
173
175
  - ext/h3/src/src/apps/applib/include/kml.h
174
176
  - ext/h3/src/src/apps/applib/include/test.h
175
177
  - ext/h3/src/src/apps/applib/include/utility.h
178
+ - ext/h3/src/src/apps/applib/lib/args.c
176
179
  - ext/h3/src/src/apps/applib/lib/kml.c
177
180
  - ext/h3/src/src/apps/applib/lib/test.c
178
181
  - ext/h3/src/src/apps/applib/lib/utility.c
@@ -208,6 +211,7 @@ files:
208
211
  - ext/h3/src/src/apps/testapps/testGeoToH3.c
209
212
  - ext/h3/src/src/apps/testapps/testH3Api.c
210
213
  - ext/h3/src/src/apps/testapps/testH3Distance.c
214
+ - ext/h3/src/src/apps/testapps/testH3GetFaces.c
211
215
  - ext/h3/src/src/apps/testapps/testH3Index.c
212
216
  - ext/h3/src/src/apps/testapps/testH3Line.c
213
217
  - ext/h3/src/src/apps/testapps/testH3NeighborRotations.c