h3 3.6.0 → 3.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby_ci.yml +30 -0
  3. data/.rubocop.yml +1 -1
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +39 -0
  6. data/Gemfile.lock +6 -24
  7. data/LICENSE.md +1 -1
  8. data/README.md +2 -3
  9. data/ext/h3/src/.github/workflows/test-linux.yml +118 -0
  10. data/ext/h3/src/.github/workflows/test-macos.yml +42 -0
  11. data/ext/h3/src/.github/workflows/test-website.yml +32 -0
  12. data/ext/h3/src/.github/workflows/test-windows.yml +44 -0
  13. data/ext/h3/src/.gitignore +5 -0
  14. data/ext/h3/src/.travis.yml +20 -42
  15. data/ext/h3/src/CHANGELOG.md +57 -0
  16. data/ext/h3/src/CMakeLists.txt +135 -33
  17. data/ext/h3/src/CONTRIBUTING.md +1 -1
  18. data/ext/h3/src/README.md +61 -11
  19. data/ext/h3/src/RELEASE.md +3 -1
  20. data/ext/h3/src/VERSION +1 -1
  21. data/ext/h3/src/dev-docs/RFCs/rfc-template.md +21 -0
  22. data/ext/h3/src/dev-docs/RFCs/v4.0.0/error-handling-rfc.md +21 -0
  23. data/ext/h3/src/dev-docs/RFCs/v4.0.0/names_for_concepts_types_functions.md +276 -0
  24. data/ext/h3/src/dev-docs/RFCs/v4.0.0/overrideable-allocators-rfc.md +141 -0
  25. data/ext/h3/src/dev-docs/RFCs/v4.0.0/polyfill-modes-rfc.md +21 -0
  26. data/ext/h3/src/dev-docs/RFCs/v4.0.0/vertex-mode-rfc.md +50 -0
  27. data/ext/h3/src/dev-docs/build_windows.md +6 -1
  28. data/ext/h3/src/dev-docs/creating_bindings.md +3 -3
  29. data/ext/h3/src/dev-docs/custom_alloc.md +27 -0
  30. data/ext/h3/src/docs/{overview/mainpage.md → README.md} +2 -3
  31. data/ext/h3/src/docs/api/misc.md +76 -0
  32. data/ext/h3/src/docs/community/applications.md +1 -0
  33. data/ext/h3/src/docs/community/bindings.md +10 -0
  34. data/ext/h3/src/docs/community/tutorials.md +8 -3
  35. data/ext/h3/src/docs/core-library/coordsystems.md +5 -4
  36. data/ext/h3/src/docs/core-library/filters.md +8 -9
  37. data/ext/h3/src/docs/core-library/geoToH3desc.md +2 -3
  38. data/ext/h3/src/docs/core-library/h3ToGeoBoundaryDesc.md +4 -5
  39. data/ext/h3/src/docs/core-library/h3ToGeoDesc.md +3 -4
  40. data/ext/h3/src/docs/core-library/h3indexing.md +26 -17
  41. data/ext/h3/src/docs/core-library/overview.md +2 -3
  42. data/ext/h3/src/docs/core-library/restable.md +1 -2
  43. data/ext/h3/src/docs/core-library/usage.md +1 -2
  44. data/ext/h3/src/docs/table-of-contents.json +47 -0
  45. data/ext/h3/src/docs/{overview/usecases.md → usecases.md} +6 -11
  46. data/ext/h3/src/scripts/binding_functions.sh +1 -1
  47. data/ext/h3/src/scripts/coverage.sh.in +1 -1
  48. data/ext/h3/src/scripts/update_version.sh +2 -2
  49. data/ext/h3/src/src/apps/applib/include/args.h +1 -0
  50. data/ext/h3/src/src/apps/applib/include/test.h +1 -0
  51. data/ext/h3/src/src/apps/applib/include/utility.h +7 -1
  52. data/ext/h3/src/src/apps/applib/lib/args.c +2 -0
  53. data/ext/h3/src/src/apps/applib/lib/kml.c +2 -0
  54. data/ext/h3/src/src/apps/applib/lib/test.c +1 -0
  55. data/ext/h3/src/src/apps/applib/lib/utility.c +133 -2
  56. data/ext/h3/src/src/apps/benchmarks/benchmarkH3Api.c +1 -1
  57. data/ext/h3/src/{website/html.config.js → src/apps/benchmarks/benchmarkH3UniEdge.c} +15 -12
  58. data/ext/h3/src/src/apps/filters/h3ToComponents.c +1 -0
  59. data/ext/h3/src/src/apps/filters/h3ToGeo.c +1 -0
  60. data/ext/h3/src/src/apps/filters/h3ToGeoBoundary.c +1 -0
  61. data/ext/h3/src/src/apps/filters/h3ToLocalIj.c +1 -0
  62. data/ext/h3/src/src/apps/filters/hexRange.c +1 -0
  63. data/ext/h3/src/src/apps/filters/kRing.c +1 -0
  64. data/ext/h3/src/src/apps/filters/localIjToH3.c +1 -0
  65. data/ext/h3/src/src/apps/miscapps/generateFaceCenterPoint.c +1 -0
  66. data/ext/h3/src/src/apps/miscapps/generateNumHexagons.c +1 -0
  67. data/ext/h3/src/src/apps/miscapps/generatePentagonDirectionFaces.c +67 -0
  68. data/ext/h3/src/src/apps/miscapps/h3ToGeoBoundaryHier.c +1 -0
  69. data/ext/h3/src/src/apps/miscapps/h3ToGeoHier.c +1 -0
  70. data/ext/h3/src/src/apps/miscapps/h3ToHier.c +1 -0
  71. data/ext/h3/src/src/apps/testapps/mkRandGeo.c +1 -0
  72. data/ext/h3/src/src/apps/testapps/mkRandGeoBoundary.c +1 -0
  73. data/ext/h3/src/src/apps/testapps/testBBox.c +1 -0
  74. data/ext/h3/src/src/apps/testapps/testBaseCells.c +15 -1
  75. data/ext/h3/src/src/apps/testapps/testCompact.c +109 -2
  76. data/ext/h3/src/src/apps/testapps/testCoordIj.c +1 -0
  77. data/ext/h3/src/src/apps/testapps/testGeoCoord.c +47 -8
  78. data/ext/h3/src/src/apps/testapps/testGeoToH3.c +1 -0
  79. data/ext/h3/src/src/apps/testapps/testH3Api.c +1 -0
  80. data/ext/h3/src/src/apps/testapps/testH3CellArea.c +47 -0
  81. data/ext/h3/src/src/apps/testapps/testH3CellAreaExhaustive.c +180 -0
  82. data/ext/h3/src/src/apps/testapps/testH3Distance.c +1 -0
  83. data/ext/h3/src/src/apps/testapps/testH3DistanceExhaustive.c +1 -0
  84. data/ext/h3/src/src/apps/testapps/testH3GetFaces.c +1 -0
  85. data/ext/h3/src/src/apps/testapps/testH3Index.c +33 -3
  86. data/ext/h3/src/src/apps/testapps/testH3Line.c +1 -0
  87. data/ext/h3/src/src/apps/testapps/testH3LineExhaustive.c +1 -0
  88. data/ext/h3/src/src/apps/testapps/testH3Memory.c +175 -0
  89. data/ext/h3/src/src/apps/testapps/testH3NeighborRotations.c +1 -0
  90. data/ext/h3/src/src/apps/testapps/testH3SetToLinkedGeo.c +1 -0
  91. data/ext/h3/src/src/apps/testapps/testH3SetToVertexGraph.c +1 -0
  92. data/ext/h3/src/src/apps/testapps/testH3ToCenterChild.c +1 -0
  93. data/ext/h3/src/src/apps/testapps/testH3ToChildren.c +1 -0
  94. data/ext/h3/src/src/apps/testapps/testH3ToGeo.c +1 -0
  95. data/ext/h3/src/src/apps/testapps/testH3ToGeoBoundary.c +1 -0
  96. data/ext/h3/src/src/apps/testapps/testH3ToLocalIj.c +12 -6
  97. data/ext/h3/src/src/apps/testapps/testH3ToLocalIjExhaustive.c +1 -0
  98. data/ext/h3/src/src/apps/testapps/testH3ToParent.c +1 -0
  99. data/ext/h3/src/src/apps/testapps/testH3UniEdge.c +45 -16
  100. data/ext/h3/src/src/apps/testapps/testH3UniEdgeExhaustive.c +111 -0
  101. data/ext/h3/src/src/apps/testapps/testHexRanges.c +1 -0
  102. data/ext/h3/src/src/apps/testapps/testHexRing.c +1 -0
  103. data/ext/h3/src/src/apps/testapps/testKRing.c +19 -0
  104. data/ext/h3/src/src/apps/testapps/testLinkedGeo.c +1 -0
  105. data/ext/h3/src/src/apps/testapps/testMaxH3ToChildrenSize.c +1 -0
  106. data/ext/h3/src/src/apps/testapps/testPentagonIndexes.c +1 -0
  107. data/ext/h3/src/src/apps/testapps/testPolyfill.c +72 -9
  108. data/ext/h3/src/src/apps/testapps/testPolyfillReported.c +157 -0
  109. data/ext/h3/src/src/apps/testapps/testPolygon.c +27 -1
  110. data/ext/h3/src/src/apps/testapps/testVec2d.c +1 -0
  111. data/ext/h3/src/src/apps/testapps/testVec3d.c +1 -0
  112. data/ext/h3/src/src/apps/testapps/testVertex.c +66 -0
  113. data/ext/h3/src/src/apps/testapps/testVertexGraph.c +1 -0
  114. data/ext/h3/src/src/h3lib/include/algos.h +8 -0
  115. data/ext/h3/src/src/h3lib/include/alloc.h +40 -0
  116. data/ext/h3/src/src/h3lib/include/baseCells.h +4 -0
  117. data/ext/h3/src/src/h3lib/include/bbox.h +4 -1
  118. data/ext/h3/src/src/h3lib/include/faceijk.h +3 -2
  119. data/ext/h3/src/src/h3lib/include/geoCoord.h +2 -3
  120. data/ext/h3/src/src/h3lib/include/h3Index.h +37 -4
  121. data/ext/h3/src/src/h3lib/include/h3api.h.in +65 -17
  122. data/ext/h3/src/src/h3lib/include/linkedGeo.h +1 -0
  123. data/ext/h3/src/src/h3lib/include/polygon.h +1 -0
  124. data/ext/h3/src/src/h3lib/include/polygonAlgos.h +1 -0
  125. data/ext/h3/src/src/h3lib/include/vertex.h +44 -0
  126. data/ext/h3/src/src/h3lib/include/vertexGraph.h +1 -0
  127. data/ext/h3/src/src/h3lib/lib/algos.c +304 -76
  128. data/ext/h3/src/src/h3lib/lib/baseCells.c +26 -4
  129. data/ext/h3/src/src/h3lib/lib/bbox.c +56 -27
  130. data/ext/h3/src/src/h3lib/lib/coordijk.c +2 -0
  131. data/ext/h3/src/src/h3lib/lib/faceijk.c +32 -21
  132. data/ext/h3/src/src/h3lib/lib/geoCoord.c +162 -44
  133. data/ext/h3/src/src/h3lib/lib/h3Index.c +83 -42
  134. data/ext/h3/src/src/h3lib/lib/h3UniEdge.c +42 -57
  135. data/ext/h3/src/src/h3lib/lib/linkedGeo.c +20 -15
  136. data/ext/h3/src/src/h3lib/lib/localij.c +1 -1
  137. data/ext/h3/src/src/h3lib/lib/polygon.c +2 -0
  138. data/ext/h3/src/src/h3lib/lib/vec2d.c +1 -0
  139. data/ext/h3/src/src/h3lib/lib/vec3d.c +1 -0
  140. data/ext/h3/src/src/h3lib/lib/vertex.c +134 -0
  141. data/ext/h3/src/src/h3lib/lib/vertexGraph.c +8 -5
  142. data/ext/h3/src/website/.eslintignore +2 -0
  143. data/ext/h3/src/website/.gitignore +57 -0
  144. data/ext/h3/src/website/.nvmrc +1 -0
  145. data/ext/h3/src/website/README.md +8 -6
  146. data/ext/h3/src/website/gatsby-config.js +83 -0
  147. data/ext/h3/src/website/package.json +20 -12
  148. data/ext/h3/src/website/scripts/build-to-gh-pages.sh +7 -5
  149. data/ext/h3/src/website/src/.gitkeep +0 -0
  150. data/ext/h3/src/website/templates/documentation.jsx +129 -0
  151. data/ext/h3/src/website/yarn.lock +13723 -0
  152. data/h3.gemspec +2 -2
  153. data/lib/h3/bindings/base.rb +14 -4
  154. data/lib/h3/bindings/private.rb +12 -9
  155. data/lib/h3/hierarchy.rb +0 -18
  156. data/lib/h3/indexing.rb +0 -18
  157. data/lib/h3/inspection.rb +3 -59
  158. data/lib/h3/miscellaneous.rb +119 -14
  159. data/lib/h3/regions.rb +3 -0
  160. data/lib/h3/traversal.rb +0 -18
  161. data/lib/h3/unidirectional_edges.rb +5 -60
  162. data/lib/h3/version.rb +1 -1
  163. data/spec/geo_json_spec.rb +8 -0
  164. data/spec/miscellaneous_spec.rb +117 -0
  165. data/spec/{region_spec.rb → regions_spec.rb} +1 -1
  166. data/spec/spec_helper.rb +2 -2
  167. metadata +44 -36
  168. data/.travis.yml +0 -11
  169. data/ext/h3/src/.ycm_extra_conf.py +0 -92
  170. data/ext/h3/src/appveyor.yml +0 -50
  171. data/ext/h3/src/website/src/config.js +0 -46
  172. data/ext/h3/src/website/src/mdRoutes.js +0 -151
  173. data/ext/h3/src/website/src/styles/_variables.scss +0 -16
  174. data/ext/h3/src/website/src/styles/index.scss +0 -3
  175. data/ext/h3/src/website/static/index.html +0 -15
