Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example Code for PostGIS to VectorTile? #7

Open
brendanvinson opened this issue Mar 30, 2017 · 2 comments
Open

Example Code for PostGIS to VectorTile? #7

brendanvinson opened this issue Mar 30, 2017 · 2 comments

Comments

@brendanvinson
Copy link

brendanvinson commented Mar 30, 2017

Could we get some example code for the right way to do PostGIS -> VectorTile? RIght now my app feeds it through the stylesheet for the datasource, but since none of the style information (color, text) it doesn't seem necessary.

@springmeyer
Copy link
Member

Feeding in a Mapnik XML is the right way to generate vector tiles. You are correct that the style information in this case is ignored - however there is no harm to it being in the style still.

The critical thing when generating vector tiles is to avoid querying too much or unneeded data in your Mapnik XML datasource definitions. This is the same for when rendering image tiles if you care about performance, but it becomes even more critical with vector tiles since you want to avoid them being too large. Mapbox.com for example will not allow you to upload individual tiles > 500 Kb for example (at the time of this writing).

To avoid "querying too much" you want to be thoughtful about your SQL queries. And you likely want to use min/max zoom denominators. The Mapbox Studio Classic project helps you author Mapnik XML styles with like this that restrict zoom. There are also probably other tools out there that make this easier. Take a look at https://github.com/mapbox/awesome-vector-tiles/. I noticed (when looking at that myself) that https://github.com/faradayio/tilesplash might be interesting to you.

@brendanvinson
Copy link
Author

brendanvinson commented May 18, 2017

So the reason it goes through the Mapnik XML is to pick up the datasource, correct? What if we generate the datasource via the api (mapnik.Datasource())? The only code that's in the xml stylesheet is the actual style rules for raster tiles.

As for "querying too much", I'm unclear on how to use the denominators as passing variables through the options object for map.render() does not work for either vector or raster tiles (results in a null value where the token is), or why this is a good use case. Regardless, we're doing this some already on the viewing end in leaflet by restricting min zoom.

Side issue: size in our vector tiles is a bit of an issue (I've seen ~240kb for a pbf with un-gzipped data, where same tile was ~30kb for the png version and ~90kb for a fully compressed data pbf) as we deal with weather contours and they're fairly complex. Where is the performance benefit to vectors at this point? The browser render end?

Node 7.10
Node Mapnik 3.6

/cc @ddproxy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants