mapbox / geojson-vt

Slice GeoJSON into vector tiles on the fly in the browser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Max call stack size error on a certain input

mourner opened this issue · comments

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);

cc @JamesChevalier

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).

Why mid is (last-first)/2? Shouldn't it be (first+last)/2?

(or first + (last-first)>>1 for avoiding overflow.)

Related code:

@district10 nice catch, likely a mistake (although it shouldn't affect correctness of the output at least). Want to PR a fix?

@mourner Sure. Two PRs created.