Open realfun opened 7 years ago
Hey realfun,
The IDs in mapbox s2 are corrupted because they're returning a JavaScript number
type. S2 Cell IDs are 64 bit, whereas the positive limit to the number
type in JavaScript is 53 bits (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER).
We're actively working on new bindings for the S2 C++ library over at Radar (https://github.com/radarlabs/s2) and we return a BigInt to address this issue.
Here's an example with that library:
const s2 = require('@radarlabs/s2');
const ll = new s2.LatLng(0, 0);
const cid = new s2.CellId(ll);
console.log(cid.id());
console.log(cid.parent(10).id());
console.log(cid.parent(11).id());
console.log(cid.parent(12).id());
console.log(cid.parent(13).id());
Which results in:
1152921504606846977n
1152922604118474752n
1152921779484753920n
1152921573326323712n
1152921521786716160n
I am trying to use this for a project, did a simple test like the following:
The results is like the following:
On Java lib and Golang version, it is like below:
Am I using it wrong or some misunderstanding?