ext/h3/src/src/h3lib/include/h3Index.h in h3-3.6.2 vs ext/h3/src/src/h3lib/include/h3Index.h in h3-3.7.1
- old
+ new
@@ -44,10 +44,16 @@
#define H3_RESERVED_OFFSET 56
/** The number of bits in a single H3 resolution digit. */
#define H3_PER_DIGIT_OFFSET 3
+/** 1 in the highest bit, 0's everywhere else. */
+#define H3_HIGH_BIT_MASK ((uint64_t)(1) << H3_MAX_OFFSET)
+
+/** 0 in the highest bit, 1's everywhere else. */
+#define H3_HIGH_BIT_MASK_NEGATIVE (~H3_HIGH_BIT_MASK)
+
/** 1's in the 4 mode bits, 0's everywhere else. */
#define H3_MODE_MASK ((uint64_t)(15) << H3_MODE_OFFSET)
/** 0's in the 4 mode bits, 1's everywhere else. */
#define H3_MODE_MASK_NEGATIVE (~H3_MODE_MASK)
@@ -72,16 +78,32 @@
/** 1's in the 3 bits of res 15 digit bits, 0's everywhere else. */
#define H3_DIGIT_MASK ((uint64_t)(7))
/** 0's in the 7 base cell bits, 1's everywhere else. */
-#define H3_DIGIT_MASK_NEGATIVE (~H3_DIGIT_MASK_NEGATIVE)
+#define H3_DIGIT_MASK_NEGATIVE (~H3_DIGIT_MASK)
-/** H3 index with mode 0, res 0, base cell 0, and 7 for all index digits. */
+/**
+ * H3 index with mode 0, res 0, base cell 0, and 7 for all index digits.
+ * Typically used to initialize the creation of an H3 cell index, which
+ * expects all direction digits to be 7 beyond the cell's resolution.
+ */
#define H3_INIT (UINT64_C(35184372088831))
/**
+ * Gets the highest bit of the H3 index.
+ */
+#define H3_GET_HIGH_BIT(h3) ((int)((((h3)&H3_HIGH_BIT_MASK) >> H3_MAX_OFFSET)))
+
+/**
+ * Sets the highest bit of the h3 to v.
+ */
+#define H3_SET_HIGH_BIT(h3, v) \
+ (h3) = (((h3)&H3_HIGH_BIT_MASK_NEGATIVE) | \
+ (((uint64_t)(v)) << H3_MAX_OFFSET))
+
+/**
* Gets the integer mode of h3.
*/
#define H3_GET_MODE(h3) ((int)((((h3)&H3_MODE_MASK) >> H3_MODE_OFFSET)))
/**
@@ -141,19 +163,30 @@
<< ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
(((uint64_t)(digit)) \
<< ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
/**
- * Invalid index used to indicate an error from geoToH3 and related functions.
+ * Invalid index used to indicate an error from geoToH3 and related functions
+ * or missing data in arrays of h3 indices. Analogous to NaN in floating point.
*/
-#define H3_INVALID_INDEX 0
+#define H3_NULL 0
+/*
+ * Return codes for compact
+ */
+
+#define COMPACT_SUCCESS 0
+#define COMPACT_LOOP_EXCEEDED -1
+#define COMPACT_DUPLICATE -2
+#define COMPACT_ALLOC_FAILED -3
+
void setH3Index(H3Index* h, int res, int baseCell, Direction initDigit);
int isResClassIII(int res);
// Internal functions
int _h3ToFaceIjkWithInitializedFijk(H3Index h, FaceIJK* fijk);
+void _h3ToFaceIjk(H3Index h, FaceIJK* fijk);
H3Index _faceIjkToH3(const FaceIJK* fijk, int res);
Direction _h3LeadingNonZeroDigit(H3Index h);
H3Index _h3RotatePent60ccw(H3Index h);
H3Index _h3RotatePent60cw(H3Index h);
H3Index _h3Rotate60ccw(H3Index h);