h3 3.6.2 → 3.7.1

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 (161) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +23 -0
  3. data/Gemfile.lock +6 -6
  4. data/README.md +1 -1
  5. data/ext/h3/src/.github/workflows/test-linux.yml +118 -0
  6. data/ext/h3/src/.github/workflows/test-macos.yml +42 -0
  7. data/ext/h3/src/.github/workflows/test-website.yml +32 -0
  8. data/ext/h3/src/.github/workflows/test-windows.yml +44 -0
  9. data/ext/h3/src/.gitignore +5 -0
  10. data/ext/h3/src/.travis.yml +16 -46
  11. data/ext/h3/src/CHANGELOG.md +43 -0
  12. data/ext/h3/src/CMakeLists.txt +133 -33
  13. data/ext/h3/src/CONTRIBUTING.md +1 -1
  14. data/ext/h3/src/README.md +60 -10
  15. data/ext/h3/src/RELEASE.md +3 -1
  16. data/ext/h3/src/VERSION +1 -1
  17. data/ext/h3/src/dev-docs/RFCs/rfc-template.md +21 -0
  18. data/ext/h3/src/dev-docs/RFCs/v4.0.0/error-handling-rfc.md +21 -0
  19. data/ext/h3/src/dev-docs/RFCs/v4.0.0/names_for_concepts_types_functions.md +276 -0
  20. data/ext/h3/src/dev-docs/RFCs/v4.0.0/overrideable-allocators-rfc.md +141 -0
  21. data/ext/h3/src/dev-docs/RFCs/v4.0.0/polyfill-modes-rfc.md +21 -0
  22. data/ext/h3/src/dev-docs/RFCs/v4.0.0/vertex-mode-rfc.md +50 -0
  23. data/ext/h3/src/dev-docs/build_windows.md +6 -1
  24. data/ext/h3/src/dev-docs/creating_bindings.md +3 -3
  25. data/ext/h3/src/dev-docs/custom_alloc.md +27 -0
  26. data/ext/h3/src/docs/{overview/mainpage.md → README.md} +2 -3
  27. data/ext/h3/src/docs/api/misc.md +76 -0
  28. data/ext/h3/src/docs/community/applications.md +1 -0
  29. data/ext/h3/src/docs/community/bindings.md +7 -1
  30. data/ext/h3/src/docs/community/tutorials.md +8 -3
  31. data/ext/h3/src/docs/core-library/coordsystems.md +5 -4
  32. data/ext/h3/src/docs/core-library/filters.md +8 -9
  33. data/ext/h3/src/docs/core-library/geoToH3desc.md +2 -3
  34. data/ext/h3/src/docs/core-library/h3ToGeoBoundaryDesc.md +4 -5
  35. data/ext/h3/src/docs/core-library/h3ToGeoDesc.md +3 -4
  36. data/ext/h3/src/docs/core-library/h3indexing.md +26 -17
  37. data/ext/h3/src/docs/core-library/overview.md +2 -3
  38. data/ext/h3/src/docs/core-library/restable.md +1 -2
  39. data/ext/h3/src/docs/core-library/usage.md +1 -2
  40. data/ext/h3/src/docs/table-of-contents.json +47 -0
  41. data/ext/h3/src/docs/{overview/usecases.md → usecases.md} +6 -11
  42. data/ext/h3/src/scripts/binding_functions.sh +1 -1
  43. data/ext/h3/src/scripts/coverage.sh.in +1 -1
  44. data/ext/h3/src/scripts/update_version.sh +2 -2
  45. data/ext/h3/src/src/apps/applib/include/args.h +1 -0
  46. data/ext/h3/src/src/apps/applib/include/test.h +1 -0
  47. data/ext/h3/src/src/apps/applib/include/utility.h +7 -1
  48. data/ext/h3/src/src/apps/applib/lib/args.c +2 -0
  49. data/ext/h3/src/src/apps/applib/lib/kml.c +2 -0
  50. data/ext/h3/src/src/apps/applib/lib/test.c +1 -0
  51. data/ext/h3/src/src/apps/applib/lib/utility.c +133 -2
  52. data/ext/h3/src/src/apps/benchmarks/benchmarkH3Api.c +1 -1
  53. data/ext/h3/src/{website/html.config.js → src/apps/benchmarks/benchmarkH3UniEdge.c} +15 -12
  54. data/ext/h3/src/src/apps/filters/h3ToComponents.c +1 -0
  55. data/ext/h3/src/src/apps/filters/h3ToGeo.c +1 -0
  56. data/ext/h3/src/src/apps/filters/h3ToGeoBoundary.c +1 -0
  57. data/ext/h3/src/src/apps/filters/h3ToLocalIj.c +1 -0
  58. data/ext/h3/src/src/apps/filters/hexRange.c +1 -0
  59. data/ext/h3/src/src/apps/filters/kRing.c +1 -0
  60. data/ext/h3/src/src/apps/filters/localIjToH3.c +1 -0
  61. data/ext/h3/src/src/apps/miscapps/generateFaceCenterPoint.c +1 -0
  62. data/ext/h3/src/src/apps/miscapps/generateNumHexagons.c +1 -0
  63. data/ext/h3/src/src/apps/miscapps/generatePentagonDirectionFaces.c +67 -0
  64. data/ext/h3/src/src/apps/miscapps/h3ToGeoBoundaryHier.c +1 -0
  65. data/ext/h3/src/src/apps/miscapps/h3ToGeoHier.c +1 -0
  66. data/ext/h3/src/src/apps/miscapps/h3ToHier.c +1 -0
  67. data/ext/h3/src/src/apps/testapps/mkRandGeo.c +1 -0
  68. data/ext/h3/src/src/apps/testapps/mkRandGeoBoundary.c +1 -0
  69. data/ext/h3/src/src/apps/testapps/testBBox.c +1 -0
  70. data/ext/h3/src/src/apps/testapps/testBaseCells.c +15 -1
  71. data/ext/h3/src/src/apps/testapps/testCompact.c +75 -0
  72. data/ext/h3/src/src/apps/testapps/testCoordIj.c +1 -0
  73. data/ext/h3/src/src/apps/testapps/testGeoCoord.c +40 -13
  74. data/ext/h3/src/src/apps/testapps/testGeoToH3.c +1 -0
  75. data/ext/h3/src/src/apps/testapps/testH3Api.c +1 -0
  76. data/ext/h3/src/src/apps/testapps/testH3CellArea.c +47 -0
  77. data/ext/h3/src/src/apps/testapps/testH3CellAreaExhaustive.c +180 -0
  78. data/ext/h3/src/src/apps/testapps/testH3Distance.c +1 -0
  79. data/ext/h3/src/src/apps/testapps/testH3DistanceExhaustive.c +1 -0
  80. data/ext/h3/src/src/apps/testapps/testH3GetFaces.c +1 -0
  81. data/ext/h3/src/src/apps/testapps/testH3Index.c +33 -3
  82. data/ext/h3/src/src/apps/testapps/testH3Line.c +1 -0
  83. data/ext/h3/src/src/apps/testapps/testH3LineExhaustive.c +1 -0
  84. data/ext/h3/src/src/apps/testapps/testH3Memory.c +175 -0
  85. data/ext/h3/src/src/apps/testapps/testH3NeighborRotations.c +1 -0
  86. data/ext/h3/src/src/apps/testapps/testH3SetToLinkedGeo.c +1 -0
  87. data/ext/h3/src/src/apps/testapps/testH3SetToVertexGraph.c +1 -0
  88. data/ext/h3/src/src/apps/testapps/testH3ToCenterChild.c +1 -0
  89. data/ext/h3/src/src/apps/testapps/testH3ToChildren.c +1 -0
  90. data/ext/h3/src/src/apps/testapps/testH3ToGeo.c +1 -0
  91. data/ext/h3/src/src/apps/testapps/testH3ToGeoBoundary.c +1 -0
  92. data/ext/h3/src/src/apps/testapps/testH3ToLocalIj.c +9 -5
  93. data/ext/h3/src/src/apps/testapps/testH3ToLocalIjExhaustive.c +1 -0
  94. data/ext/h3/src/src/apps/testapps/testH3ToParent.c +1 -0
  95. data/ext/h3/src/src/apps/testapps/testH3UniEdge.c +45 -16
  96. data/ext/h3/src/src/apps/testapps/testH3UniEdgeExhaustive.c +111 -0
  97. data/ext/h3/src/src/apps/testapps/testHexRanges.c +1 -0
  98. data/ext/h3/src/src/apps/testapps/testHexRing.c +1 -0
  99. data/ext/h3/src/src/apps/testapps/testKRing.c +1 -0
  100. data/ext/h3/src/src/apps/testapps/testLinkedGeo.c +1 -0
  101. data/ext/h3/src/src/apps/testapps/testMaxH3ToChildrenSize.c +1 -0
  102. data/ext/h3/src/src/apps/testapps/testPentagonIndexes.c +1 -0
  103. data/ext/h3/src/src/apps/testapps/testPolyfill.c +72 -9
  104. data/ext/h3/src/src/apps/testapps/testPolyfillReported.c +157 -0
  105. data/ext/h3/src/src/apps/testapps/testPolygon.c +1 -0
  106. data/ext/h3/src/src/apps/testapps/testVec2d.c +1 -0
  107. data/ext/h3/src/src/apps/testapps/testVec3d.c +1 -0
  108. data/ext/h3/src/src/apps/testapps/testVertex.c +66 -0
  109. data/ext/h3/src/src/apps/testapps/testVertexGraph.c +1 -0
  110. data/ext/h3/src/src/h3lib/include/algos.h +8 -0
  111. data/ext/h3/src/src/h3lib/include/alloc.h +40 -0
  112. data/ext/h3/src/src/h3lib/include/baseCells.h +4 -0
  113. data/ext/h3/src/src/h3lib/include/bbox.h +4 -1
  114. data/ext/h3/src/src/h3lib/include/faceijk.h +3 -2
  115. data/ext/h3/src/src/h3lib/include/geoCoord.h +2 -3
  116. data/ext/h3/src/src/h3lib/include/h3Index.h +37 -4
  117. data/ext/h3/src/src/h3lib/include/h3api.h.in +65 -17
  118. data/ext/h3/src/src/h3lib/include/linkedGeo.h +1 -0
  119. data/ext/h3/src/src/h3lib/include/polygon.h +1 -0
  120. data/ext/h3/src/src/h3lib/include/polygonAlgos.h +1 -0
  121. data/ext/h3/src/src/h3lib/include/vertex.h +44 -0
  122. data/ext/h3/src/src/h3lib/include/vertexGraph.h +1 -0
  123. data/ext/h3/src/src/h3lib/lib/algos.c +300 -75
  124. data/ext/h3/src/src/h3lib/lib/baseCells.c +26 -4
  125. data/ext/h3/src/src/h3lib/lib/bbox.c +56 -31
  126. data/ext/h3/src/src/h3lib/lib/coordijk.c +2 -0
  127. data/ext/h3/src/src/h3lib/lib/faceijk.c +32 -21
  128. data/ext/h3/src/src/h3lib/lib/geoCoord.c +162 -44
  129. data/ext/h3/src/src/h3lib/lib/h3Index.c +81 -43
  130. data/ext/h3/src/src/h3lib/lib/h3UniEdge.c +42 -57
  131. data/ext/h3/src/src/h3lib/lib/linkedGeo.c +20 -15
  132. data/ext/h3/src/src/h3lib/lib/localij.c +1 -1
  133. data/ext/h3/src/src/h3lib/lib/polygon.c +2 -0
  134. data/ext/h3/src/src/h3lib/lib/vec2d.c +1 -0
  135. data/ext/h3/src/src/h3lib/lib/vec3d.c +1 -0
  136. data/ext/h3/src/src/h3lib/lib/vertex.c +134 -0
  137. data/ext/h3/src/src/h3lib/lib/vertexGraph.c +8 -5
  138. data/ext/h3/src/website/.eslintignore +2 -0
  139. data/ext/h3/src/website/.gitignore +57 -0
  140. data/ext/h3/src/website/.nvmrc +1 -0
  141. data/ext/h3/src/website/README.md +8 -6
  142. data/ext/h3/src/website/gatsby-config.js +83 -0
  143. data/ext/h3/src/website/package.json +20 -12
  144. data/ext/h3/src/website/scripts/build-to-gh-pages.sh +7 -5
  145. data/ext/h3/src/website/src/.gitkeep +0 -0
  146. data/ext/h3/src/website/templates/documentation.jsx +129 -0
  147. data/ext/h3/src/website/yarn.lock +13723 -0
  148. data/lib/h3/bindings/private.rb +3 -0
  149. data/lib/h3/miscellaneous.rb +123 -0
  150. data/lib/h3/version.rb +1 -1
  151. data/spec/miscellaneous_spec.rb +117 -0
  152. data/spec/regions_spec.rb +1 -1
  153. metadata +35 -14
  154. data/ext/h3/src/.ycm_extra_conf.py +0 -92
  155. data/ext/h3/src/appveyor.yml +0 -50
  156. data/ext/h3/src/src/apps/testapps/testPolyfill_GH136.c +0 -58
  157. data/ext/h3/src/website/src/config.js +0 -46
  158. data/ext/h3/src/website/src/mdRoutes.js +0 -151
  159. data/ext/h3/src/website/src/styles/_variables.scss +0 -16
  160. data/ext/h3/src/website/src/styles/index.scss +0 -3
  161. data/ext/h3/src/website/static/index.html +0 -15
