mapbox / tilelive-bridge

Implements the tilelive API for generating mapnik vector tiles from traditional mapnik datasources.
BSD 3-Clause "New" or "Revised" License
63 stars 46 forks source link

Slow generating MVTs from a shapefile with only 1 feature #83

Closed tephenavies closed 8 years ago

tephenavies commented 8 years ago

I'm serving MVTs using mojodna/tessera and tilelive modules from 2 sources for the border of Australia (open data from Australian Bureau of Statistics):

The mbtiles are super fast (obviously), but the tilelive-bridge tiles are really slow. The shapefile shp.zip has only 1 feature, the outline of all of Australia in a large amount of detail:

ogrinfo -dialect SQLITE -sql "SELECT ST_NPoints(geometry) FROM FID_AUS_2011_AUST" .
...
    ST_NPoints(geometry) (Integer) = 1622598

That one feature is a MultiPolygon with 6718 polygons, but I'm fairly sure the entire mainland of Australia is done with one polygon, the rest are little islands. I'm guessing it's so slow because mapnik, behind tilelive-bridge, has to check each point in that huge polygon every time a tile is requested. I've tried using a shapeindex generated index file, with and without --index-parts, but it seems that this indexes Polygons of a MultiPolygon, not parts of the polygons within.

What should I do? I've thought of

e-n-f commented 8 years ago

Is your client limited to 4096-unit tiles or can it handle arbitrary resolution? If you can handle higher resolution, you could make your z12 tiles extremely detailed with, say, tippecanoe -z12 -d20, which would give you as much detail to overzoom from at z12 as you would normally get at z20.

tephenavies commented 8 years ago

Thanks. That worked really well.