in lib/h3core.js [1203:1243]
export function uncompactCells(compactedSet, res) {
validateRes(res);
if (!compactedSet || !compactedSet.length) {
return [];
}
// Set up input set
const count = compactedSet.length;
const set = C._calloc(count, SZ_H3INDEX);
storeArrayOfH3Indexes(set, compactedSet);
// Estimate how many hexagons we need (always overestimates if in error)
const uncompactCellSizePtr = C._malloc(SZ_INT64);
try {
throwIfError(
H3.uncompactCellsSize(set, count, UNUSED_UPPER_32_BITS, res, uncompactCellSizePtr)
);
const uncompactCellSize = validateArrayLength(
readInt64AsDoubleFromPointer(uncompactCellSizePtr)
);
// Allocate memory for uncompacted hexagons
const uncompactedSet = C._calloc(uncompactCellSize, SZ_H3INDEX);
try {
throwIfError(
H3.uncompactCells(
set,
count,
UNUSED_UPPER_32_BITS,
uncompactedSet,
uncompactCellSize,
UNUSED_UPPER_32_BITS,
res
)
);
return readArrayOfH3Indexes(uncompactedSet, uncompactCellSize);
} finally {
C._free(set);
C._free(uncompactedSet);
}
} finally {
C._free(uncompactCellSizePtr);
}
}