h3 4.2.2__tar.gz → 4.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. {h3-4.2.2 → h3-4.3.0}/CHANGELOG.md +4 -1
  2. {h3-4.2.2 → h3-4.3.0}/PKG-INFO +2 -2
  3. {h3-4.2.2 → h3-4.3.0}/pyproject.toml +1 -1
  4. {h3-4.2.2 → h3-4.3.0}/readme.md +1 -1
  5. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/cells.pyx +4 -40
  6. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/h3lib.pxd +1 -0
  7. {h3-4.2.2 → h3-4.3.0}/src/h3lib/CMakeLists.txt +2 -0
  8. h3-4.3.0/src/h3lib/VERSION +1 -0
  9. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/algos.h +3 -0
  10. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/h3api.h.in +9 -3
  11. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/algos.c +101 -2
  12. h3-4.2.2/src/h3lib/VERSION +0 -1
  13. {h3-4.2.2 → h3-4.3.0}/.github/workflows/build_docs.yml +0 -0
  14. {h3-4.2.2 → h3-4.3.0}/.github/workflows/lint_and_coverage.yml +0 -0
  15. {h3-4.2.2 → h3-4.3.0}/.github/workflows/tests.yml +0 -0
  16. {h3-4.2.2 → h3-4.3.0}/.github/workflows/wheels.yml +0 -0
  17. {h3-4.2.2 → h3-4.3.0}/.gitignore +0 -0
  18. {h3-4.2.2 → h3-4.3.0}/.gitmodules +0 -0
  19. {h3-4.2.2 → h3-4.3.0}/CMakeLists.txt +0 -0
  20. {h3-4.2.2 → h3-4.3.0}/LICENSE +0 -0
  21. {h3-4.2.2 → h3-4.3.0}/src/h3/CMakeLists.txt +0 -0
  22. {h3-4.2.2 → h3-4.3.0}/src/h3/__init__.py +0 -0
  23. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/CMakeLists.txt +0 -0
  24. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/__init__.py +0 -0
  25. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/cells.pxd +0 -0
  26. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/edges.pxd +0 -0
  27. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/edges.pyx +0 -0
  28. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/error_system.pxd +0 -0
  29. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/error_system.pyx +0 -0
  30. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/latlng.pxd +0 -0
  31. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/latlng.pyx +0 -0
  32. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/memory.pxd +0 -0
  33. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/memory.pyx +0 -0
  34. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/to_multipoly.pyx +0 -0
  35. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/util.pxd +0 -0
  36. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/util.pyx +0 -0
  37. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/vertex.pxd +0 -0
  38. {h3-4.2.2 → h3-4.3.0}/src/h3/_cy/vertex.pyx +0 -0
  39. {h3-4.2.2 → h3-4.3.0}/src/h3/_h3shape.py +0 -0
  40. {h3-4.2.2 → h3-4.3.0}/src/h3/_version.py +0 -0
  41. {h3-4.2.2 → h3-4.3.0}/src/h3/api/__init__.py +0 -0
  42. {h3-4.2.2 → h3-4.3.0}/src/h3/api/basic_int/__init__.py +0 -0
  43. {h3-4.2.2 → h3-4.3.0}/src/h3/api/basic_int/_convert.py +0 -0
  44. {h3-4.2.2 → h3-4.3.0}/src/h3/api/basic_str/__init__.py +0 -0
  45. {h3-4.2.2 → h3-4.3.0}/src/h3/api/basic_str/_convert.py +0 -0
  46. {h3-4.2.2 → h3-4.3.0}/src/h3/api/memview_int/__init__.py +0 -0
  47. {h3-4.2.2 → h3-4.3.0}/src/h3/api/memview_int/_convert.py +0 -0
  48. {h3-4.2.2 → h3-4.3.0}/src/h3/api/numpy_int/__init__.py +0 -0
  49. {h3-4.2.2 → h3-4.3.0}/src/h3/api/numpy_int/_convert.py +0 -0
  50. {h3-4.2.2 → h3-4.3.0}/src/h3lib/LICENSE +0 -0
  51. {h3-4.2.2 → h3-4.3.0}/src/h3lib/README.md +0 -0
  52. {h3-4.2.2 → h3-4.3.0}/src/h3lib/cmake/Config.cmake.in +0 -0
  53. {h3-4.2.2 → h3-4.3.0}/src/h3lib/cmake/TestWrapValgrind.cmake +0 -0
  54. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/alloc.h +0 -0
  55. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/baseCells.h +0 -0
  56. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/bbox.h +0 -0
  57. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/constants.h +0 -0
  58. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/coordijk.h +0 -0
  59. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/directedEdge.h +0 -0
  60. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/faceijk.h +0 -0
  61. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/h3Assert.h +0 -0
  62. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/h3Index.h +0 -0
  63. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/iterators.h +0 -0
  64. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/latLng.h +0 -0
  65. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/linkedGeo.h +0 -0
  66. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/localij.h +0 -0
  67. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/mathExtensions.h +0 -0
  68. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/polyfill.h +0 -0
  69. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/polygon.h +0 -0
  70. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/polygonAlgos.h +0 -0
  71. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/vec2d.h +0 -0
  72. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/vec3d.h +0 -0
  73. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/vertex.h +0 -0
  74. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/include/vertexGraph.h +0 -0
  75. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/baseCells.c +0 -0
  76. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/bbox.c +0 -0
  77. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/coordijk.c +0 -0
  78. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/directedEdge.c +0 -0
  79. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/faceijk.c +0 -0
  80. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/h3Assert.c +0 -0
  81. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/h3Index.c +0 -0
  82. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/iterators.c +0 -0
  83. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/latLng.c +0 -0
  84. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/linkedGeo.c +0 -0
  85. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/localij.c +0 -0
  86. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/mathExtensions.c +0 -0
  87. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/polyfill.c +0 -0
  88. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/polygon.c +0 -0
  89. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/vec2d.c +0 -0
  90. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/vec3d.c +0 -0
  91. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/vertex.c +0 -0
  92. {h3-4.2.2 → h3-4.3.0}/src/h3lib/src/h3lib/lib/vertexGraph.c +0 -0
  93. {h3-4.2.2 → h3-4.3.0}/tests/readme.md +0 -0
  94. {h3-4.2.2 → h3-4.3.0}/tests/test_cython/__init__.py +0 -0
  95. {h3-4.2.2 → h3-4.3.0}/tests/test_cython/cython_example.pyx +0 -0
  96. {h3-4.2.2 → h3-4.3.0}/tests/test_cython/test_cython.py +0 -0
  97. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/__init__.py +0 -0
  98. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/polyfill/__init__.py +0 -0
  99. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/polyfill/test_h3.py +0 -0
  100. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/polyfill/test_polyfill.py +0 -0
  101. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/polyfill/test_polyfill_ordering.py +0 -0
  102. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/polyfill/test_polygon_class.py +0 -0
  103. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/polyfill/test_to_multipoly.py +0 -0
  104. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/test_apis/__init__.py +0 -0
  105. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/test_apis/test_api_bindings_match.py +0 -0
  106. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/test_apis/test_basic_int.py +0 -0
  107. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/test_apis/test_basic_str.py +0 -0
  108. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/test_apis/test_collection_inputs.py +0 -0
  109. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/test_apis/test_ico_faces.py +0 -0
  110. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/test_apis/test_memview_int.py +0 -0
  111. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/test_apis/test_numpy_int.py +0 -0
  112. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/test_cells_and_edges.py +0 -0
  113. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/test_error_codes.py +0 -0
  114. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/test_h3.py +0 -0
  115. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/test_length_area.py +0 -0
  116. {h3-4.2.2 → h3-4.3.0}/tests/test_lib/util.py +0 -0
