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
Vector tiles support #8
Comments
Here is an example of the minimal workflow for merging a vector source and a style to produce an image tile: var mapnik = require('mapnik'),
fs = require('fs');
var vtile = new mapnik.VectorTile(0, 0, 0);
vtile.setData(fs.readFileSync('./test_vector_tile.pbf')); // Comes from http http://vector.mapzen.com/osm/earth,landuse,roads/0/0/0.mapbox
vtile.parse();
// console.log(vtile.names());
// console.log(JSON.stringify(vtile.toGeoJSON(0)));
var map = new mapnik.Map(vtile.width(),vtile.height());
map.fromStringSync('<?xml version="1.0" encoding="utf-8"?>'+
'<!DOCTYPE Map[]>'+
'<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" background-color="steelblue">'+
'<Style name="style" filter-mode="first">'+
' <Rule>'+
' <PolygonSymbolizer fill="#efefef" />'+
' </Rule>'+
'</Style>'+
'<Layer name="earth"'+
' srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">'+
' <StyleName>style</StyleName> </Layer>'+
'</Map>'+
'');
map.extent = [-20037508.34, -20037508.34, 20037508.34, 20037508.34];
vtile.render(map, new mapnik.Image(vtile.width(),vtile.height()), function(err, vtile_image) {
if (err) throw err;
vtile_image.save('test_vector_tile.png', 'png32');
}); One of the traps is that, we need to have those "dummy" layers (without Datasource) in the style, so the one who creates the style Mapnik XML needs not to know the source layer to be able to create it. So, basically, as I see it now, kosmtik would:
Question: should we try to follow the exact project structure and convention than a tm2 project, or should we take the liberty of some custom choices when it makes sense AND having a "tm2 compatibility layer". Option 2 means a bit of duplicate work, but in the same time I'm not sure we want to be totally reliant of tm2 choices that can change anytime in the future, so it may makes sense to promote a more generic/open vector tile project structure. |
MapQuest/avecado#31 (comment) might be relevant. Couple of things I've ran across
|
Good point; I think a kosmtik plugin (or core?) could serve that, so we have a full worflow support
But what about mapbox://a-mapbox-id?
Even if it's not the definitive answer for this, the "local config" feature of kosmtik can be of help here. See examples of my localconfig for HOT rendering (both .json and .js examples here, but only one should be used in the same time, indeed).
Good question. I think tilejson is a great standard answer for this, but in the same time being able to simply support the {z}/{x}/{y} de facto standard tile scheme should be good too, to keep things simple. Maybe a protocol can help? zxy://?
Humm, another good question. Maybe we can sniff the presence of "project.xml"? Or we can rely on the 'xxx.tm2source' convention about the folder naming when it's a source to be served, and otherwise it's a tree of tiles? |
About sources URI. We can have:
So here is a first suggestion of the URLs formats to be parsed:
Not sure about what to do when protocol is missing (tm2 project makes implicit that it's a Mapbox id, AFAIK). That's a first shot of reflection, and I'm certainly missing some points. |
Given that there's no reason a relative path can't be changed to a mapbox:// URI, I don't see a need to process a relative URI. |
Pushed a first poc, but there is still work to do:
|
There's two reasons for metatiles - efficiency and labeling. With rendering direct from database, you take a certain amount of time that is essentially independent of area rendered to go through the indexes and do at least one seek on the table. Thus, you want to render enough features at once for efficiency reasons. A 8x8 metatile probably takes about as long as 4 individual tiles. With vector tiles, you don't have that, and the only static costs is a round trip to initiate tile retrieval and setup for rendering an area. Everything else should be closer to proportional to number of features, meaning a 8x8 metatile should take closer to the time of 64 tiles. This isn't to say that there wouldn't be some throughput increase for metatiling. Labeling is... complicated. Off-hand, I'm not sure how you merge adjacent vector tiles and handle their buffer overlap. I guess what I'm saying is, don't worry about metatiles. |
I'll see what I can do. Or you could generate one for https://github.com/mapzen/vector-datasource/wiki/Mapzen-Vector-Tile-Service |
I've opened an issue for that, they seem to this: tilezen/vector-datasource#73 (I could work on a PR there but I guess I've enough to do on the kosmtik side)
One thing I've in mind is, for a given metatile, to call all the vectortiles, and then to call Not having metatile support means that we don't have the final labelling behind the eyes while working, which is not what we want indeed. Another problem is for the exports like tiles tree folder or MBTiles (I'm about to work on this, because I will need it soon). |
There's all sorts of stuff that won't work on a conceptual level, such as ordering. A couple are
The server stacks I've seen do tile by tile rendering, so labeling is the same.
I don't see why MBTiles would be an issue. You generate tile by tile and stuff them into the sqlite database. Where we'd see bigger MT gains would be MTs on generation of the vector tiles, but it's not clear there if it's worth it for continually updating data. Profiling would be required. |
It's not about the MBTiles itself. It's the fact that we can tolerate to have non optimized label placement when coding, but when we export the map (tree dir or MBTiles) to be used in some production situation, it becomes a problem. |
We should have the ability to re-order layers within the resulting Mapnik XML. Rendering order is based on that order, not the order within the vector tile. |
For now, is adding a "layers" key in you style yml an option?
Still in the style yml, you can also just add the layers name as a list in the Layer key, they will be normalized. Any other suggestion? |
I don't actually need the ability to re-order layers for my current work since I'm in control of the vector source |
Just wanted to note that TileJSON endpoints are now available for the Mapzen Vector Tile service (http://mapzen.com/vector). See tilezen/vector-datasource#73. |
Excellent! Thanks for that, I'll test that very soon :) |
This issue is very old, what is the status of vector tiles support in kosmtik? |
For what I understand now, we have those subtasks:
Though, many areas of the process remain confused for me at this point.
cc @pnorman in case you want to 1. add some elements 2. track the progress of the issue
The text was updated successfully, but these errors were encountered: