in src/h3lib/lib/h3Index.c [461:492]
int H3_EXPORT(uncompact)(const H3Index* compactedSet, const int numHexes,
H3Index* h3Set, const int maxHexes, const int res) {
int outOffset = 0;
for (int i = 0; i < numHexes; i++) {
if (compactedSet[i] == 0) continue;
if (outOffset >= maxHexes) {
// We went too far, abort!
return -1;
}
int currentRes = H3_GET_RESOLUTION(compactedSet[i]);
if (!_isValidChildRes(currentRes, res)) {
// Nonsensical. Abort.
return -2;
}
if (currentRes == res) {
// Just copy and move along
h3Set[outOffset] = compactedSet[i];
outOffset++;
} else {
// Bigger hexagon to reduce in size
int numHexesToGen =
H3_EXPORT(maxH3ToChildrenSize)(compactedSet[i], res);
if (outOffset + numHexesToGen > maxHexes) {
// We're about to go too far, abort!
return -1;
}
H3_EXPORT(h3ToChildren)(compactedSet[i], res, h3Set + outOffset);
outOffset += numHexesToGen;
}
}
return 0;
}