mapbox / geojson-vt

Slice GeoJSON into vector tiles on the fly in the browser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Serializing tile index

knownasilya opened this issue · comments

Is it possible to serialize the tile index and then recreate the JS object?

I'm looking to follow #53 to generate a full index and then store that, and use it when fetching tiles. Not sure if this is much slower then using mapnik..

You can serialize/deserialize from pbf format using the vt-pbf library.

I'm looking to serialize the full tile index, not a single tile. Basically I want to run the index on a big geojson object once and then use that to generate tiles.

I'm creating full tile indexes in a web worker and passing it back via postMessage. I'm then trying to reconstruct the object in my main process via Object.assign, but my features aren't rendering.

I tried copying the serialized message contents onto a geojson-vt instance created in my main process from the same GeoJSON data as in the web worker but the debug log from splitTile incorrectly gives

tile z15-8849-13489 (features: 2, points: 10, simplified: 0)
tile z15-8849-13488 (features: 2, points: 10, simplified: 0)
tile z15-8848-13489 (features: 2, points: 10, simplified: 0)
tile z15-8848-13488 (features: 2, points: 10, simplified: 0)

instead of the correct:

tile z15-8849-13489 (features: 2, points: 10, simplified: 10)
tile z15-8849-13488 (features: 0, points: 0, simplified: 0)
tile z15-8848-13489 (features: 0, points: 0, simplified: 0)
tile z15-8848-13488 (features: 0, points: 0, simplified: 0)

Is there a way once I have tile indexes created to be able to get splitTile and getTile to function correctly?

@mourner Would you happen to have any input on this?

@knownasilya @andrewheartsxd did you find a way to successfully serialize a full tileIndex?

No idea, been to long, I probably moved on to something else for that project.