@@ -9,7 +9,7 @@ Planned improvements and changes are listed on the [H3 Roadmap](https://github.c
9
9
  * Please include tests that show the bug is fixed or feature works as intended.
10
10
  * Please add a description of your change to the Unreleased section of the [changelog](./CHANGELOG.md).
11
11
  * Please open issues to discuss large features or changes which would break compatibility, before submitting pull requests.
12
- * Please keep H3 compatible with major C compilers, such as GCC, Clang, and MSVC.
12
+ * Please keep H3 compatible with major C compilers, such as GCC, Clang, and MSVC. We use clang-format-9 for source code formatting, if you have another version the CI job may error on formatting differences.
13
13
  * Please keep code coverage of the core H3 library at 100%.
14
14
 
15
15
  Before we can merge your changes, you must agree to the [Uber Contributor License Agreement](https://cla-assistant.io/uber/h3).
data/ext/h3/src/README.md CHANGED
@@ -1,24 +1,27 @@
1
- <img align="right" src="https://uber.github.io/res/h3Logo-color.svg" alt="H3 Logo" width="200">
1
+ <img align="right" src="https://uber.github.io/img/h3Logo-color.svg" alt="H3 Logo" width="200">
2
2
 
3
3
  # H3: A Hexagonal Hierarchical Geospatial Indexing System
4
4
 
5
- [![Build Status](https://travis-ci.com/uber/h3.svg?branch=master)](https://travis-ci.com/uber/h3)
6
- [![Build status](https://ci.appveyor.com/api/projects/status/61431y4sc5w0tsuk/branch/master?svg=true)](https://ci.appveyor.com/project/Uber/h3/branch/master)
5
+ [![test-linux](https://github.com/uber/h3/workflows/test-linux/badge.svg)](https://github.com/uber/h3/actions)
6
+ [![test-macos](https://github.com/uber/h3/workflows/test-macos/badge.svg)](https://github.com/uber/h3/actions)
7
+ [![test-windows](https://github.com/uber/h3/workflows/test-windows/badge.svg)](https://github.com/uber/h3/actions)
8
+ [![test-website](https://github.com/uber/h3/workflows/test-website/badge.svg)](https://github.com/uber/h3/actions)
7
9
  [![Coverage Status](https://coveralls.io/repos/github/uber/h3/badge.svg?branch=master)](https://coveralls.io/github/uber/h3?branch=master)
8
10
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
9
11
 
10
12
  H3 is a geospatial indexing system using a hexagonal grid that can be (approximately) subdivided into finer and finer hexagonal grids, combining the benefits of a hexagonal grid with [S2](https://code.google.com/archive/p/s2-geometry-library/)'s hierarchical subdivisions.
11
13
 
12
- Documentation is available at [https://uber.github.io/h3/](https://uber.github.io/h3/). Developer documentation in Markdown format is available under the [dev-docs](./dev-docs/) directory.
14
+ Documentation is available at [https://h3geo.org/](https://h3geo.org/). Developer documentation in Markdown format is available under the [dev-docs](./dev-docs/) directory.
13
15
 
14
16
  * Post **bug reports or feature requests** to the [GitHub Issues page](https://github.com/uber/h3/issues)
15
17
  * Ask **questions** by posting to the [H3 tag on StackOverflow](https://stackoverflow.com/questions/tagged/h3)
18
+ * There is also an [H3 Slack workspace](https://join.slack.com/t/h3-core/shared_invite/zt-g6u5r1hf-W_~uVJmfeiWtMQuBGc1NNg)
16
19
 
17
20
  ## Installing
18
21
 
19
- We recommend using prebuilt bindings if they are available for your programming language. Bindings for [Go](https://github.com/uber/h3-go), [Java](https://github.com/uber/h3-java), [JavaScript](https://github.com/uber/h3-js), [Python](https://github.com/uber/h3-py), and [others](https://uber.github.io/h3/#/documentation/community/bindings) are available.
22
+ We recommend using prebuilt bindings if they are available for your programming language. Bindings for [Go](https://github.com/uber/h3-go), [Java](https://github.com/uber/h3-java), [JavaScript](https://github.com/uber/h3-js), [Python](https://github.com/uber/h3-py), and [others](https://h3geo.org/docs/community/bindings) are available.
20
23
 
21
- On macOS, you can install H3 using brew:
24
+ On macOS, you can install H3 using `brew`:
22
25
  ```
23
26
  brew install h3
24
27
  ```
@@ -30,7 +33,7 @@ Still here? To build the H3 C library, you'll need a C compiler (tested with `gc
30
33
 
31
34
  #### Install build-time dependencies
32
35
 
33
- * Alpine
36
+ * Alpine
34
37
  ```
35
38
  # Installing the bare build requirements
36
39
  apk add cmake make gcc libtool musl-dev
@@ -45,7 +48,7 @@ sudo apt install cmake make gcc libtool
45
48
  sudo apt install clang-format cmake-curses-gui lcov doxygen
46
49
  ```
47
50
 
48
- * macOS (using brew)
51
+ * macOS (using `brew`)
49
52
 
50
53
  First make sure you [have the developer tools installed](http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/) and then
51
54
 
@@ -60,24 +63,71 @@ brew install clang-format lcov doxygen
60
63
 
61
64
  You will need to install CMake and Visual Studio, including the Visual C++ compiler. For building on Windows, please follow the [Windows build instructions](dev-docs/build_windows.md).
62
65
 
66
+ * FreeBSD
67
+
68
+ ```
69
+ # Installing the build requirements
70
+ sudo pkg install bash cmake gmake doxygen lcov
71
+ ```
72
+
63
73
  #### Compilation
64
74
 
65
- From the repository you would then compile like so:
75
+ From the repository root, you can compile H3 with:
66
76
 
67
77
  ```
68
- cmake .
78
+ mkdir build
79
+ cd build
80
+ cmake ..
69
81
  make
70
82
  ```
71
83
 
84
+ All subsequent `make` commands should be run from within the `build` directory.
85
+
86
+ **Note**: There are several ways to build H3 with CMake; the method above is just one example that restricts all build artifacts to the `build` directory.
87
+
72
88
  You can install system-wide with:
73
89
 
74
90
  ```
75
91
  sudo make install
76
92
  ```
77
93
 
94
+ If using the method above, from the repository root, you can clean all build artifacts with:
95
+
96
+ ```
97
+ rm -rf build
98
+ ```
99
+
78
100
  #### Testing
79
101
 
80
- After making the project, you can test with `make test`, and if `lcov` is installed you can `make coverage` to generate a code coverage report.
102
+ After making the project, you can test with `make test`.
103
+ You can run a faster test suite that excludes the most expensive tests with `make test-fast`.
104
+
105
+ #### Coverage
106
+
107
+ You can generate a code coverage report if `lcov` is installed, and if the project was built with the `CMAKE_BUILD_TYPE=Debug` option.
108
+ For example, from a clean repository, you could run:
109
+
110
+ ```
111
+ mkdir build
112
+ cd build
113
+ cmake -DCMAKE_BUILD_TYPE=Debug ..
114
+ make
115
+ make coverage
116
+ ```
117
+
118
+ You can then view a detailed HTML coverage report by opening `coverage/index.html` in your browser.
119
+
120
+ #### Benchmarks
121
+
122
+ You can run timing benchmarks by building with the `CMAKE_BUILD_TYPE=Release`, and running `make benchmarks`:
123
+
124
+ ```
125
+ mkdir build
126
+ cd build
127
+ cmake -DCMAKE_BUILD_TYPE=Release ..
128
+ make
129
+ make benchmarks
130
+ ```
81
131
 
82
132
  #### Documentation
83
133
 
@@ -2,8 +2,10 @@
2
2
 
3
3
  1. Create a PR "Preparing for release X.Y.Z" against master branch
4
4
  * Alter CHANGELOG.md from `[Unreleased]` to `[X.Y.Z] YYYY-MM-DD`
5
- * Run `make update-version` and give `X.Y.Z` when prompted
5
+ * Run `make update-version` and give `X.Y.Z` when prompted (this updates
6
+ the VERSION file, so don't change it manually)
6
7
  * Check that all merges that need to be in the changelog are present
8
+ * Get reviews and merge the PR
7
9
 
8
10
  2. Create a release "Release X.Y.Z" on Github
9
11
  * Create Tag `vX.Y.Z`
data/ext/h3/src/VERSION CHANGED
@@ -1 +1 @@
1
- 3.6.0
1
+ 3.7.2
@@ -0,0 +1,21 @@
1
+ # RFC: <Subject>
2
+
3
+ * **Authors**: -
4
+ * **Date**: -
5
+ * **Status**: Draft
6
+
7
+ ## Abstract
8
+
9
+ *Brief overview of the subject and proposal*
10
+
11
+ ## Motivation
12
+
13
+ *Why is this important?*
14
+
15
+ ## Approaches
16
+
17
+ *What are the various options to address this issue?*
18
+
19
+ ## Proposal
20
+
21
+ *What is the recommended approach?*
@@ -0,0 +1,21 @@
1
+ # RFC: Consistent error handling
2
+
3
+ * **Authors**: -
4
+ * **Date**: -
5
+ * **Status**: Draft
6
+
7
+ ## Abstract
8
+
9
+ Error handling in the H3 library is inconsistent across functions, many of which have no explicit mechanism to indicate that an error occured. This RFC proposes updating all functions that allocate blocks of memory or that could receive invalid input to return an integer code indicating success or error.
10
+
11
+ ## Motivation
12
+
13
+ *Why is this important?*
14
+
15
+ ## Approaches
16
+
17
+ *What are the various options to address this issue?*
18
+
19
+ ## Proposal
20
+
21
+ *What is the recommended approach?*
@@ -0,0 +1,276 @@
1
+ # RFC: Names for H3 Concepts, Types, and Functions
2
+
3
+ - **Authors**:
4
+ - AJ Friend
5
+ - Nick Rabinowitz
6
+ - Isaac Brodsky
7
+ - David Ellis
8
+ - **Dates**:
9
+ - Started: 2020-02-02
10
+ - Accepted: 2020-03-26
11
+ - **Status**: Accepted
12
+ - **Discussions**:
13
+ - <https://github.com/uber/h3/pull/308>
14
+
15
+ ## Motivation
16
+
17
+ Concepts like `hexagon`, `cell`, and `index` are currently used ambiguously in the H3 codebase and in documentation.
18
+ This can cause confusion, for example, when a function might only work on strict H3 *hexagons*, but fails when encountering H3 *pentagons*.
19
+
20
+ Reaching a consensus on the precise, technical language used when discussing H3 concepts will clarify future library discussions and improve end-user documentation.
21
+
22
+ We would also like to standardize a function-naming scheme.
23
+
24
+ ## Terminology
25
+
26
+ The following technical terms should be used in the documentation, the H3 codebase, and precise technical discussions of the library.
27
+
28
+ - `H3Index`:
29
+ - an unsigned 64-bit integer representing *any* H3 object (hexagon, pentagon, directed edge ...)
30
+ - often represented as a 15-character (or 16-character) hexadecimal string, like `'8928308280fffff'`
31
+ - the full term "H3 index" should be used to avoid confusion with other common uses of "index";
32
+ when a "traditional" index is needed, prefer using "number", "pos", or another term to avoid confusion
33
+ - **mode**:
34
+ - an integer describing the type of object being represented by an H3 index
35
+ - this integer is encoded in the `H3Index`
36
+ - **cell** or **H3 cell**:
37
+ - a geometric/geographic unit polygon in the H3 grid, corresponding to an `H3Index` of `mode 1` (hexagon or pentagon)
38
+ - for functions that can handle either hexagons or pentagons, the more general term "cell" should be used whenever possible
39
+ - **hexagon**:
40
+ - an H3 **cell** that is a **topological** hexagon
41
+ - below, we explain that functions that *only* work with **hexagons** have an `Unsafe` suffix;
42
+ these functions are paired with ones having a `Safe` suffix, meaning they can handle **pentagons**, but are slower
43
+ - **pentagon**:
44
+ - an H3 **cell** that is a **topological** pentagon
45
+ - **directed edge**:
46
+ - represents a traversal from an origin **cell** to an adjacent destination **cell**
47
+ - corresponds to an `H3Index` of `mode 2`
48
+ - **grid**:
49
+ - the graph with nodes corresponding to H3 cells, and edges given by pairs of adjacent cells
50
+ - for example, `gridDistance` is the minimal number of edges in a graph path connecting two cells
51
+ - **point**:
52
+ - a representation of a geographic point in terms of a latitude/longitude pair
53
+ - **topological**:
54
+ - H3 cells are **topological** pentagons or hexagons, in the sense that they have 5 or 6 neighbors, respectively, in the H3 **grid**
55
+ - the majority of **hexagons** are also **geometric** hexagons (similarly with **pentagons**), in that they have 6 edges and vertices when represented as polygons of lat/lng points
56
+ - a small number of **hexagons** are not **geometric** hexagons (similarly with **pentagons**), in that they have extra vertices and edges due to distortion around icosahedron boundaries
57
+ - for more details, see this [h3-js issue](https://github.com/uber/h3-js/issues/53) or this [Observable post](https://observablehq.com/@fil/h3-oddities)
58
+ - **base cell**:
59
+ - one of the 122 H3 **cells** (110 hexagons and 12 pentagons) of resolution `0`
60
+ - every other cell in H3 is a child of a base cell
61
+ - each base cell has a "base cell number" (0--121), which is encoded into the `H3Index` representation of every H3 cell
62
+ - there is a one-to-one correspondence between the "base cell number" and the `H3Index` representation of resolution `0` cells
63
+ + e.g., base cell 0 has `H3Index` hexadecimal representation `'8001fffffffffff'`
64
+ - **boundary**:
65
+ - all or part of the list of geometric points that enclose an H3 cell
66
+ - may include more than 6 points in the case that a cell is not a geometric hexagon, such as when a hexagon crosses an icosahedron boundary
67
+ - may also be used to describe the boundary between two geometric cells, as in the case of an edge
68
+ - represented in the H3 codebase with the `CellBoundary` struct (previously `GeoBoundary` before v4.0)
69
+ - `H3_NULL`;
70
+ - equivalent to `0` and guaranteed to never be a valid `H3Index` (even after any future H3 **modes** are added)
71
+ - returned by functions to denote an error, or to denote missing data in arrays of `H3Index`
72
+ - analogous to `NaN` in floating point
73
+
74
+
75
+ ### Use of "hex", "hexagon", "cell", "pentagon", etc.
76
+
77
+ We realize that "hex" or "hexagon" will still be used informally to refer to the concept of "cell" (As the development team, we do it ourselves!).
78
+ This should be expected in casual, informal discussions of H3.
79
+ However, when *precision* is required, we advise the use of strict technical terms like "index", "cell", "hexagon", "pentagon", etc.
80
+ In the codebase and in the documentation, strictly correct terminology should *always* be used, as many functions and algorithms distinguish between hexagons and pentagons.
81
+
82
+
83
+ ## `H3_EXPORT` and C name collisions
84
+
85
+ To avoid C name collisions, we should build the bindings (`h3-py`, `h3-java`, `h3-go`, and `h3-node`) with a standard function prefix, using the `H3_EXPORT` C macro.
86
+ The `h3-js` binding would not need this.
87
+
88
+ The proposed prefix is `h3_`.
89
+
90
+ ## Functions
91
+
92
+ ### Conventions for "property getters" and transforms
93
+
94
+ - use `get` prefix for
95
+ + constant data (`getNumCells`, `getRes0Cells`)
96
+ + object properties (`getResolution`, `getBaseCellNumber`)
97
+ - use `to` to denote transforms
98
+ + different representations of the same object
99
+ + when doing a lossy transformation to a new object (`cellToParent`, `pointToCell`)
100
+ - do not use `get` or `to` for *computations*
101
+ + e.g., `polyfill`, `compact`, `cellAreaKm2`
102
+
103
+ There is some ambiguity between property, transform, and computation, so use your best judgement with these guidelines in mind.
104
+
105
+ ### Validity checks
106
+
107
+ - `isValid*` should mean that a *full* validity check is made
108
+ - without `Valid` (like in the case of `isPentagon`), we do not guarantee
109
+ that a full validity check is made; instead, a user should assume only a
110
+ minimal bit mask check is done
111
+ - we could imagine a `isValidPengaton` function, if full verification
112
+ would be convenient
113
+ - similarly, a function like `areNeighborCells` will assume each cell
114
+ has passed the `isValidCell` check; the function will do only minimal
115
+ work to determine if they are neighbors
116
+
117
+
118
+ ### General Function Names
119
+
120
+ | Current name | Proposed name |
121
+ |-------------------------------|-----------------------|
122
+ | *Does Not Exist (DNE)* | `isValidIndex` |
123
+ | `h3IsValid` | `isValidCell` |
124
+ | `h3UnidirectionalEdgeIsValid` | `isValidDirectedEdge` |
125
+ | `h3IsPentagon` | `isPentagon` |
126
+ | `h3IsResClassIII` | `isResClassIII` |
127
+ | `h3IndexesAreNeighbors` | `areNeighborCells` |
128
+ | `h3ToParent` | `cellToParent` |
129
+ | `h3ToCenterChild` | `cellToCenterChild` |
130
+ | `h3ToChildren` | `cellToChildren` |
131
+ | `numHexagons` | `getNumCells` |
132
+ | `getRes0Indexes` | `getRes0Cells` |
133
+ | `getPentagonIndexes` | `getPentagons` |
134
+ | `h3GetBaseCell` | `getBaseCellNumber` |
135
+ | `h3GetResolution` | `getResolution` |
136
+ | *DNE* | `getMode` |
137
+ | `h3GetFaces` | `getIcosahedronFaces` |
138
+ | `geoToH3` | `pointToCell` |
139
+ | `h3ToGeo` | `cellToPoint` |
140
+ | `compact` | `compactCells` |
141
+ | `uncompact` | `uncompactCells` |
142
+ | `polyfill` | `polygonToCells` |
143
+
144
+ **Note**: `getResolution` and `getBaseCellNumber` should work for both cells and edges.
145
+
146
+
147
+ ### H3 Grid Functions
148
+
149
+ Many of these functions will have three forms:
150
+ - `<func_name>`
151
+ - `<func_name>Unsafe`
152
+ - `<func_name>Safe`
153
+
154
+ The `Unsafe` version is fast, but may fail if it encounters a pentagon.
155
+ It should return a failure code in this case.
156
+
157
+ The `Safe` version is slower, but will work in all cases.
158
+
159
+ The version without either suffix is intended to be the one typically
160
+ used.
161
+ This version will first attempt the `Unsafe` version, and if
162
+ it detects failure, will fall back to the `Safe` version.
163
+ Encountering pentagons is rare in most use-cases, so this version
164
+ should usually be equivalent to the fast version, but with a guarantee
165
+ that it will not fail.
166
+
167
+ Initially, we **will not** expose the `Safe` versions to users in the API.
168
+ We may expose them in the future if a need becomes clear.
169
+
170
+
171
+ #### Distance
172
+
173
+ | Current name | Proposed name |
174
+ |--------------|-------------------------|
175
+ | `h3Distance` | `gridDistance` |
176
+ | `h3Line` | `gridPathCells` |
177
+ | *DNE* | `gridPathEdges` |
178
+ | *DNE* | `gridPathDirectedEdges` |
179
+
180
+
181
+ #### Filled-In Disk With Distances
182
+
183
+ | Current name | Proposed name | Calls |
184
+ |---------------------|---------------------------|---------------------------------------|
185
+ | `hexRangeDistances` | `gridDiskDistancesUnsafe` | NONE |
186
+ | `_kRingInternal` | `gridDiskDistancesSafe` | NONE |
187
+ | `kRingDistances` | `gridDiskDistances` | `hexRangeDistances`, `_kRingInternal` |
188
+
189
+
190
+ #### Filled-In Disk Without Distances
191
+
192
+ | Current name | Proposed name | Calls |
193
+ |--------------|-------------------|---------------------|
194
+ | `hexRange` | `gridDiskUnsafe` | `hexRangeDistances` |
195
+ | *DNE* | `gridDiskSafe` | |
196
+ | `kRing` | `gridDisk` | `kRingDistances` |
197
+ | `hexRanges` | `gridDisksUnsafe` | N x `hexRange` |
198
+
199
+ - **Note**: We may remove `hexRanges` from the API, as it is just a very simple wrapper around
200
+ `hexRange`. Inclusion is a discussion separate from this RFC. We'll simply state that
201
+ *if we do* include it, we will rename it `gridDisksUnsafe`.
202
+
203
+
204
+ #### Hollow Ring
205
+
206
+ | Current name | Proposed name | Calls |
207
+ |--------------|------------------|----------------------------------|
208
+ | `hexRing` | `gridRingUnsafe` | NONE |
209
+ | *DNE* | `gridRingSafe` | `gridDiskDistancesSafe` |
210
+ | *DNE* | `gridRing` | `gridRingUnsafe`, `gridRingSafe` |
211
+
212
+ ### H3 Edge Types
213
+
214
+ Instead of `UnidirectionalEdge`, use the term `DirectedEdge`.
215
+
216
+ For a future undirected edge mode, use the term `Edge`.
217
+
218
+ | Current name | Proposed name |
219
+ |-----------------------------------------------|------------------------------|
220
+ | `h3UnidirectionalEdgeIsValid` | `isValidDirectedEdge` |
221
+ | `getH3UnidirectionalEdge` | `cellsToDirectedEdge` |
222
+ | `getH3IndexesFromUnidirectionalEdge` | `directedEdgeToCells` |
223
+ | `getH3UnidirectionalEdgesFromHexagon` | `originToDirectedEdges` |
224
+ | *DNE* | `destinationToDirectedEdges` |
225
+ | `getH3UnidirectionalEdgeBoundary` | `directedEdgeToBoundary` |
226
+ | `getOriginH3IndexFromUnidirectionalEdge` | `getDirectedEdgeOrigin` |
227
+ | `getDestinationH3IndexFromUnidirectionalEdge` | `getDirectedEdgeDestination` |
228
+
229
+
230
+ ### Area/Length Functions
231
+
232
+ | Current name | Proposed name |
233
+ |----------------|-----------------------------|
234
+ | `hexAreaKm2` | `getHexagonAreaAvgKm2` |
235
+ | `hexAreaM2` | `getHexagonAreaAvgM2` |
236
+ | `edgeLengthKm` | `getHexagonEdgeLengthAvgKm` |
237
+ | `edgeLengthM` | `getHexagonEdgeLengthAvgM` |
238
+ | *DNE* | `getPentagonAreaAvg*` |
239
+ | *DNE* | `getPentagonEdgeLengthAvg*` |
240
+ | *DNE* | `cellAreaKm2` |
241
+ | *DNE* | `cellAreaM2` |
242
+
243
+ **Note**: `cellAreaKm2` and `cellAreaM2` would return the actual area of
244
+ the passed-in cell.
245
+
246
+
247
+ ## Polygons
248
+
249
+ **Note**: In addition to the changes listed in this section, we are considering
250
+ removing the `Linked*` data types from the public API. However, that is a larger
251
+ discussion requiring benchmarking, so we will defer that to a
252
+ [separate issue](https://github.com/uber/h3/issues/323) outside of this RFC.
253
+
254
+
255
+ ### Data Structures
256
+
257
+ - rename `GeoBoundary` to `CellBoundary` to indicate it is space-limited to describing the geometry of cells
258
+
259
+ | Current name | Proposed name | Notes |
260
+ |-------------------|-------------------|-----------------------------------|
261
+ | `GeoBoundary` | `CellBoundary` | <= 10 stack-allocated `GeoPoint`s |
262
+ | `GeoCoord` | `GeoPoint` | |
263
+ | `Geofence` | `GeoLoop` | heap-allocated `GeoPoint`s |
264
+ | `GeoPolygon` | `GeoPolygon` | |
265
+ | `GeoMultiPolygon` | `GeoMultiPolygon` | currently not used |
266
+
267
+
268
+ ### Functions
269
+
270
+ | Current name | Proposed name | Notes |
271
+ |-----------------------------------|--------------------------|------------------------|
272
+ | `h3ToGeoBoundary` | `cellToBoundary` | returns `CellBoundary` |
273
+ | *DNE* | `cellToLoop` | returns `GeoLoop` |
274
+ | *DNE* | `loopToBoundary` | |
275
+ | *DNE* | `boundaryToLoop` | |
276
+ | `getH3UnidirectionalEdgeBoundary` | `directedEdgeToBoundary` | returns `CellBoundary` |