Talk:MapCSS/0.2
Suggested improvements for MapCSS 0.2
- Clarify z-index behaviour and introduce new object-id assignment (suggestion by Komzpa)
- More CSS-like behaviour for descendant/child selectors (suggestion by Sebastian Klein):
- child: relation > node -- a node that is a member of that relation
- descendant: relation node -- a node that is a member of that relation, or whose enclosing way is a member of that relation, or whose enclosing relation is...
- Rename :area to :closed to remove ambiguity (suggestion by Sebastian Klein)
- canvas (or background) object type to define background colour etc. (suggestion by Komzpa and Sebastian Klein)
- Ability to have { interactive: no; } (or similar) so that interactive clients (e.g. Potlatch2) don't respond to mouse-clicks on that object
- Introduce a font-variant: 'normal' (default), or 'small-caps' (Update: added to spec -spaetz)
- Allow icon-width and icon-height (or icon-scale?) to use in combination with icon-image (Update: added to spec -spaetz)
- Additional keywords for line width: thinnest (thinnest possible line for the target device) This requires anti-aliasing. If this drawing style is not supported, it should fall-back to a width value to draw a more or less thin line.)
- I am not particularly in favor of a "thinnest" keyword. I think you should be able to just specify 0.01 as width and have the renderer figure out what to do with it (if it does not support subpixel, it should fallback to 1 pixel, etc). --spaetz
- Introduce right/left option for lines and casings. Use cases: embankments, cycleway:left, may be useful for areas where inside vs outside is determined by direction. Stevage 01:19, 31 January 2011 (UTC)
- Remove support for #abcdef colours and CSS colour names and replace them with rgb(0.0-1.0, 0.0-1.0, 0.0-1.0) (and variants for other colour spaces). Beelsebob 09:47, 7 February 2011 (UTC)
- Remove fill-opacity, opacity, casing-opacity, extrude-edge-opacity, extrude-face-opacity, icon-opacity and shield-opacity and roll the behaviour into the respective colour properties, by allowing colours to be specified as rgba(0.0-1.0, 0.0-1.0, 0.0-1.0, 0.0-1.0). Beelsebob 09:47, 7 February 2011 (UTC)
- Add casing-z-index, shield-z-index, text-z-index and icon-z-index to stop renderers having to treat the layer tag as a special magical case. Beelsebob 09:47, 7 February 2011 (UTC)
- Why would node [x=y] be ambiguous? Disallowing this makes parsing significantly harder. Beelsebob 19:14, 12 March 2011 (UTC)
- Add casings to icon-image or allow shields to be repurposed for nodes.
- Use casing-width, casing-color, etc. for shields as well as lines. Can't the parser tell it's working on a shield?
Dealing with z-index and cascades more sensibly
Use the CSS subpart syntax to create multiple styles for a single element. Each subpart defines its own cascade of properties.
E.g.
-
way[highway=footway] { width: 2; z-index: 3; } -
way[fixme]::fixme_highlight { width: 10; z-index: 2; color: red; text: "fixme"; font-size: 12; }
draws footways with width 2 and highlights all ways if they have the FIXME key. The subpart name is a free identifier, but there are two special subparts:
The default subpart:
-
way[highway=footway]::default { width: 3; z-index: 2; }
can be interchangeably written as
-
way[highway=footway] { width: 3; z-index: 2; }.
Otherwise it is just an ordinary subpart.
The * subpart:
It is special in 3 ways:
- It is not rendered, so it is only there for "book keeping".
- It overrides all existing subparts:
- so
-
way::A { a; } -
way::B { b; } -
way::* { c; }
-
- is equivalent to
-
way::A { a; } -
way::B { b; } -
way::A { c; } -
way::B { c; }
-
- so
- It initializes new subparts. In other words:
-
way::* { a; } -
way::A { b; }
-
- is equivalent to
-
way::A {} -
way::* { a; } -
way::A { b; }
-
- (which is in turn the same as
-
way::A { a; } -
way::A { b; }
-
- or
-
way::A { a; b; }.)
-
-- Bk 15:13, 13 July 2010 (UTC)
Declarations
- exit: RichardF said: "It's an optimisation, really - a little hackish addition to tell the parser
to stop checking any rules from this point on, in circumstances where speed is really important. I agree it shouldn't be part of the core spec." and Komяpa says "IMHO this thing was invented just for easier debugging of Halcyon and shouldn't be present in mapcss at all." so we might want to delete it from the core spec.
more on dashes
add the following properties for advanced dashes drawing:
dashes-offset: <NUM>; dashes-background-color: <COLOR>;
The offset is a number >= 0 that specifies how much to skip from the start of the pattern. Background color sets the color of the line in between the dashes. If the color is non-transparent, this can also be done with the casing property. Otherwise it can be simulated in the following way:
way {
dashes: 30, 17, 2, 5;
color: blue;
}
way::dashes-background {
dashes: 5, 30, 17, 2;
dashes-offset: 5;
color: lightblue;
}
--Bk 11:25, 26 September 2010 (BST)
Generalized selectors (area)
In addition to the OSM specific basic selectors node, way and relation, it would be useful to have more "abstract" or GIS related selectors.
For a start we could have the area selector, which selects closed ways and Multipolygons.
Currently it would select a closed way with junction=roundabout, although it does not really represent an area. When osm has a real area data type in the future, this can be changed. --Bk 15:46, 2 October 2010 (BST)
- area selector is now on the spec. If source data doesn't have relations, renderer could just not implement them. --Komяpa 10:00, 18 June 2011 (BST)
Testing for relation member roles
see subpage
fill-color vs. fill
Why not use standard W3C properties?
Dealing with areas
How is the best way to deal with areas. way[condition]:closed and area[condition] seems to be treated differently, at least in JOSM. --Skippern 18:14, 4 July 2011 (BST)
- area should cover multipolygons and closed ways. For historical reasons, JOSM handles this a bit different: Unclosed ways are included, but reported by the validator when an area style applies. Actually the abstraction can be seen as an advantage, as renderers can decide on their own, how areas are defined in detail.--Bk 19:30, 8 July 2011 (BST)
icon-image formats and scaling
What formats are supported by icon-image, and is it possible to scale the images? The reason I am asking is that I wish to use SVG graphics. In some cases I would also allow the option to scale images, either use various resolutions of the same SVG file on different zoom levels or in some cases evaluate values to determine resolution. --Skippern 01:30, 7 July 2011 (BST)
- scaling is possible. image formats depends on renderer, for now usually png is supported. --Komяpa 13:39, 8 July 2011 (BST)
- I found scaling, icon-width and icon-height are documented, but I saw a stylesheet use icon-size (not documented?), which worked for me, looking into making a ticket to accept .SVG in the renderer in question. --Skippern 15:56, 8 July 2011 (BST)
- Opened trac ticket in JOSM --Skippern 16:12, 8 July 2011 (BST)
- scaling is possible. image formats depends on renderer, for now usually png is supported. --Komяpa 13:39, 8 July 2011 (BST)
Nested rules
Will there be a rule to handle nested rules? For example one could make a nested rule for natural=wetland with subrules for wetland=* i.e. by giving a background colour in the parent rule and fill symbol in each of the sub rules.... --Skippern 12:45, 26 August 2011 (BST)
- In current practice, you would give background color in a
[natural=wetland]rule and define details in subsequent rules, that repeat the[natural=wetland]filter, a better example: way[highway=secondary] { color: yellow; width: 5; }way[highway=secondary][tunnel=yes] { dashes: 4,4; }- --Bk 17:04, 26 August 2011 (BST)
- The reason I ask this is that I am writing a set of highly complicated rules, and nesting would allow me to simplify alot. What I am looking for is something like:
way[highway=secondary] { color: yellow; width: 5; way[tunnel=yes] { dashes: 4,4: } }- --Skippern 20:18, 26 August 2011 (BST)
- Yes, I think nested rules would have a lot of potential, but maybe the idea is a little ahead of it's time...--Bk 14:59, 13 September 2011 (BST)
icon-image on areas
Shouldn't it be possible to use icon-image, or a similar rule on areas? i.e. a hospital icon rendered in the center of a hospital building polygon. --Skippern 21:17, 7 September 2011 (BST)