[Mapcss] Nesting Selectors

Thomas Davie tom.davie at gmail.com
Sat Apr 28 00:53:27 BST 2012


Warning: not very CSS like proposal coming up!

I've recently been toying with how to optimise OpenStreetPad's stylesheet code, and found that a large gain could be found by supporting the exit; statement in MapCSS, and allowing lots of checking to be omitted by stopping checking rules after a certain one had matched.  This has made OSP about 20 times faster at styling using its default style sheet.

However... I want to go further.  A second way to be able to omit checks, and to add more expressivity to the language, would be to allow nesting of MapCSS selectors like this:

> way[highway]
> {
>   width: 8pt;
>   color: rgb(1.0, 1.0, 1.0);
>   casing-width: 1pt;
>   casing-color: rgb(0.5, 0.5, 0.5);
>   
>   z-index: 100;
> 
>   text-position: line;
>   
>   font-family: Helvetica;
>   font-size: 12pt;
>   text-color: black;
>   text-offset: 6;
>   text-halo-radius: 2pt;
>   text-halo-color: white;
> 
>   way|z16-[highway],
>   way|z12-[highway="motorway"],
>   way|z14-[highway="trunk"],
>   way|z15-[highway="primary"]
>   {
>     text: tag("name");
>   }
>   
>   way[highway="motorway"],
>   way[highway="motorway_link"]
>   {
>     width: 16pt;
>     z-index: 100.5;
>     color: rgb(0.745 , 0.784, 1.0);
>     font-size: 14pt;
>   }
>   
>   exit;
> }

This would allow an object to be checked for the existence of a highway tag (for example) exactly once, but still allow fine grained control over how each different highway= value should be rendered.  More so, it allows the user to add details (like for example, access=no highways rendering with red dots on them) to the way of that type much more easily, as they can simply add a nested selector inside the highway selector.

Before I ran off and implemented this, I wanted to run it past everyone – is this viable?

Thanks

Tom Davie


More information about the Mapcss mailing list