mapbox/geojson-vt

Generate exact single tile

Opened this issue · 2 comments

I'm creating server endpoint wich serves vector tile from elasticsearch. I'm querying geojson features for tile from elasticsearch and want geojson-vt to generate exact tile, without its parents to be more cpu-efficient. Is it possible with geojson-vt?

const geojson = get_features_within_tile(z, x, y);
const tileIndex = geojsonvt(geojson, { /* some magic options */ });
const tile = tileIndex.getTile(z, x, y);

// this is what i want
const tiles_generated_count = Object.keys(tileIndex.tiles).length;
console.assert(tiles_generated_count == 1);

There's no way to do that currently, since geojson-vt generates tiles top-down recursively (more info) — first slicing out z0 tile, then doing 4 z1 tiles, etc.

But I think it'd make sense to add such a feature because a similar one was implemented for the C++ port mapbox/geojson-vt-cpp#65 cc @asheemmamoowala