[Mapcss] multi-strokes and subparts

Sebastian Spaeth Sebastian at SSpaeth.de
Sat Jul 10 23:06:35 BST 2010


Heureka! ceux does multi-strokes with subparts now

 I had to try quite a lot of options and rewrite a bit of code, but it
seems to work fine now. Let me describe the strategy I chose:

1) For each element, if there are only "generic" rules (without any
subparts specified), render that as one stroke/fill. So:

way [natural] {fill-opacity: 0.4;}
way [natural] {fill-color:black;}

will fill an area blackish-transparent.

2) As soon as there is at least one subpart specified that matches an
element, we won't draw the generic stroke/fill, but only the subpart ones, so
this:

way [natural=water]::area  
    { z-index: -0.1;  fill-color: #b5d6f1; color: #b0b0b0;}
way [natural=water]::label  
    { z-index: 5; width: 0; casing-width:0; text: name;}
way [natural] 
    {fill-opacity: 1.0; width: 1; color: black;}

will do 2 and not three strokes: 
  the ::area and the ::label stroke. 

It will use the style rules from the generic one as base, but rules
given for the subparts will always override the stroke style for that
subpart (even if the generic rule comes later in the file). That means
the above three rules are equivalent to these 2:

/* Next rules gets fill-opacity, width, but NOT color from the generic 
   as color is specified in the ::area rule */
way [natural=water]::area  
    { z-index: -0.1;  fill-color: #b5d6f1; color: #b0b0b0; 
      fill-opacity: 1.0; width: 1;}
/* Next rules gets fill-opacity, color, but NOT width from the generic */
way [natural=water]::label  
    { z-index: 5; width: 0; casing-width:0; text: name; 
      fill-opacity: 1.0; color:black;}


To sum it up, generic styles provide the base and subpart styles
complement and override specific styles. If there are only generic
styles, render that as 1 stroke, but as soon as there are subparts,
don't render the generic one.


In my implementation:
   way [highway]::* 
is a synonym for "way [highway]" (the generic) which matches all subparts.

In my implementation:
   way [highway]:: 
refers to a specific subpart (call it __unnamed__)

Does this make sense?

Happy SOTM or where ever you are.
Sebastian




More information about the Mapcss mailing list