[Mapcss] Proposal: casing-z-index

Thomas Davie tom.davie at gmail.com
Mon Feb 7 07:50:48 GMT 2011


Hi,

Thanks to Kompza and RichardF I think I've pretty much got my head wrapped round how MapCSS works.  With my inexperience in mind though, I believe I've spotted a way to significantly clean up MapCSS 0.2.

One ugly thing that all renderers seem to do is to treat the layer tag on geometry as being a special case.  The usual interpretation seems to be to treat each layer as a completely distinct map, and to composite the layers together as a final stage at the end.  The result is that unlike specifying the z-index of an element, the casings are brought above the lower elements by specifying a higher layer.

I'd like to propose a casing-z-index property as simple solution that stops this needing to be treated as a special case.  Instead, casing z-indices are specified on the exact same scale as element z-indices.

A quick example of how this might work:

way
{
  casing-z-index: eval(layer * 10); // We in general want the casing to be the lowest thing for any given "layer"
  z-index: eval(layer * 10 + 1); // And the ways drawn over the top of the casings
}

way[highway]
{
  z-index: eval(layer * 10 + 7); // We want highways to appear above everything except...
}

way[highway=trunk]
{
  casing-z-index: eval(layer * 10 + 8); // For trunk roads, we want to highlight them, so we bring the casing up above the other roads
  z-index: eval(layer * 10 + 9); // And more so, bring the road above the casing.
}

The downside of this proposal is of course that it would break existing style sheets, in that space must be left in the z-index scale to allow casings to slot in.

The upside though is that renderers need not do anything special or magical with the layer tag, simplifying code, and pushing more style into the stylesheet.

This proposal does bring up at least some extra issues.  For example, when does a shield's border get drawn, does it introduce a need for a border-z-index property?  If anyone else can think of more, please do get stuck in.

Thanks

Tom 'Beelsebob' Davie


More information about the Mapcss mailing list