Composite documentation / question
Hey,
we've dabbled in vector compositing using composite and compositeSync.
Composites works as expected when we composite two tiles with different layers, such as:
Source A: Layer 1
Source B: Layer 2
Result: Composite tiles contain Layer 1 and Layer 2
However when we combine sources containing the same layers, where each layer is not overlapping or partially overlapping within a tile, we're not seeing the expected results:
Source A: Layer 1
Source B: Layer 1
Result: Composite tiles contain Layer 1, but only from Source A
Illustrated with a few screenshots:
Source A:

Source B:

Actual result of composite from Source A and B:

Expected result:

Is this as expected, or are our expectations a bit off? Is there any flag/option to enable this layer-by-layer composition we're trying to achieve?
@kristfal
We have talked internally about how to achieve this for some time but it is really not a simple solution, because it could be the compositing of very different layers. This all originates from the V2 vector tile specification requiring that vector tiles do not contain two layers of the same name.
Some problems that could exist should we "merge" layers -- not looking for answers, just explaining problems right now:
Repeated Feature IDs:
Assuming two feature ids are the same do you merge them? What if the properties of those features are different? What if they are different geometry types?
Buffers + "Glue"
Assuming two tiles of higher zoom level are being composited into a new tile at a lower zoom level. How do you merge the layers together, if you do not they would have strange lines in them possibly along the seams, and if they have buffers this makes it more complex. Do you merge only on like feature ids? What about if it is two polygons with the same properties, does a user understand it is merging only on feature ids? (Then they would ask -- how can I edit my feature ids -- which isn't easy to do).
Alright so now, we decide on what to merge, what type of union methodology do we use? This could be complex with multi polygons and multiline strings?
In Summary
We really want to get to the point where we can do this -- its just something we are going to have to take some time and think out a very good solution.
@flippmoke Thanks for the input. I now understand that it is quite complicated to solve. We'll figure out a different way of solving our composite needs on our end, thanks for the solid response.
@kristfal if you are interested in working on the compositing problem in node-mapnik we :heart: well tested pull requests :)
@kristfal did you ever find a solution for this you'd be happy to share? We are not as concerned about zoom issues or feature conflicts, more just literal composition of features onto the same layer in an efficient way that doesn't involve obtaining the geojson, merging the features and pushing back into the vector tile.
Any possible thoughts?
@cammanderson we abandoned the idea and decided to do composition in postgis instead.
If you are serving data that changes rapidly, I'd suggest looking into tilelive and tilelive-bridge, as those tools will allow you do serve directly from 'live' sources such as postgis.