@@ -18,8 +18,11 @@
18
18
  */
19
19
 
20
20
  #include "linkedGeo.h"
21
+
21
22
  #include <assert.h>
22
23
  #include <stdlib.h>
24
+
25
+ #include "alloc.h"
23
26
  #include "geoCoord.h"
24
27
  #include "h3api.h"
25
28
 
@@ -30,7 +33,7 @@
30
33
  */
31
34
  LinkedGeoPolygon* addNewLinkedPolygon(LinkedGeoPolygon* polygon) {
32
35
  assert(polygon->next == NULL);
33
- LinkedGeoPolygon* next = calloc(1, sizeof(*next));
36
+ LinkedGeoPolygon* next = H3_MEMORY(calloc)(1, sizeof(*next));
34
37
  assert(next != NULL);
35
38
  polygon->next = next;
36
39
  return next;
@@ -42,7 +45,7 @@ LinkedGeoPolygon* addNewLinkedPolygon(LinkedGeoPolygon* polygon) {
42
45
  * @return Pointer to loop
43
46
  */
44
47
  LinkedGeoLoop* addNewLinkedLoop(LinkedGeoPolygon* polygon) {
45
- LinkedGeoLoop* loop = calloc(1, sizeof(*loop));
48
+ LinkedGeoLoop* loop = H3_MEMORY(calloc)(1, sizeof(*loop));
46
49
  assert(loop != NULL);
47
50
  return addLinkedLoop(polygon, loop);
48
51
  }
@@ -71,7 +74,7 @@ LinkedGeoLoop* addLinkedLoop(LinkedGeoPolygon* polygon, LinkedGeoLoop* loop) {
71
74
  * @return Pointer to the coordinate
72
75
  */
73
76
  LinkedGeoCoord* addLinkedCoord(LinkedGeoLoop* loop, const GeoCoord* vertex) {
74
- LinkedGeoCoord* coord = malloc(sizeof(*coord));
77
+ LinkedGeoCoord* coord = H3_MEMORY(malloc)(sizeof(*coord));
75
78
  assert(coord != NULL);
76
79
  *coord = (LinkedGeoCoord){.vertex = *vertex, .next = NULL};
77
80
  LinkedGeoCoord* last = loop->last;
@@ -95,7 +98,7 @@ void destroyLinkedGeoLoop(LinkedGeoLoop* loop) {
95
98
  for (LinkedGeoCoord* currentCoord = loop->first; currentCoord != NULL;
96
99
  currentCoord = nextCoord) {
97
100
  nextCoord = currentCoord->next;
98
- free(currentCoord);
101
+ H3_MEMORY(free)(currentCoord);
99
102
  }
100
103
  }
101
104
 
@@ -115,14 +118,14 @@ void H3_EXPORT(destroyLinkedPolygon)(LinkedGeoPolygon* polygon) {
115
118
  currentLoop != NULL; currentLoop = nextLoop) {
116
119
  destroyLinkedGeoLoop(currentLoop);
117
120
  nextLoop = currentLoop->next;
118
- free(currentLoop);
121
+ H3_MEMORY(free)(currentLoop);
119
122
  }
120
123
  nextPolygon = currentPolygon->next;
121
124
  if (skip) {
122
125
  // do not free the input polygon
123
126
  skip = false;
124
127
  } else {
125
- free(currentPolygon);
128
+ H3_MEMORY(free)(currentPolygon);
126
129
  }
127
130
  }
128
131
  }
@@ -242,9 +245,10 @@ static const LinkedGeoPolygon* findPolygonForHole(
242
245
  }
243
246
  // Initialize arrays for candidate loops and their bounding boxes
244
247
  const LinkedGeoPolygon** candidates =
245
- malloc(polygonCount * sizeof(LinkedGeoPolygon*));
248
+ H3_MEMORY(malloc)(polygonCount * sizeof(LinkedGeoPolygon*));
246
249
  assert(candidates != NULL);
247
- const BBox** candidateBBoxes = malloc(polygonCount * sizeof(BBox*));
250
+ const BBox** candidateBBoxes =
251
+ H3_MEMORY(malloc)(polygonCount * sizeof(BBox*));
248
252
  assert(candidateBBoxes != NULL);
249
253
 
250
254
  // Find all polygons that contain the loop
@@ -267,8 +271,8 @@ static const LinkedGeoPolygon* findPolygonForHole(
267
271
  findDeepestContainer(candidates, candidateBBoxes, candidateCount);
268
272
 
269
273
  // Free allocated memory
270
- free(candidates);
271
- free(candidateBBoxes);
274
+ H3_MEMORY(free)(candidates);
275
+ H3_MEMORY(free)(candidateBBoxes);
272
276
 
273
277
  return parent;
274
278
  }
@@ -308,11 +312,12 @@ int normalizeMultiPolygon(LinkedGeoPolygon* root) {
308
312
  // Create an array to hold all of the inner loops. Note that
309
313
  // this array will never be full, as there will always be fewer
310
314
  // inner loops than outer loops.
311
- LinkedGeoLoop** innerLoops = malloc(loopCount * sizeof(LinkedGeoLoop*));
315
+ LinkedGeoLoop** innerLoops =
316
+ H3_MEMORY(malloc)(loopCount * sizeof(LinkedGeoLoop*));
312
317
  assert(innerLoops != NULL);
313
318
 
314
319
  // Create an array to hold the bounding boxes for the outer loops
315
- BBox* bboxes = malloc(loopCount * sizeof(BBox));
320
+ BBox* bboxes = H3_MEMORY(malloc)(loopCount * sizeof(BBox));
316
321
  assert(bboxes != NULL);
317
322
 
318
323
  // Get the first loop and unlink it from root
@@ -349,14 +354,14 @@ int normalizeMultiPolygon(LinkedGeoPolygon* root) {
349
354
  // been unlinked from the root and the caller will no longer have
350
355
  // a way to destroy it with destroyLinkedPolygon.
351
356
  destroyLinkedGeoLoop(innerLoops[i]);
352
- free(innerLoops[i]);
357
+ H3_MEMORY(free)(innerLoops[i]);
353
358
  resultCode = NORMALIZATION_ERR_UNASSIGNED_HOLES;
354
359
  }
355
360
  }
356
361
 
357
362
  // Free allocated memory
358
- free(innerLoops);
359
- free(bboxes);
363
+ H3_MEMORY(free)(innerLoops);
364
+ H3_MEMORY(free)(bboxes);
360
365
 
361
366
  return resultCode;
362
367
  }
@@ -20,11 +20,11 @@
20
20
  * an origin index.
21
21
  */
22
22
  #include <assert.h>
23
- #include <faceijk.h>
24
23
  #include <inttypes.h>
25
24
  #include <math.h>
26
25
  #include <stdlib.h>
27
26
  #include <string.h>
27
+
28
28
  #include "baseCells.h"
29
29
  #include "faceijk.h"
30
30
  #include "h3Index.h"
@@ -18,9 +18,11 @@
18
18
  */
19
19
 
20
20
  #include "polygon.h"
21
+
21
22
  #include <float.h>
22
23
  #include <math.h>
23
24
  #include <stdbool.h>
25
+
24
26
  #include "bbox.h"
25
27
  #include "constants.h"
26
28
  #include "geoCoord.h"
@@ -18,6 +18,7 @@
18
18
  */
19
19
 
20
20
  #include "vec2d.h"
21
+
21
22
  #include <math.h>
22
23
  #include <stdio.h>
23
24
 
@@ -18,6 +18,7 @@
18
18
  */
19
19
 
20
20
  #include "vec3d.h"
21
+
21
22
  #include <math.h>
22
23
 
23
24
  /**
@@ -0,0 +1,134 @@
1
+ /*
2
+ * Copyright 2020 Uber Technologies, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /** @file vertex.h
17
+ * @brief Functions for working with cell vertexes.
18
+ */
19
+
20
+ #include "vertex.h"
21
+
22
+ #include "baseCells.h"
23
+ #include "faceijk.h"
24
+ #include "geoCoord.h"
25
+ #include "h3Index.h"
26
+
27
+ #define DIRECTION_INDEX_OFFSET 2
28
+
29
+ /** @brief Table of direction-to-face mapping for each pentagon
30
+ *
31
+ * Note that faces are in directional order, starting at J_AXES_DIGIT.
32
+ * This table is generated by the generatePentagonDirectionFaces script.
33
+ */
34
+ static const PentagonDirectionFaces pentagonDirectionFaces[NUM_PENTAGONS] = {
35
+ {4, {4, 0, 2, 1, 3}}, {14, {6, 11, 2, 7, 1}},
36
+ {24, {5, 10, 1, 6, 0}}, {38, {7, 12, 3, 8, 2}},
37
+ {49, {9, 14, 0, 5, 4}}, {58, {8, 13, 4, 9, 3}},
38
+ {63, {11, 6, 15, 10, 16}}, {72, {12, 7, 16, 11, 17}},
39
+ {83, {10, 5, 19, 14, 15}}, {97, {13, 8, 17, 12, 18}},
40
+ {107, {14, 9, 18, 13, 19}}, {117, {15, 19, 17, 18, 16}},
41
+ };
42
+
43
+ /**
44
+ * Get the number of CCW rotations of the cell's vertex numbers
45
+ * compared to the directional layout of its neighbors.
46
+ * @return Number of CCW rotations for the cell
47
+ */
48
+ int vertexRotations(H3Index cell) {
49
+ // Get the face and other info for the origin
50
+ FaceIJK fijk;
51
+ _h3ToFaceIjk(cell, &fijk);
52
+ int baseCell = H3_EXPORT(h3GetBaseCell)(cell);
53
+ int cellLeadingDigit = _h3LeadingNonZeroDigit(cell);
54
+
55
+ // get the base cell face
56
+ FaceIJK baseFijk;
57
+ _baseCellToFaceIjk(baseCell, &baseFijk);
58
+
59
+ int ccwRot60 = _baseCellToCCWrot60(baseCell, fijk.face);
60
+
61
+ if (_isBaseCellPentagon(baseCell)) {
62
+ // Find the appropriate direction-to-face mapping
63
+ PentagonDirectionFaces dirFaces;
64
+ for (int p = 0; p < NUM_PENTAGONS; p++) {
65
+ if (pentagonDirectionFaces[p].baseCell == baseCell) {
66
+ dirFaces = pentagonDirectionFaces[p];
67
+ break;
68
+ }
69
+ }
70
+
71
+ // additional CCW rotation for polar neighbors or IK neighbors
72
+ if (fijk.face != baseFijk.face &&
73
+ (_isBaseCellPolarPentagon(baseCell) ||
74
+ fijk.face ==
75
+ dirFaces.faces[IK_AXES_DIGIT - DIRECTION_INDEX_OFFSET])) {
76
+ ccwRot60 = (ccwRot60 + 1) % 6;
77
+ }
78
+
79
+ // Check whether the cell crosses a deleted pentagon subsequence
80
+ if (cellLeadingDigit == JK_AXES_DIGIT &&
81
+ fijk.face ==
82
+ dirFaces.faces[IK_AXES_DIGIT - DIRECTION_INDEX_OFFSET]) {
83
+ // Crosses from JK to IK: Rotate CW
84
+ ccwRot60 = (ccwRot60 + 5) % 6;
85
+ } else if (cellLeadingDigit == IK_AXES_DIGIT &&
86
+ fijk.face ==
87
+ dirFaces.faces[JK_AXES_DIGIT - DIRECTION_INDEX_OFFSET]) {
88
+ // Crosses from IK to JK: Rotate CCW
89
+ ccwRot60 = (ccwRot60 + 1) % 6;
90
+ }
91
+ }
92
+ return ccwRot60;
93
+ }
94
+
95
+ /** @brief Hexagon direction to vertex number relationships (same face).
96
+ * Note that we don't use direction 0 (center).
97
+ */
98
+ static const int directionToVertexNumHex[NUM_DIGITS] = {
99
+ INVALID_DIGIT, 3, 1, 2, 5, 4, 0};
100
+
101
+ /** @brief Pentagon direction to vertex number relationships (same face).
102
+ * Note that we don't use directions 0 (center) or 1 (deleted K axis).
103
+ */
104
+ static const int directionToVertexNumPent[NUM_DIGITS] = {
105
+ INVALID_DIGIT, INVALID_DIGIT, 1, 2, 4, 3, 0};
106
+
107
+ /**
108
+ * Get the first vertex number for a given direction. The neighbor in this
109
+ * direction is located between this vertex number and the next number in
110
+ * sequence.
111
+ * @returns The number for the first topological vertex, or INVALID_VERTEX_NUM
112
+ * if the direction is not valid for this cell
113
+ */
114
+ int vertexNumForDirection(const H3Index origin, const Direction direction) {
115
+ int isPentagon = H3_EXPORT(h3IsPentagon)(origin);
116
+ // Check for invalid directions
117
+ if (direction == CENTER_DIGIT || direction >= INVALID_DIGIT ||
118
+ (isPentagon && direction == K_AXES_DIGIT))
119
+ return INVALID_VERTEX_NUM;
120
+
121
+ // Determine the vertex rotations for this cell
122
+ int rotations = vertexRotations(origin);
123
+
124
+ // Find the appropriate vertex, rotating CCW if necessary
125
+ if (isPentagon) {
126
+ return (directionToVertexNumPent[direction] + NUM_PENT_VERTS -
127
+ rotations) %
128
+ NUM_PENT_VERTS;
129
+ } else {
130
+ return (directionToVertexNumHex[direction] + NUM_HEX_VERTS -
131
+ rotations) %
132
+ NUM_HEX_VERTS;
133
+ }
134
+ }
@@ -18,11 +18,14 @@
18
18
  */
19
19
 
20
20
  #include "vertexGraph.h"
21
+
21
22
  #include <assert.h>
22
23
  #include <math.h>
23
24
  #include <stdint.h>
24
25
  #include <stdio.h>
25
26
  #include <stdlib.h>
27
+
28
+ #include "alloc.h"
26
29
  #include "geoCoord.h"
27
30
 
28
31
  /**
@@ -33,7 +36,7 @@
33
36
  */
34
37
  void initVertexGraph(VertexGraph* graph, int numBuckets, int res) {
35
38
  if (numBuckets > 0) {
36
- graph->buckets = calloc(numBuckets, sizeof(VertexNode*));
39
+ graph->buckets = H3_MEMORY(calloc)(numBuckets, sizeof(VertexNode*));
37
40
  assert(graph->buckets != NULL);
38
41
  } else {
39
42
  graph->buckets = NULL;
@@ -53,7 +56,7 @@ void destroyVertexGraph(VertexGraph* graph) {
53
56
  while ((node = firstVertexNode(graph)) != NULL) {
54
57
  removeVertexNode(graph, node);
55
58
  }
56
- free(graph->buckets);
59
+ H3_MEMORY(free)(graph->buckets);
57
60
  }
58
61
 
59
62
  /**
@@ -91,7 +94,7 @@ void _initVertexNode(VertexNode* node, const GeoCoord* fromVtx,
91
94
  VertexNode* addVertexNode(VertexGraph* graph, const GeoCoord* fromVtx,
92
95
  const GeoCoord* toVtx) {
93
96
  // Make the new node
94
- VertexNode* node = malloc(sizeof(VertexNode));
97
+ VertexNode* node = H3_MEMORY(malloc)(sizeof(VertexNode));
95
98
  assert(node != NULL);
96
99
  _initVertexNode(node, fromVtx, toVtx);
97
100
  // Determine location
@@ -108,7 +111,7 @@ VertexNode* addVertexNode(VertexGraph* graph, const GeoCoord* fromVtx,
108
111
  if (geoAlmostEqual(&currentNode->from, fromVtx) &&
109
112
  geoAlmostEqual(&currentNode->to, toVtx)) {
110
113
  // already exists, bail
111
- free(node);
114
+ H3_MEMORY(free)(node);
112
115
  return currentNode;
113
116
  }
114
117
  if (currentNode->next != NULL) {
@@ -150,7 +153,7 @@ int removeVertexNode(VertexGraph* graph, VertexNode* node) {
150
153
  }
151
154
  }
152
155
  if (found) {
153
- free(node);
156
+ H3_MEMORY(free)(node);
154
157
  graph->size--;
155
158
  return 0;
156
159
  }
@@ -0,0 +1,2 @@
1
+ dist/
2
+ node_modules/
@@ -0,0 +1,57 @@
1
+ ### Node ###
2
+ # Logs
3
+ logs
4
+ *.log
5
+ npm-debug.log*
6
+
7
+ # Runtime data
8
+ pids
9
+ *.pid
10
+ *.seed
11
+ *.pid.lock
12
+
13
+ # Directory for instrumented libs generated by jscoverage/JSCover
14
+ lib-cov
15
+
16
+ # Coverage directory used by tools like istanbul
17
+ coverage
18
+
19
+ # nyc test coverage
20
+ .nyc_output
21
+
22
+ # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
23
+ .grunt
24
+
25
+ # node-waf configuration
26
+ .lock-wscript
27
+
28
+ # Compiled binary addons (http://nodejs.org/api/addons.html)
29
+ build/Release
30
+
31
+ # Dependency directories
32
+ node_modules
33
+ jspm_packages
34
+
35
+ # Optional npm cache directory
36
+ .npm
37
+
38
+ # Optional eslint cache
39
+ .eslintcache
40
+
41
+ # Optional REPL history
42
+ .node_repl_history
43
+
44
+ # Output of 'npm pack'
45
+ *.tgz
46
+
47
+ # Yarn Integrity file
48
+ .yarn-integrity
49
+
50
+
51
+ # Gatsby context
52
+ .gatsby-context.js
53
+
54
+ # Bundle stats
55
+ bundle-stats.json
56
+
57
+ package-lock.json
@@ -0,0 +1 @@
1
+ v10.17.0
@@ -1,24 +1,26 @@
1
1
  # H3 Documentation Website
2
2
 
3
- This is the source for the [H3 documentation website](https://uber.github.io/h3/).
3
+ This is the source for the [H3 documentation website](https://h3geo.org/).
4
4
 
5
5
  The source of the pages in the documentation is in the [docs](../docs) directory.
6
6
 
7
7
  ## Building Locally
8
8
 
9
- Building the documentation requires Node.js. To build and view the H3 documentation,
9
+ Building the documentation requires Node.js. To build and view the H3 documentation,
10
10
  run the following from `./website`:
11
11
 
12
12
  ```
13
- npm install
14
- npm run build
15
- npm start
13
+ yarn
14
+ yarn run build
16
15
  ```
17
16
 
17
+ You will then be able to open `public/index.html` in your browser. Note that images
18
+ will not render because they expect a `/h3/` path prefix.
19
+
18
20
  ## Updating the H3 Website
19
21
 
20
22
  Make sure your `gh-pages` branch has its remote set to the upstream repo, then
21
23
 
22
24
  ```
23
25
  make publish-website
24
- ```
26
+ ```