[Mapcss] Stacked rules question

Sebastian Klein bastikln at googlemail.com
Fri Jul 9 09:20:39 BST 2010


Sebastian Spaeth wrote:
> On 2010-07-07, Sebastian Klein wrote:
> 
>>>     way[highway=footway] { z-index: 5; width: 1; color: green; }
>>>     way[highway=footway]::highlight  { width: 3; z-index: 2; }
>>>     way[highway=footway]::centreline { width: 2; z-index: 3; }
> 
> OK, so what does this do? 2 strokes, one at z2 and one at z3? Or 3
> strokes with the third at z5? (I presume 2 strokes is what we intent
> here)
> 
> But then, subparts become kind of obligatory and
>    way[highway=footway] { z-index: 5; width: 1; color: green; }
> this by itself wouldn't stroke anything?


Yes, it would look ugly if subparts became obligatory. The idea is that 
for a subpart to show, a selector with that subpart has to apply at 
least once for the object.

So

way[highway=footway]::highlight { width: 3; z-index: 2 }
way[highway=footway] { z-index: 5; width: 1; color: green }

or even

way[highway=footway]::highlight {}
way[highway=footway] { z-index: 5; width: 1; color: green }

shows a green highlight for footways, but

way[highway=footway] { z-index: 5; width: 1; color: green }

does not. But to avoid writing ::centerline all over the place, you can have

way::centerline {}

at the beginning of the file. (My first thought was to make it implicit, 
but need not be.)

So for evaluation, there is one style cascade for the object itself and 
one for each occurring subpart. A rule without subpart syntax overrides 
style definition for all subparts. When a new subpart is encountered, 
the new subpart style is initialized with the style for the object itself.

E.g.

way::centerline {}

[...]

way { antialiasing:none }

way[highway=footway]
   { z-index: 3; width: 1; color: green; linecap: round}

way[highway=footway][fixme=~/.*/]::highlight
   { z-index: 2; width: 10; color: red }

way[highway=footway][fixme=~/.*/]::centerline
   {dashes: 1, 1}

way[access=private] {dashes: 3, 6}


This should draw every part of the way non-anti-aliased. All footways 
would have a centreline in green and width 1. If has fixme tag, there is 
a red highlight (with round linecap) and the centreline is dashed. But 
if the way has private access, the dashing style is overridden to be "3, 
6" for both the centreline and the highlight (which is probably not 
intended).

IMHO, this would be a consistent way to deal with highlights, i.e. 
multiple styles for one object. (But I'm not trying to dictate anything, 
just a suggestion that can still be improved and refined. :)  )

So is subpart a free identifier or a keyword? At first sight I don't see 
a reason why it shouldn't be a free choice.


Sebastian






More information about the Mapcss mailing list