h3 3.5.0 → 3.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +45 -0
- data/Gemfile.lock +9 -7
- data/README.md +8 -8
- data/ext/h3/src/.github/workflows/test-linux.yml +118 -0
- data/ext/h3/src/.github/workflows/test-macos.yml +42 -0
- data/ext/h3/src/.github/workflows/test-website.yml +32 -0
- data/ext/h3/src/.github/workflows/test-windows.yml +44 -0
- data/ext/h3/src/.gitignore +5 -0
- data/ext/h3/src/.travis.yml +21 -32
- data/ext/h3/src/CHANGELOG.md +60 -0
- data/ext/h3/src/CMakeLists.txt +150 -33
- data/ext/h3/src/CONTRIBUTING.md +1 -1
- data/ext/h3/src/README.md +65 -16
- data/ext/h3/src/RELEASE.md +3 -1
- data/ext/h3/src/VERSION +1 -1
- data/ext/h3/src/dev-docs/RFCs/rfc-template.md +21 -0
- data/ext/h3/src/dev-docs/RFCs/v4.0.0/error-handling-rfc.md +21 -0
- data/ext/h3/src/dev-docs/RFCs/v4.0.0/names_for_concepts_types_functions.md +276 -0
- data/ext/h3/src/dev-docs/RFCs/v4.0.0/overrideable-allocators-rfc.md +141 -0
- data/ext/h3/src/dev-docs/RFCs/v4.0.0/polyfill-modes-rfc.md +21 -0
- data/ext/h3/src/dev-docs/RFCs/v4.0.0/vertex-mode-rfc.md +50 -0
- data/ext/h3/src/dev-docs/build_windows.md +6 -1
- data/ext/h3/src/dev-docs/creating_bindings.md +3 -3
- data/ext/h3/src/dev-docs/custom_alloc.md +27 -0
- data/ext/h3/src/docs/{overview/mainpage.md → README.md} +2 -3
- data/ext/h3/src/docs/api/hierarchy.md +8 -0
- data/ext/h3/src/docs/api/misc.md +94 -0
- data/ext/h3/src/docs/community/applications.md +1 -0
- data/ext/h3/src/docs/community/bindings.md +10 -0
- data/ext/h3/src/docs/community/tutorials.md +8 -3
- data/ext/h3/src/docs/core-library/coordsystems.md +5 -4
- data/ext/h3/src/docs/core-library/filters.md +8 -9
- data/ext/h3/src/docs/core-library/geoToH3desc.md +2 -3
- data/ext/h3/src/docs/core-library/h3ToGeoBoundaryDesc.md +4 -5
- data/ext/h3/src/docs/core-library/h3ToGeoDesc.md +3 -4
- data/ext/h3/src/docs/core-library/h3indexing.md +26 -17
- data/ext/h3/src/docs/core-library/overview.md +2 -3
- data/ext/h3/src/docs/core-library/restable.md +1 -2
- data/ext/h3/src/docs/core-library/usage.md +1 -2
- data/ext/h3/src/docs/table-of-contents.json +47 -0
- data/ext/h3/src/docs/{overview/usecases.md → usecases.md} +6 -11
- data/ext/h3/src/scripts/binding_functions.sh +1 -1
- data/ext/h3/src/scripts/coverage.sh.in +8 -4
- data/ext/h3/src/scripts/update_version.sh +2 -2
- data/ext/h3/src/src/apps/applib/include/args.h +1 -0
- data/ext/h3/src/src/apps/applib/include/test.h +1 -0
- data/ext/h3/src/src/apps/applib/include/utility.h +7 -1
- data/ext/h3/src/src/apps/applib/lib/args.c +2 -0
- data/ext/h3/src/src/apps/applib/lib/kml.c +2 -0
- data/ext/h3/src/src/apps/applib/lib/test.c +1 -0
- data/ext/h3/src/src/apps/applib/lib/utility.c +133 -2
- data/ext/h3/src/src/apps/benchmarks/benchmarkH3Api.c +1 -1
- data/ext/h3/src/{website/html.config.js → src/apps/benchmarks/benchmarkH3UniEdge.c} +15 -12
- data/ext/h3/src/src/apps/filters/h3ToComponents.c +1 -0
- data/ext/h3/src/src/apps/filters/h3ToGeo.c +1 -0
- data/ext/h3/src/src/apps/filters/h3ToGeoBoundary.c +1 -0
- data/ext/h3/src/src/apps/filters/h3ToLocalIj.c +1 -0
- data/ext/h3/src/src/apps/filters/hexRange.c +1 -0
- data/ext/h3/src/src/apps/filters/kRing.c +1 -0
- data/ext/h3/src/src/apps/filters/localIjToH3.c +1 -0
- data/ext/h3/src/src/apps/miscapps/generateBaseCellNeighbors.c +2 -2
- data/ext/h3/src/src/apps/miscapps/generateFaceCenterPoint.c +1 -0
- data/ext/h3/src/src/apps/miscapps/generateNumHexagons.c +1 -2
- data/ext/h3/src/src/apps/miscapps/generatePentagonDirectionFaces.c +67 -0
- data/ext/h3/src/src/apps/miscapps/h3ToGeoBoundaryHier.c +1 -0
- data/ext/h3/src/src/apps/miscapps/h3ToGeoHier.c +1 -0
- data/ext/h3/src/src/apps/miscapps/h3ToHier.c +1 -0
- data/ext/h3/src/src/apps/testapps/mkRandGeo.c +1 -0
- data/ext/h3/src/src/apps/testapps/mkRandGeoBoundary.c +1 -0
- data/ext/h3/src/src/apps/testapps/testBBox.c +1 -0
- data/ext/h3/src/src/apps/testapps/testBaseCells.c +15 -1
- data/ext/h3/src/src/apps/testapps/testCompact.c +121 -2
- data/ext/h3/src/src/apps/testapps/testCoordIj.c +1 -0
- data/ext/h3/src/src/apps/testapps/testGeoCoord.c +47 -8
- data/ext/h3/src/src/apps/testapps/testGeoToH3.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3Api.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3CellArea.c +47 -0
- data/ext/h3/src/src/apps/testapps/testH3CellAreaExhaustive.c +180 -0
- data/ext/h3/src/src/apps/testapps/testH3Distance.c +2 -50
- data/ext/h3/src/src/apps/testapps/testH3DistanceExhaustive.c +84 -0
- data/ext/h3/src/src/apps/testapps/testH3GetFaces.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3Index.c +33 -3
- data/ext/h3/src/src/apps/testapps/testH3Line.c +2 -84
- data/ext/h3/src/src/apps/testapps/testH3LineExhaustive.c +115 -0
- data/ext/h3/src/src/apps/testapps/testH3Memory.c +175 -0
- data/ext/h3/src/src/apps/testapps/testH3NeighborRotations.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3SetToLinkedGeo.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3SetToVertexGraph.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3ToCenterChild.c +68 -0
- data/ext/h3/src/src/apps/testapps/testH3ToChildren.c +15 -2
- data/ext/h3/src/src/apps/testapps/testH3ToGeo.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3ToGeoBoundary.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3ToLocalIj.c +24 -236
- data/ext/h3/src/src/apps/testapps/testH3ToLocalIjExhaustive.c +265 -0
- data/ext/h3/src/src/apps/testapps/testH3ToParent.c +1 -0
- data/ext/h3/src/src/apps/testapps/testH3UniEdge.c +45 -16
- data/ext/h3/src/src/apps/testapps/testH3UniEdgeExhaustive.c +111 -0
- data/ext/h3/src/src/apps/testapps/testHexRanges.c +1 -0
- data/ext/h3/src/src/apps/testapps/testHexRing.c +1 -0
- data/ext/h3/src/src/apps/testapps/testKRing.c +1 -0
- data/ext/h3/src/src/apps/testapps/testLinkedGeo.c +1 -0
- data/ext/h3/src/src/apps/testapps/testMaxH3ToChildrenSize.c +1 -0
- data/ext/h3/src/src/apps/testapps/testPentagonIndexes.c +58 -0
- data/ext/h3/src/src/apps/testapps/testPolyfill.c +72 -9
- data/ext/h3/src/src/apps/testapps/testPolyfillReported.c +157 -0
- data/ext/h3/src/src/apps/testapps/testPolygon.c +27 -1
- data/ext/h3/src/src/apps/testapps/testVec2d.c +1 -0
- data/ext/h3/src/src/apps/testapps/testVec3d.c +1 -0
- data/ext/h3/src/src/apps/testapps/testVertex.c +66 -0
- data/ext/h3/src/src/apps/testapps/testVertexGraph.c +1 -0
- data/ext/h3/src/src/h3lib/include/algos.h +8 -0
- data/ext/h3/src/src/h3lib/include/alloc.h +40 -0
- data/ext/h3/src/src/h3lib/include/baseCells.h +4 -0
- data/ext/h3/src/src/h3lib/include/bbox.h +4 -1
- data/ext/h3/src/src/h3lib/include/constants.h +2 -0
- data/ext/h3/src/src/h3lib/include/faceijk.h +3 -2
- data/ext/h3/src/src/h3lib/include/geoCoord.h +2 -3
- data/ext/h3/src/src/h3lib/include/h3Index.h +37 -4
- data/ext/h3/src/src/h3lib/include/h3api.h.in +85 -17
- data/ext/h3/src/src/h3lib/include/linkedGeo.h +1 -0
- data/ext/h3/src/src/h3lib/include/polygon.h +1 -0
- data/ext/h3/src/src/h3lib/include/polygonAlgos.h +1 -0
- data/ext/h3/src/src/h3lib/include/vertex.h +44 -0
- data/ext/h3/src/src/h3lib/include/vertexGraph.h +1 -0
- data/ext/h3/src/src/h3lib/lib/algos.c +305 -80
- data/ext/h3/src/src/h3lib/lib/baseCells.c +26 -4
- data/ext/h3/src/src/h3lib/lib/bbox.c +56 -27
- data/ext/h3/src/src/h3lib/lib/coordijk.c +2 -0
- data/ext/h3/src/src/h3lib/lib/faceijk.c +35 -24
- data/ext/h3/src/src/h3lib/lib/geoCoord.c +162 -44
- data/ext/h3/src/src/h3lib/lib/h3Index.c +150 -46
- data/ext/h3/src/src/h3lib/lib/h3UniEdge.c +42 -57
- data/ext/h3/src/src/h3lib/lib/linkedGeo.c +20 -15
- data/ext/h3/src/src/h3lib/lib/localij.c +5 -5
- data/ext/h3/src/src/h3lib/lib/polygon.c +3 -2
- data/ext/h3/src/src/h3lib/lib/vec2d.c +1 -0
- data/ext/h3/src/src/h3lib/lib/vec3d.c +1 -0
- data/ext/h3/src/src/h3lib/lib/vertex.c +134 -0
- data/ext/h3/src/src/h3lib/lib/vertexGraph.c +8 -5
- data/ext/h3/src/website/.eslintignore +2 -0
- data/ext/h3/src/website/.gitignore +57 -0
- data/ext/h3/src/website/.nvmrc +1 -0
- data/ext/h3/src/website/README.md +8 -6
- data/ext/h3/src/website/gatsby-config.js +83 -0
- data/ext/h3/src/website/package.json +20 -12
- data/ext/h3/src/website/scripts/build-to-gh-pages.sh +7 -5
- data/ext/h3/src/website/src/.gitkeep +0 -0
- data/ext/h3/src/website/templates/documentation.jsx +129 -0
- data/ext/h3/src/website/yarn.lock +13723 -0
- data/h3.gemspec +1 -0
- data/lib/h3.rb +8 -23
- data/lib/h3/bindings/base.rb +15 -4
- data/lib/h3/bindings/private.rb +13 -9
- data/lib/h3/geo_json.rb +1 -1
- data/lib/h3/hierarchy.rb +24 -9
- data/lib/h3/indexing.rb +7 -7
- data/lib/h3/inspection.rb +22 -26
- data/lib/h3/miscellaneous.rb +157 -9
- data/lib/h3/regions.rb +3 -0
- data/lib/h3/traversal.rb +9 -9
- data/lib/h3/unidirectional_edges.rb +18 -18
- data/lib/h3/version.rb +1 -1
- data/spec/geo_json_spec.rb +8 -0
- data/spec/hierarchy_spec.rb +23 -13
- data/spec/indexing_spec.rb +15 -15
- data/spec/inspection_spec.rb +17 -17
- data/spec/miscellaneous_spec.rb +151 -6
- data/spec/{region_spec.rb → regions_spec.rb} +1 -1
- data/spec/traversal_spec.rb +6 -6
- data/spec/unidirectional_edges_spec.rb +18 -18
- metadata +55 -15
- data/ext/h3/src/.ycm_extra_conf.py +0 -92
- data/ext/h3/src/appveyor.yml +0 -50
- data/ext/h3/src/website/src/config.js +0 -46
- data/ext/h3/src/website/src/mdRoutes.js +0 -151
- data/ext/h3/src/website/src/styles/_variables.scss +0 -16
- data/ext/h3/src/website/src/styles/index.scss +0 -3
- data/ext/h3/src/website/static/index.html +0 -15
- data/lib/h3/bindings.rb +0 -12
data/lib/h3/regions.rb
CHANGED
@@ -141,6 +141,7 @@ module H3
|
|
141
141
|
linked_geo_polygon = LinkedGeoPolygon.new
|
142
142
|
Bindings::Private.h3_set_to_linked_geo(h3_set, h3_indexes.size, linked_geo_polygon)
|
143
143
|
|
144
|
+
# The algorithm in h3 currently only handles 1 polygon
|
144
145
|
extract_linked_geo_polygon(linked_geo_polygon).first
|
145
146
|
ensure
|
146
147
|
Bindings::Private.destroy_linked_polygon(linked_geo_polygon)
|
@@ -154,6 +155,8 @@ module H3
|
|
154
155
|
geo_polygons = [linked_geo_polygon]
|
155
156
|
|
156
157
|
until linked_geo_polygon[:next].null?
|
158
|
+
# Until the h3 algorithm is updated to handle multiple polygons,
|
159
|
+
# this block will never run.
|
157
160
|
geo_polygons << linked_geo_polygon[:next]
|
158
161
|
linked_geo_polygon = linked_geo_polygon[:next]
|
159
162
|
end
|
data/lib/h3/traversal.rb
CHANGED
@@ -18,7 +18,7 @@ module H3
|
|
18
18
|
# @return [Integer] Maximum k-ring size.
|
19
19
|
attach_function :max_kring_size, :maxKringSize, %i[k_distance], :int
|
20
20
|
|
21
|
-
# @!method
|
21
|
+
# @!method distance(origin, h3_index)
|
22
22
|
#
|
23
23
|
# Derive the distance between two H3 indexes.
|
24
24
|
#
|
@@ -26,13 +26,13 @@ module H3
|
|
26
26
|
# @param [Integer] h3_index H3 index
|
27
27
|
#
|
28
28
|
# @example Derive the distance between two H3 indexes.
|
29
|
-
# H3.
|
29
|
+
# H3.distance(617700169983721471, 617700169959866367)
|
30
30
|
# 5
|
31
31
|
#
|
32
32
|
# @return [Integer] Distance between indexes.
|
33
|
-
attach_function :
|
33
|
+
attach_function :distance, :h3Distance, %i[h3_index h3_index], :k_distance
|
34
34
|
|
35
|
-
# @!method
|
35
|
+
# @!method line_size(origin, destination)
|
36
36
|
#
|
37
37
|
# Derive the number of hexagons present in a line between two H3 indexes.
|
38
38
|
#
|
@@ -45,11 +45,11 @@ module H3
|
|
45
45
|
# @param [Integer] destination H3 index
|
46
46
|
#
|
47
47
|
# @example Derive the number of hexagons present in a line between two H3 indexes.
|
48
|
-
# H3.
|
48
|
+
# H3.line_size(617700169983721471, 617700169959866367)
|
49
49
|
# 6
|
50
50
|
#
|
51
51
|
# @return [Integer] Number of hexagons found between indexes.
|
52
|
-
attach_function :
|
52
|
+
attach_function :line_size, :h3LineSize, %i[h3_index h3_index], :int
|
53
53
|
|
54
54
|
# Derives H3 indexes within k distance of the origin H3 index.
|
55
55
|
#
|
@@ -288,7 +288,7 @@ module H3
|
|
288
288
|
# @param [Integer] destination Destination H3 index.
|
289
289
|
#
|
290
290
|
# @example Derive the indexes found in a line.
|
291
|
-
# H3.
|
291
|
+
# H3.line(617700169983721471, 617700169959866367)
|
292
292
|
# [
|
293
293
|
# 617700169983721471, 617700169984245759, 617700169988177919,
|
294
294
|
# 617700169986867199, 617700169987391487, 617700169959866367
|
@@ -297,8 +297,8 @@ module H3
|
|
297
297
|
# @raise [ArgumentError] Could not compute line
|
298
298
|
#
|
299
299
|
# @return [Array<Integer>] H3 indexes
|
300
|
-
def
|
301
|
-
max_hexagons =
|
300
|
+
def line(origin, destination)
|
301
|
+
max_hexagons = line_size(origin, destination)
|
302
302
|
hexagons = H3Indexes.of_size(max_hexagons)
|
303
303
|
res = Bindings::Private.h3_line(origin, destination, hexagons)
|
304
304
|
raise(ArgumentError, "Could not compute line") if res.negative?
|
@@ -5,7 +5,7 @@ module H3
|
|
5
5
|
module UnidirectionalEdges
|
6
6
|
extend H3::Bindings::Base
|
7
7
|
|
8
|
-
# @!method
|
8
|
+
# @!method neighbors?(origin, destination)
|
9
9
|
#
|
10
10
|
# Determine whether two H3 indexes are neighbors.
|
11
11
|
#
|
@@ -13,29 +13,29 @@ module H3
|
|
13
13
|
# @param [Integer] destination Destination H3 index
|
14
14
|
#
|
15
15
|
# @example Check two H3 indexes
|
16
|
-
# H3.
|
16
|
+
# H3.neighbors?(617700169958293503, 617700169958031359)
|
17
17
|
# true
|
18
18
|
#
|
19
19
|
# @return [Boolean] True if indexes are neighbors
|
20
|
-
|
20
|
+
attach_predicate_function :neighbors?, :h3IndexesAreNeighbors, %i[h3_index h3_index], :bool
|
21
21
|
|
22
|
-
# @!method
|
22
|
+
# @!method unidirectional_edge_valid?(h3_index)
|
23
23
|
#
|
24
24
|
# Determine whether the given H3 index represents an edge.
|
25
25
|
#
|
26
26
|
# @param [Integer] h3_index H3 index
|
27
27
|
#
|
28
28
|
# @example Check if H3 index is a valid unidirectional edge.
|
29
|
-
# H3.
|
29
|
+
# H3.unidirectional_edge_valid?(1266218516299644927)
|
30
30
|
# true
|
31
31
|
#
|
32
32
|
# @return [Boolean] True if H3 index is a valid unidirectional edge
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
attach_predicate_function :unidirectional_edge_valid?,
|
34
|
+
:h3UnidirectionalEdgeIsValid,
|
35
|
+
%i[h3_index],
|
36
|
+
:bool
|
37
37
|
|
38
|
-
# @!method
|
38
|
+
# @!method unidirectional_edge(origin, destination)
|
39
39
|
#
|
40
40
|
# Derives the H3 index of the edge from the given H3 indexes.
|
41
41
|
#
|
@@ -43,11 +43,11 @@ module H3
|
|
43
43
|
# @param [Integer] destination H3 index
|
44
44
|
#
|
45
45
|
# @example Derive the H3 edge index between two H3 indexes
|
46
|
-
# H3.
|
46
|
+
# H3.unidirectional_edge(617700169958293503, 617700169958031359)
|
47
47
|
# 1626506486489284607
|
48
48
|
#
|
49
49
|
# @return [Integer] H3 edge index
|
50
|
-
attach_function :
|
50
|
+
attach_function :unidirectional_edge,
|
51
51
|
:getH3UnidirectionalEdge,
|
52
52
|
%i[h3_index h3_index],
|
53
53
|
:h3_index
|
@@ -93,11 +93,11 @@ module H3
|
|
93
93
|
# @param [Integer] edge H3 edge index
|
94
94
|
#
|
95
95
|
# @example Get origin and destination indexes from edge
|
96
|
-
# H3.
|
96
|
+
# H3.origin_and_destination_from_unidirectional_edge(1266218516299644927)
|
97
97
|
# [617700169958293503, 617700169961177087]
|
98
98
|
#
|
99
99
|
# @return [Array<Integer>] H3 index array.
|
100
|
-
def
|
100
|
+
def origin_and_destination_from_unidirectional_edge(edge)
|
101
101
|
max_hexagons = 2
|
102
102
|
out = H3Indexes.of_size(max_hexagons)
|
103
103
|
Bindings::Private.h3_indexes_from_unidirectional_edge(edge, out)
|
@@ -109,14 +109,14 @@ module H3
|
|
109
109
|
# @param [Integer] origin H3 index
|
110
110
|
#
|
111
111
|
# @example Get unidirectional indexes from hexagon
|
112
|
-
# H3.
|
112
|
+
# H3.unidirectional_edges_from_hexagon(612933930963697663)
|
113
113
|
# [
|
114
114
|
# 1261452277305049087, 1333509871342977023, 1405567465380904959,
|
115
115
|
# 1477625059418832895, 1549682653456760831, 1621740247494688767
|
116
116
|
# ]
|
117
117
|
#
|
118
118
|
# @return [Array<Integer>] H3 index array.
|
119
|
-
def
|
119
|
+
def unidirectional_edges_from_hexagon(origin)
|
120
120
|
max_edges = 6
|
121
121
|
out = H3Indexes.of_size(max_edges)
|
122
122
|
Bindings::Private.h3_unidirectional_edges_from_hexagon(origin, out)
|
@@ -128,7 +128,7 @@ module H3
|
|
128
128
|
# @param [Integer] edge H3 edge index
|
129
129
|
#
|
130
130
|
# @example
|
131
|
-
# H3.
|
131
|
+
# H3.unidirectional_edge_boundary(612933930963697663)
|
132
132
|
# [
|
133
133
|
# [68.92995788193981, 31.831280499087402], [69.39359648991828, 62.345344956509784],
|
134
134
|
# [76.163042830191, 94.14309010184775], [87.36469532319619, 145.5581976913368],
|
@@ -136,7 +136,7 @@ module H3
|
|
136
136
|
# ]
|
137
137
|
#
|
138
138
|
# @return [Array<Array<Float>>] Edge boundary coordinates for a hexagon
|
139
|
-
def
|
139
|
+
def unidirectional_edge_boundary(edge)
|
140
140
|
geo_boundary = GeoBoundary.new
|
141
141
|
Bindings::Private.h3_unidirectional_edge_boundary(edge, geo_boundary)
|
142
142
|
geo_boundary[:verts].take(geo_boundary[:num_verts]).map do |d|
|
data/lib/h3/version.rb
CHANGED
data/spec/geo_json_spec.rb
CHANGED
@@ -60,6 +60,14 @@ RSpec.describe H3 do
|
|
60
60
|
expect { geo_json_to_coordinates }.to raise_error(ArgumentError)
|
61
61
|
end
|
62
62
|
end
|
63
|
+
|
64
|
+
context "when given JSON with the wrong structure" do
|
65
|
+
let(:input) { { blah: "blah" }.to_json }
|
66
|
+
|
67
|
+
it "raises an error" do
|
68
|
+
expect { geo_json_to_coordinates }.to raise_error(ArgumentError)
|
69
|
+
end
|
70
|
+
end
|
63
71
|
end
|
64
72
|
|
65
73
|
describe ".coordinates_to_geo_json" do
|
data/spec/hierarchy_spec.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
RSpec.describe H3 do
|
2
2
|
include_context "constants"
|
3
3
|
|
4
|
-
describe ".
|
4
|
+
describe ".parent" do
|
5
5
|
let(:h3_index) { "89283082993ffff".to_i(16) }
|
6
6
|
let(:parent_resolution) { 8 }
|
7
7
|
let(:result) { "8828308299fffff".to_i(16) }
|
8
8
|
|
9
|
-
subject(:
|
9
|
+
subject(:parent) { H3.parent(h3_index, parent_resolution) }
|
10
10
|
|
11
11
|
it { is_expected.to eq(result) }
|
12
12
|
end
|
13
13
|
|
14
|
-
describe ".
|
14
|
+
describe ".children" do
|
15
15
|
let(:h3_index) { "8928308280fffff".to_i(16) }
|
16
16
|
|
17
|
-
subject(:
|
17
|
+
subject(:children) { H3.children(h3_index, child_resolution) }
|
18
18
|
|
19
19
|
context "when resolution is 3" do
|
20
20
|
let(:child_resolution) { 3 }
|
21
21
|
let(:count) { 0 }
|
22
22
|
|
23
23
|
it "has 0 children" do
|
24
|
-
expect(
|
24
|
+
expect(children.count).to eq count
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -31,11 +31,11 @@ RSpec.describe H3 do
|
|
31
31
|
let(:expected) { "8928308280fffff".to_i(16) }
|
32
32
|
|
33
33
|
it "has 1 child" do
|
34
|
-
expect(
|
34
|
+
expect(children.count).to eq count
|
35
35
|
end
|
36
36
|
|
37
37
|
it "is the expected value" do
|
38
|
-
expect(
|
38
|
+
expect(children.first).to eq expected
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -44,7 +44,7 @@ RSpec.describe H3 do
|
|
44
44
|
let(:count) { 7 }
|
45
45
|
|
46
46
|
it "has 7 children" do
|
47
|
-
expect(
|
47
|
+
expect(children.count).to eq count
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -53,7 +53,7 @@ RSpec.describe H3 do
|
|
53
53
|
let(:count) { 117649 }
|
54
54
|
|
55
55
|
it "has 117649 children" do
|
56
|
-
expect(
|
56
|
+
expect(children.count).to eq count
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -61,7 +61,7 @@ RSpec.describe H3 do
|
|
61
61
|
let(:child_resolution) { -1 }
|
62
62
|
|
63
63
|
it "raises an error" do
|
64
|
-
expect {
|
64
|
+
expect { children }.to raise_error(ArgumentError)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -69,15 +69,15 @@ RSpec.describe H3 do
|
|
69
69
|
let(:child_resolution) { 16 }
|
70
70
|
|
71
71
|
it "raises an error" do
|
72
|
-
expect {
|
72
|
+
expect { children }.to raise_error(ArgumentError)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
describe ".
|
77
|
+
describe ".max_children" do
|
78
78
|
let(:h3_index) { "8928308280fffff".to_i(16) }
|
79
79
|
|
80
|
-
subject(:
|
80
|
+
subject(:max_children) { H3.max_children(h3_index, child_resolution) }
|
81
81
|
|
82
82
|
context "when resolution is 3" do
|
83
83
|
let(:child_resolution) { 3 }
|
@@ -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/indexing_spec.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
RSpec.describe H3 do
|
2
2
|
include_context "constants"
|
3
3
|
|
4
|
-
describe ".
|
4
|
+
describe ".from_geo_coordinates" do
|
5
5
|
let(:resolution) { 8 }
|
6
6
|
let(:coords) { [53.959130, -1.079230]}
|
7
7
|
let(:result) { valid_h3_index }
|
8
8
|
|
9
|
-
subject(:
|
9
|
+
subject(:from_geo_coordinates) { H3.from_geo_coordinates(coords, resolution) }
|
10
10
|
|
11
11
|
it { is_expected.to eq(result) }
|
12
12
|
|
@@ -14,7 +14,7 @@ RSpec.describe H3 do
|
|
14
14
|
let(:coords) { [1, 2, 3] }
|
15
15
|
|
16
16
|
it "raises an error" do
|
17
|
-
expect {
|
17
|
+
expect { from_geo_coordinates }.to raise_error(ArgumentError)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -22,7 +22,7 @@ RSpec.describe H3 do
|
|
22
22
|
let(:coords) { "boom" }
|
23
23
|
|
24
24
|
it "raises an error" do
|
25
|
-
expect {
|
25
|
+
expect { from_geo_coordinates }.to raise_error(ArgumentError)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -30,31 +30,31 @@ RSpec.describe H3 do
|
|
30
30
|
let(:coords) { [-1.1323222, 190.1020102] }
|
31
31
|
|
32
32
|
it "raises an error" do
|
33
|
-
expect {
|
33
|
+
expect { from_geo_coordinates }.to raise_error(ArgumentError)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
describe ".
|
38
|
+
describe ".to_geo_coordinates" do
|
39
39
|
let(:h3_index) { valid_h3_index }
|
40
40
|
let(:expected_lat) { 53.95860421941 }
|
41
41
|
let(:expected_lon) { -1.08119564709 }
|
42
42
|
|
43
|
-
subject(:
|
43
|
+
subject(:to_geo_coordinates) { H3.to_geo_coordinates(h3_index) }
|
44
44
|
|
45
45
|
it "should return the expected latitude" do
|
46
|
-
expect(
|
46
|
+
expect(to_geo_coordinates[0]).to be_within(0.000001).of(expected_lat)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should return the expected longitude" do
|
50
|
-
expect(
|
50
|
+
expect(to_geo_coordinates[1]).to be_within(0.000001).of(expected_lon)
|
51
51
|
end
|
52
52
|
|
53
53
|
context "when given an invalid h3_index" do
|
54
54
|
let(:h3_index) { "boom" }
|
55
55
|
|
56
56
|
it "raises an error" do
|
57
|
-
expect {
|
57
|
+
expect { to_geo_coordinates }.to raise_error(TypeError)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -62,12 +62,12 @@ RSpec.describe H3 do
|
|
62
62
|
let(:h3_index) { too_long_number }
|
63
63
|
|
64
64
|
it "raises an error" do
|
65
|
-
expect {
|
65
|
+
expect { to_geo_coordinates }.to raise_error(RangeError)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
describe ".
|
70
|
+
describe ".to_boundary" do
|
71
71
|
let(:h3_index) { "85283473fffffff".to_i(16) }
|
72
72
|
let(:expected) do
|
73
73
|
[
|
@@ -80,13 +80,13 @@ RSpec.describe H3 do
|
|
80
80
|
]
|
81
81
|
end
|
82
82
|
|
83
|
-
subject(:
|
83
|
+
subject(:to_boundary) { H3.to_boundary(h3_index) }
|
84
84
|
|
85
85
|
it "matches expected boundary coordinates" do
|
86
|
-
|
86
|
+
to_boundary.zip(expected) do |(lat, lon), (exp_lat, exp_lon)|
|
87
87
|
expect(lat).to be_within(0.000001).of(exp_lat)
|
88
88
|
expect(lon).to be_within(0.000001).of(exp_lon)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
92
|
-
end
|
92
|
+
end
|
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
|
|