#22539 closed defect (worksforme)
Error in MAPCSS regarding LAYER and SET's ?
Reported by: | mikeho | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Core mappaint | Version: | |
Keywords: | Cc: |
Description (last modified by )
I am in the process of building some useful mapcss for JOSM. Concerning the turnouts this works, in that I have stored a corresponding graphic for each configuration.
Regarding the signals I had the idea to build the possible signal states on the fly from a few graphics (e.g. black background in front of green / red / yellow dot for ks1 / hp0 / ...).
The following works:
node z17-["railway:signal:combined:states" *= "DE-ESO:hp0"]::layer_signal_611, node z17-["railway:signal:main:states" *= "DE-ESO:hp0"]::layer_signal_611 { z-index: 611; icon-image: "icons/light_rr.png"; icon-offset-x: 0; icon-offset-y: -20; allow-overlap: true; } node z17-["railway:signal:combined:states" *= "DE-ESO:ks1"]::layer_signal_612, node z17-["railway:signal:main:states" *= "DE-ESO:ks1"]::layer_signal_612 { z-index: 612; icon-image: "icons/light_gr.png"; icon-offset-x: -5; icon-offset-y: -10; allow-overlap: true; } node z17-["railway:signal:combined:states" *= "DE-ESO:ks2"]::layer_signal_613, node z17-["railway:signal:main:states" *= "DE-ESO:ks2"]::layer_signal_613 { z-index: 613; icon-image: "icons/light_or.png"; icon-offset-x: 5; icon-offset-y: -10; allow-overlap: true; }
My idea to first remember the states via Set (classes) does not work regarding the display in connection with the layers (without ::layer___
it works))
1) get status
node["railway:signal:combined:states" *= "DE-ESO:hp0"], node["railway:signal:main:states" *= "DE-ESO:hp0"] { set .sg_hp0; } node["railway:signal:combined:states" *= "DE-ESO:ks1"], node["railway:signal:main:states" *= "DE-ESO:ks1"] { set .sg_ks1; } node["railway:signal:combined:states" *= "DE-ESO:ks2"], node["railway:signal:main:states" *= "DE-ESO:ks2"] { set .sg_ks2; }
2) display
node.sg_hp0::layer_signal_611 { z-index: 611; icon-image: "icons/light_rr.png"; icon-offset-x: 0; icon-offset-y: -20; allow-overlap: true; } node.sg_ks1::layer_signal_612 { z-index: 612; icon-image: "icons/light_gr.png"; icon-offset-x: -5; icon-offset-y: -10; allow-overlap: true; } node.sg_ks2::layer_signal_613 { z-index: 613; icon-image: "icons/light_or.png"; icon-offset-x: 5; icon-offset-y: -10; allow-overlap: true; }
Unfortunately I didn't find anything useful at wiki:Help/Styles/MapCSSImplementation. Can't JOSM do the combo of layer and sets or am I thinking wrong?
Many greetings
mikeho
Translated with www.DeepL.com/Translator (free version)
Attachments (0)
Change History (7)
comment:1 by , 2 years ago
Cc: | removed |
---|---|
Component: | Core → Core mappaint |
Description: | modified (diff) |
Resolution: | → worksforme |
Status: | new → closed |
comment:2 by , 2 years ago
Where can I find this (History - A couple of notes:) in a normal/standard documentation?
comment:3 by , 2 years ago
- See wiki:WikiProcessors#AvailableProcessors . I don't expect people to read it, but I figured I'd bring up a way to format the mapcss in a pretty/more readable format, just in case you make a bunch of mapcss tickets.
- I don't know if this is explicitly documented somewhere. But it should probably be documented in wiki:Help/Styles/Images#Includingimagesinstyles .
- See wiki:Help/Styles/MapCSSImplementation#LayerIdentifier for what the default layer is ("default"). Documentation for
prop(p_name)
says "value of the property p_name of the current layer, e.g.prop("width")
" (see wiki:Help/Styles/MapCSSImplementation#Evalexpressions )
comment:4 by , 2 years ago
- many Tanks !
- Mostly I look in wiki:Help/Styles/MapCSSImplementation to unterstand JOSM MAPCSS, but often I didn't found what I'm looking for. Who to ask for help?
Examples:
- How to get the rotation angel of a WAY in a NODE ? Coincidentally, I found the following in ticket #10217:
... icon-rotation: way; ...
but what I need is something like that (transfromed from VBA to MAPCSS):
... /* in VBA */ Dim way_angle as single way_angle = function_angel_of_way_on_node() icon-rotation = way_angle + 90 /* 90 Grad */ /* in MAPCSS ? */ ... ... ...
- How to use variabel in MAPCSS for some calculation? Are functions like SINUS, COSINUS available?
- Last question today: What about text-align or text-alignment-horizontal = left/right/centre to put text on the left or right site of a icon? The Text are values of tags:
... node|z17-["railway"*="signal"] { set sg; } ... ... node[is_prop_set("sg", "default")]::layer_signal_602 { z-index: 602; icon-image: "icons/bg_light_signal"; allow-overlap: true; } ... ... node[is_prop_set("sg", "default")]::layer_400 { z-index: 400; text-offset-x: 20; text-offset-y: 10; text: note; text-alignment-horizontal = left; /* = default, on left side of icon *******/ font-size: 12; text-color: #FFFFFF; text-halo-opacity: 1; text-halo-color: #202020; text-halo-radius: 2; text-allow-overlap: true; } node[is_prop_set("sg", "default")]::layer_401 { z-index: 402; text-offset-x: 20; text-offset-y: 0; text: fixme; text-alignment-horizontal = left; /* = default *******/ font-size: 12; text-color: #FFFFFF; text-halo-opacity: 1; text-halo-color: #202020; text-halo-radius: 2; text-allow-overlap: true; } node[is_prop_set("sg", "default")]::layer_402 { z-index: 402; text-offset-x: 20; text-offset-y: 0; text: ref; text-alignment-horizontal = right; /* on left side of icon *******/ font-size: 12; text-color: #FFFFFF; text-halo-opacity: 1; text-halo-color: #202020; text-halo-radius: 2; text-allow-overlap: true; } ...
thanks, mikeho
comment:5 by , 2 years ago
- #josm on OFTC IRC has some activity. I'm on it, but only Monday-Thursday.
- Not currently possible. Sorry.
- Assuming SINUS and COSINUS are sin/cosine functions, they are available (see Help/Styles/MapCSSImplementation#Evalexpressions , specifically look for "asin, atan, atan2, ceil, cos, cosh, exp, floor, log, max, min, mod (since r17759), random, round, signum, sin, sinh, sqrt, tan, tanh"). To use a variable, set the variable first (e.g.
_x: someValue
) and then useprop("_x")
to get it back. You can do something like_x: 5; _angle: cos(prop("_x"));
. - Have you looked at
text-anchor-horizontal
?
comment:6 by , 2 years ago
additional question:
who to get osmstimestamp in a format like this: YYYY-MM-DD hh:mm:ss
comment:7 by , 2 years ago
I don't believe we currently have that as an option. You *can* get the time (in seconds) since the epoch though.
A couple of notes:
cc
-- the reporter will get replies sent to them.{{{#!mapcss
}}}
. Example:.png
to theicon-image
paths -- JOSM will automatically try.png
and.svg
.set
operation in (1) on the "default" layer. So you want to use prop(p_name, layer_name) or the equivalent foris_prop_set
in (2), depending upon what you are trying to do. Example: