Max call stack size error on a certain input
mourner opened this issue · comments
Volodymyr Agafonkin commented
Originally reported at mapbox/mapbox-gl-js#6086 (comment)
Minimal test case for Node v8:
const geojsonvt = require('geojson-vt');
const coords = [];
for (let i = 0; i < 1400; i++) {
coords.push([0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]);
}
const data = {
"type": "LineString",
"coordinates": coords
};
geojsonvt(data);
James Chevalier commented
Let me know if you would like any real world testing. I'm happy to throw around beta software to see if https://citystrides.com/users/5560/map loads properly with the latest Mapbox GL JS in Safari or Chrome on a Mac (where I originally noticed the issue).
TANG ZhiXiong commented
Why mid
is (last-first)/2
? Shouldn't it be (first+last)/2
?
(or first + (last-first)>>1
for avoiding overflow.)
Related code:
Volodymyr Agafonkin commented
@district10 nice catch, likely a mistake (although it shouldn't affect correctness of the output at least). Want to PR a fix?
TANG ZhiXiong commented
@mourner Sure. Two PRs created.