in lib/h3core.js [1510:1528]
export function localIjToCell(origin, coords) {
// Validate input coords
if (!coords || typeof coords.i !== 'number' || typeof coords.j !== 'number') {
throw new Error('Coordinates must be provided as an {i, j} object');
}
// Allocate memory for the CoordIJ struct and an H3 index to hold the return value
const ij = C._malloc(SZ_COORDIJ);
const out = C._malloc(SZ_H3INDEX);
storeCoordIJ(ij, coords);
try {
throwIfError(
H3.localIjToCell(...h3IndexToSplitLong(origin), ij, LOCAL_IJ_DEFAULT_MODE, out)
);
return validateH3Index(readH3IndexFromPointer(out));
} finally {
C._free(ij);
C._free(out);
}
}