in lib/h3core.js [340:360]
function coordinatesToGeoPolygon(coordinates, isGeoJson) {
// Any loops beyond the first loop are holes
const numHoles = coordinates.length - 1;
const geoPolygon = C._calloc(SZ_GEOPOLYGON);
// Byte positions within the struct
const geoLoopOffset = 0;
const numHolesOffset = geoLoopOffset + SZ_GEOLOOP;
const holesOffset = numHolesOffset + SZ_INT;
// geoLoop is first part of struct
polygonArrayToGeoLoop(coordinates[0], geoPolygon + geoLoopOffset, isGeoJson);
let holes;
if (numHoles > 0) {
holes = C._calloc(numHoles, SZ_GEOLOOP);
for (let i = 0; i < numHoles; i++) {
polygonArrayToGeoLoop(coordinates[i + 1], holes + SZ_GEOLOOP * i, isGeoJson);
}
}
C.setValue(geoPolygon + numHolesOffset, numHoles, 'i32');
C.setValue(geoPolygon + holesOffset, holes, 'i32');
return geoPolygon;
}