5. Compositing
TODO: find better example foreground / background image combinations
TODO: maybe extend OSM default style with a big single red dot marker, similar to CartoCSS example page
TODO: the TileMill project also has a nice visualization of the various composition operations
Mapnik supports all compisiting modes defined in the SVG standard, a few more are available when using the Agg render only.
By default the "src-over" compositing mode is used. A different mode can be set on the <Layer>, <Style> or symbolizer level.
TODO: explain level differences
TODO: add description lines to the table below
| Mode | Description |
|---|---|
SVG standard modes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AGG-only modes |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
All examples below basically use the same XML stylesheet, with just the comp-op attribute for the red dots layer changed.
<?xml version="1.0" encoding="utf-8"?>
<Map background-color='black'>
<FileSource name="symbols">./symbols</FileSource>
<Style name="countries">
<Rule>
<PolygonSymbolizer fill="green"/>
</Rule>
</Style>
<Layer name="countries">
<StyleName>countries</StyleName>
<Datasource>
<Parameter name="type">shape</Parameter>
<Parameter name="file">data/ne_110m_admin_0_countries_lakes.shp</Parameter>
</Datasource>
</Layer>
<Style name="style" comp-op="difference">
<Rule>
<PointSymbolizer allow-overlap="true" base="symbols" file="red/dot.svg"/>
</Rule>
</Style>
<Layer name="layer">
<StyleName>style</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline">
wkt
"POINT(1 1)"
</Parameter>
</Datasource>
</Layer>
</Map>