mapbox / mapnik-vector-tile

Mapnik implemention of Mapbox Vector Tile specification
BSD 3-Clause "New" or "Revised" License
552 stars 117 forks source link

Mapnik vector tile performance #276

Closed am2222 closed 6 years ago

am2222 commented 6 years ago

Hi, I want to use mapnik vector tile library to save osm data from pbf as vector tiles and save them into a database with x,y,z information. later I can try to load them again using mapnik and I think it must have a better performance than loading pbf using mapniks input plugins. well here there are some problems:

flippmoke commented 6 years ago

first of all mapnik vector tiles does not support mapnik 3.1.X

The master branch should support mapnik 3.1.x currently

well do you think I have to write a mapnik input plugin to use vactor tiles saved in database?

It would probably be easier to simply use a vector tile buffer you pulled from the database and then use that for processing directly using mapnik-vector-tile.

what about performance? do you think it increases performance while rendering? thanks

Eliminating the time to build data via a query is an important reason we use vector tiles. So yes, it definitely can be more performant.

What is your end goal here? Do you need to re-invent the wheel? There are lots of services to host vector tiles or software prebuilt to serve tiles directly. Its often easier to simply put tiles in a directory rather in a database.

am2222 commented 6 years ago

@flippmoke thanks for your fast reply, as a matter of fact I want to render osm data using mapnik, firstly I converted them into spatialite datasource and as mapnik supports this input plugin I tried to render them, it works well but the performance is not good on my device. so I decieded to use vector tiles. now I want to render all tiles of my area and save them, I have no idea if there is a better way to serve those tiles. I thought if I save them in a mbtile schema database it would be good, I can query tiles using x,y,z (as I am currently doing that in one of my own mapik input plugins to read raster data from mbtile datasource ) and later render them. is there any better way or tool to make vector tiles from pbf or store them? I can not use servers or such things as I have a limited portable device and it does not have much ram and cpu . thanks

flippmoke commented 6 years ago

@am2222 does the portable device have a gpu?

flippmoke commented 6 years ago

I am obviously somewhat biased here as I work for Mapbox, but I would try to use a service to provide OSM tiles if you can (or offline OSM tiles if connectivity is an issue), such as Mapbox. Constantly providing OSM data is hard -- as is properly crafting a good set of vector tiles from the OSM data. I know that in almost every circumstance its cheaper in the long run to use a service (Mapbox or another). I would look around at your options before committing to making it all yourself. If I had a GPU on the mobile device I would not use Mapnik, but rather would use Mapbox-GL-Native (also open source, but SDKs exist for many devices prebuilt). Rendering on the GPU frees up other actions with the CPU and makes for more interactive maps.

am2222 commented 6 years ago

@flippmoke yes it has a gpu too. I must give a try to Mapbox-GL as you said. I can use osm pre-redered tiles and I must render them myself but I have no idea if there is any osm vector tiles available somewhere. I also have problem with building mapnik vector tile against existing mapnik vesion, can you please help me about it?

flippmoke commented 6 years ago

@am2222

I have no idea if there is any osm vector tiles available somewhere. Mapbox has a setup to allow you style vector tiles and use a prebuilt set of OSM data. There is a nice GUI to edit vector tile's styles before using them in Mapbox-GL. There is also Mapbox Studio Classic for older mapnik rendered vector tiles that can be delivered as images.

https://www.mapbox.com/install/ is probably a good start page.

Just to be more balanced, there is also https://openmaptiles.org/ as well that provides OSM vector tiles.

I also have problem with building mapnik vector tile against existing mapnik vesion, can you please help me about it?

I would suggest using v1.6.0 tag of mapnik-vector-tile with v3.0.18 tag of mapnik for building. We have some prebuilt binaries of these that are used in the testing of mapnik-vector-tile via mason. If you examine the make system of mapnik-vector-tile you will see some of this, it helps with dependencies etc.

If you are using node/js - there is already both of these prebuilt together by using node-mapnik -- which we provide binaries of for a few systems.

am2222 commented 6 years ago

@flippmoke thanks very much for your detailed reply. openmaptiles helps me a lot, I noticed it is in pbf format, I hope there was not any need to convert pbfs to other formats.

flippmoke commented 6 years ago

@am2222 will you close this issue when you don't need any more help 👍