uncompact method
Uncompact a compacted set of hexagons to hexagons of the same resolution
Implementation
@override
List<BigInt> uncompact(
List<BigInt> compactedHexagons, {
required int resolution,
}) {
assert(resolution >= 0 && resolution < 16,
'Resolution must be in [0, 15] range');
return using((arena) {
final compactedHexagonsPointer = arena<Uint64>(compactedHexagons.length);
for (var i = 0; i < compactedHexagons.length; i++) {
final pointer = Pointer<Uint64>.fromAddress(
compactedHexagonsPointer.address + sizeOf<Uint64>() * i,
);
pointer.value = compactedHexagons[i].toInt();
}
final maxUncompactSize = _h3c.maxUncompactSize(
compactedHexagonsPointer,
compactedHexagons.length,
resolution,
);
if (maxUncompactSize < 0) {
throw H3Exception('Failed to uncompact');
}
final out = arena<Uint64>(maxUncompactSize);
final resultCode = _h3c.uncompact(
compactedHexagonsPointer,
compactedHexagons.length,
out,
maxUncompactSize,
resolution,
);
if (resultCode != 0) {
throw H3Exception('Failed to uncompact');
}
final list = out.asTypedList(maxUncompactSize).toList();
return list.where((e) => e != 0).map((e) => e.toBigInt()).toList();
});
}