@@ -16,7 +16,10 @@ avoid adding features or APIs which do not map onto the
16
16
 
17
17
  ## Unreleased
18
18
 
19
- None.
19
+ ## [4.3.0] - 2025-06-17
20
+
21
+ - Update `h3lib` to v4.3.0. (#461)
22
+ - Uses `gridRing` (uber/h3#1016) instead of Cython fallback logic.
20
23
 
21
24
  ## [4.2.2] - 2025-03-10
22
25
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: h3
3
- Version: 4.2.2
3
+ Version: 4.3.0
4
4
  Summary: Uber's hierarchical hexagonal geospatial indexing system
5
5
  Author-Email: Uber Technologies <ajfriend@gmail.com>
6
6
  Maintainer-Email: AJ Friend <ajfriend@gmail.com>
@@ -257,7 +257,7 @@ Description-Content-Type: text/markdown
257
257
  [![PyPI version](https://badge.fury.io/py/h3.svg)](https://badge.fury.io/py/h3)
258
258
  [![PyPI downloads](https://img.shields.io/pypi/dm/h3.svg)](https://pypistats.org/packages/h3)
259
259
  [![conda](https://img.shields.io/conda/vn/conda-forge/h3-py.svg)](https://anaconda.org/conda-forge/h3-py)
260
- [![version](https://img.shields.io/badge/h3-v4.2.1-blue.svg)](https://github.com/uber/h3/releases/tag/v4.2.1)
260
+ [![version](https://img.shields.io/badge/h3-v4.3.0-blue.svg)](https://github.com/uber/h3/releases/tag/v4.3.0)
261
261
  [![version](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/uber/h3-py/blob/master/LICENSE)
262
262
 
263
263
  [![Tests](https://github.com/uber/h3-py/workflows/tests/badge.svg)](https://github.com/uber/h3-py/actions)
@@ -4,7 +4,7 @@ build-backend = 'scikit_build_core.build'
4
4
 
5
5
  [project]
6
6
  name = 'h3'
7
- version = '4.2.2'
7
+ version = '4.3.0'
8
8
  description = "Uber's hierarchical hexagonal geospatial indexing system"
9
9
  readme = 'readme.md'
10
10
  license = {file = 'LICENSE'}
@@ -5,7 +5,7 @@
5
5
  [![PyPI version](https://badge.fury.io/py/h3.svg)](https://badge.fury.io/py/h3)
6
6
  [![PyPI downloads](https://img.shields.io/pypi/dm/h3.svg)](https://pypistats.org/packages/h3)
7
7
  [![conda](https://img.shields.io/conda/vn/conda-forge/h3-py.svg)](https://anaconda.org/conda-forge/h3-py)
8
- [![version](https://img.shields.io/badge/h3-v4.2.1-blue.svg)](https://github.com/uber/h3/releases/tag/v4.2.1)
8
+ [![version](https://img.shields.io/badge/h3-v4.3.0-blue.svg)](https://github.com/uber/h3/releases/tag/v4.3.0)
9
9
  [![version](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/uber/h3-py/blob/master/LICENSE)
10
10
 
11
11
  [![Tests](https://github.com/uber/h3-py/workflows/tests/badge.svg)](https://github.com/uber/h3-py/actions)
@@ -87,41 +87,6 @@ cpdef H3int[:] grid_disk(H3int h, int k):
87
87
  return mv
88
88
 
89
89
 
90
- cpdef H3int[:] _ring_fallback(H3int h, int k):
91
- """
92
- `ring` tries to call `h3lib.hexRing` first; if that fails, we call
93
- this function, which relies on `h3lib.kRingDistances`.
94
-
95
- Failures for `h3lib.hexRing` happen when the algorithm runs into a pentagon.
96
- """
97
- cdef:
98
- int64_t n
99
- int[:] distances ## todo: weird, this needs to be specified to avoid errors. cython bug?
100
-
101
- check_cell(h)
102
- check_distance(k)
103
-
104
- check_for_error(
105
- h3lib.maxGridDiskSize(k, &n)
106
- )
107
- hmm = H3MemoryManager(n)
108
-
109
- # parallel array of cell distances from `h`.
110
- # idea: instead of a memoryview object, have a my_mv object that can return a ptr, but does the correct logic when it has length 0
111
- # then can always just return the pointer, instead of the weird &mv[0] syntax
112
- distances = int_mv(n)
113
- check_for_error(
114
- h3lib.gridDiskDistances(h, k, hmm.ptr, &distances[0])
115
- )
116
-
117
- for i,v in enumerate(distances):
118
- if v != k:
119
- hmm.ptr[i] = 0
120
-
121
- mv = hmm.to_mv()
122
-
123
- return mv
124
-
125
90
  cpdef H3int[:] grid_ring(H3int h, int k):
126
91
  """ Return cells at grid distance `== k` from `h`.
127
92
  Collection is "hollow" for k >= 1.
@@ -131,11 +96,10 @@ cpdef H3int[:] grid_ring(H3int h, int k):
131
96
 
132
97
  n = 6*k if k > 0 else 1
133
98
  hmm = H3MemoryManager(n)
134
- err = h3lib.gridRingUnsafe(h, k, hmm.ptr)
135
- if err:
136
- mv = _ring_fallback(h, k)
137
- else:
138
- mv = hmm.to_mv()
99
+ check_for_error(
100
+ h3lib.gridRing(h, k, hmm.ptr)
101
+ )
102
+ mv = hmm.to_mv()
139
103
 
140
104
  return mv
141
105
 
@@ -139,6 +139,7 @@ cdef extern from 'h3api.h':
139
139
  H3Error localIjToCell(H3int origin, const CoordIJ *ij, uint32_t mode, H3int *out) nogil
140
140
 
141
141
  H3Error gridDiskDistances(H3int origin, int k, H3int *out, int *distances) nogil
142
+ H3Error gridRing(H3int origin, int k, H3int *out) nogil
142
143
  H3Error gridRingUnsafe(H3int origin, int k, H3int *out) nogil
143
144
 
144
145
  H3Error areNeighborCells(H3int origin, H3int destination, int *out) nogil
@@ -242,6 +242,8 @@ set(OTHER_SOURCE_FILES
242
242
  src/apps/testapps/testGetIcosahedronFaces.c
243
243
  src/apps/testapps/testLatLng.c
244
244
  src/apps/testapps/testLatLngInternal.c
245
+ src/apps/testapps/testGridRing.c
246
+ src/apps/testapps/testGridRingInternal.c
245
247
  src/apps/testapps/testGridRingUnsafe.c
246
248
  src/apps/testapps/testH3SetToVertexGraphInternal.c
247
249
  src/apps/testapps/testBBoxInternal.c
@@ -0,0 +1 @@
1
+ 4.3.0
@@ -53,4 +53,7 @@ H3Error _getEdgeHexagons(const GeoLoop *geoloop, int64_t numHexagons, int res,
53
53
  // The safe gridDiskDistances algorithm.
54
54
  H3Error _gridDiskDistancesInternal(H3Index origin, int k, H3Index *out,
55
55
  int *distances, int64_t maxIdx, int curK);
56
+
57
+ // The safe gridRing algorithm.
58
+ H3Error _gridRingInternal(H3Index origin, int k, H3Index *out);
56
59
  #endif
@@ -282,12 +282,18 @@ DECLSPEC H3Error H3_EXPORT(gridDiskDistances)(H3Index origin, int k,
282
282
  H3Index *out, int *distances);
283
283
  /** @} */
284
284
 
285
- /** @defgroup gridRingUnsafe gridRingUnsafe
286
- * Functions for gridRingUnsafe
285
+ /** @defgroup gridRing gridRing
286
+ * Functions for gridRing
287
287
  * @{
288
288
  */
289
- /** @brief hollow hexagon ring at some origin */
289
+ /** @brief maximum number of hexagons in hollow k-ring */
290
+ DECLSPEC H3Error H3_EXPORT(maxGridRingSize)(int k, int64_t *out);
291
+
292
+ /** @brief hollow hexagon ring k distance from origin */
290
293
  DECLSPEC H3Error H3_EXPORT(gridRingUnsafe)(H3Index origin, int k, H3Index *out);
294
+
295
+ /** @brief hollow hexagon ring k distance from origin */
296
+ DECLSPEC H3Error H3_EXPORT(gridRing)(H3Index origin, int k, H3Index *out);
291
297
  /** @} */
292
298
 
293
299
  /** @defgroup polygonToCells polygonToCells
@@ -334,6 +334,103 @@ H3Error H3_EXPORT(gridDiskDistancesSafe)(H3Index origin, int k, H3Index *out,
334
334
  return _gridDiskDistancesInternal(origin, k, out, distances, maxIdx, 0);
335
335
  }
336
336
 
337
+ /**
338
+ * Maximum number of cells that result from the gridRing algorithm with the
339
+ * given k.
340
+ *
341
+ * @param k k value, k >= 0.
342
+ * @param out size in indexes
343
+ */
344
+ H3Error H3_EXPORT(maxGridRingSize)(int k, int64_t *out) {
345
+ if (k < 0) {
346
+ return E_DOMAIN;
347
+ }
348
+ if (k == 0) {
349
+ *out = 1;
350
+ return E_SUCCESS;
351
+ }
352
+ *out = 6 * (int64_t)k;
353
+ return E_SUCCESS;
354
+ }
355
+
356
+ /**
357
+ * Returns the "hollow" ring of hexagons at exactly grid distance k from
358
+ * the origin hexagon. In particular, k=0 returns just the origin hexagon.
359
+ *
360
+ * Elements of the output array may be left zero, as can happen when crossing a
361
+ * pentagon.
362
+ *
363
+ * @param origin Origin location.
364
+ * @param k k >= 0
365
+ * @param out Array which must be of size 6 * k (or 1 if k == 0)
366
+ * @return 0 if successful; nonzero otherwise.
367
+ */
368
+ H3Error H3_EXPORT(gridRing)(H3Index origin, int k, H3Index *out) {
369
+ // Optimistically try the faster gridDiskUnsafe algorithm first
370
+ const H3Error failed = H3_EXPORT(gridRingUnsafe)(origin, k, out);
371
+ if (!failed) {
372
+ return E_SUCCESS;
373
+ }
374
+ // Fast algo failed, fall back to slower, correct algo
375
+ // and also wipe out array because contents untrustworthy
376
+ memset(out, 0, 6 * k * sizeof(H3Index));
377
+ return _gridRingInternal(origin, k, out);
378
+ }
379
+
380
+ /**
381
+ * Internal algorithm for the safe but slow version of gridRing
382
+ *
383
+ * This function uses _gridDiskDistancesInternal to get all cells up to distance
384
+ * k, then filters those results to include only cells exactly at distance k.
385
+ *
386
+ * @param origin Origin cell.
387
+ * @param k Exact distance to filter for.
388
+ * @param out Array which must be of size 6 * k (or 1 if k == 0). This is where
389
+ * the final filtered results will be placed.
390
+ * @return H3Error indicating success or failure.
391
+ */
392
+ H3Error _gridRingInternal(H3Index origin, int k, H3Index *out) {
393
+ // Short-circuit on 'identity' ring
394
+ if (k == 0) {
395
+ out[0] = origin;
396
+ return E_SUCCESS;
397
+ }
398
+
399
+ int64_t maxIdx;
400
+ H3Error err = H3_EXPORT(maxGridDiskSize)(k, &maxIdx);
401
+ if (err) {
402
+ return err;
403
+ }
404
+
405
+ H3Index *disk_out = H3_MEMORY(calloc)(maxIdx, sizeof(H3Index));
406
+ if (!disk_out) {
407
+ return E_MEMORY_ALLOC;
408
+ }
409
+ int *disk_distances = H3_MEMORY(calloc)(maxIdx, sizeof(int));
410
+ if (!disk_distances) {
411
+ H3_MEMORY(free)(disk_out);
412
+ return E_MEMORY_ALLOC;
413
+ }
414
+
415
+ err = _gridDiskDistancesInternal(origin, k, disk_out, disk_distances,
416
+ maxIdx, 0);
417
+ if (err) {
418
+ H3_MEMORY(free)(disk_out);
419
+ H3_MEMORY(free)(disk_distances);
420
+ return err;
421
+ }
422
+
423
+ int current_idx = 0;
424
+ for (int64_t i = 0; i < maxIdx; ++i) {
425
+ if (disk_out[i] != 0 && disk_distances[i] == k) {
426
+ out[current_idx++] = disk_out[i];
427
+ }
428
+ }
429
+ H3_MEMORY(free)(disk_out);
430
+ H3_MEMORY(free)(disk_distances);
431
+ return E_SUCCESS;
432
+ }
433
+
337
434
  /**
338
435
  * Returns the hexagon index neighboring the origin, in the direction dir.
339
436
  *
@@ -690,6 +787,9 @@ H3Error H3_EXPORT(gridDisksUnsafe)(H3Index *h3Set, int length, int k,
690
787
  * @return 0 if successful; nonzero otherwise.
691
788
  */
692
789
  H3Error H3_EXPORT(gridRingUnsafe)(H3Index origin, int k, H3Index *out) {
790
+ if (k < 0) {
791
+ return E_DOMAIN;
792
+ }
693
793
  // Short-circuit on 'identity' ring
694
794
  if (k == 0) {
695
795
  out[0] = origin;
@@ -755,9 +855,8 @@ H3Error H3_EXPORT(gridRingUnsafe)(H3Index origin, int k, H3Index *out) {
755
855
  // failure.
756
856
  if (lastIndex != origin) {
757
857
  return E_PENTAGON;
758
- } else {
759
- return E_SUCCESS;
760
858
  }
859
+ return E_SUCCESS;
761
860
  }
762
861
 
763
862
  /**
@@ -1 +0,0 @@
1
- 4.2.1
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes