mapbox / mapnik-vector-tile

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

How are projections meant to be handled? #266

Closed dylanede closed 6 years ago

dylanede commented 6 years ago

I'm trying to see how to take a given map (with styling), "render" it to a vector tile, then load that vector tile in as a data source and render an image. This last step requires that the data sources of the map style are edited to point to the vector tile layer data sources. I have this mostly working - I get a rendered image, but the projection is wrong. It looks like I must alter the projections in the layers as well.

As an example, I have an original map that renders like so, with a longlat projection:

image

After writing it to a vector tile (using create_tile, passing in the extent of the map) and loading it back in then correcting the map layers to point to the vector tile data sources, I get this output:

image

It appears that as well as being projected wrong (despite still specifying longlat), the geometry is getting clipped - the southern tip of the Faroe islands is now not visible at all, and less of France is visible.

I suspect that the problem is due to me using

std::make_shared<tile_datasource_pbf>(layer, 0, 0, 0)

to create the data sources, since it appears that the x, y and z parameters are specific to web mercator tiling.

What do I need to do to get this to render correctly in longlat, with tiles also generated in longlat? I would like to retain the ability to specify tile extents explicitly in whatever projection I choose. Would this require a custom data source implementation?

Also, what coordinate system are the vector tiles stored in? Is it the same as the input map?

Thanks in advance.

flippmoke commented 6 years ago

Also, what coordinate system are the vector tiles stored in? Is it the same as the input map?

A vector tile has its own coordinate system based per tile. Basically it is much like the coordinates of an image tile. The bottom left corner of a tile being the 0,0 point. Therefore, there is no changing what the projection of the tile actually is during this process.

Overall it is difficult for me to know exactly what the problem you are running into might be with out digging into your code, could you a sample code showing your problem?