Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#22539 closed defect (worksforme)

Error in MAPCSS regarding LAYER and SET's ? — at Version 1

Reported by: mikeho Owned by: team
Priority: normal Milestone:
Component: Core mappaint Version:
Keywords: Cc:

Description (last modified by taylor.smock)

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)

Change History (1)

comment:1 by taylor.smock, 3 years ago

Cc: mikeho removed
Component: CoreCore mappaint
Description: modified (diff)
Resolution: worksforme
Status: newclosed

A couple of notes:

  1. You didn't need to add yourself to cc -- the reporter will get replies sent to them.
  2. You can format the mapcss code by wrapping it in {{{#!mapcss }}}. Example:
    {{{#!mapcss
    [mapcss here]
    }}}
    
  3. You shouldn't have to add .png to the icon-image paths -- JOSM will automatically try .png and .svg.
  4. You are doing a set operation in (1) on the "default" layer. So you want to use prop(p_name, layer_name) or the equivalent for is_prop_set in (2), depending upon what you are trying to do. Example:
    node[is_prop_set("sg_hp0", "default")]::layer_signal_611 {
        z-index: 611;
        icon-image: "icons/light_rr.png";
        icon-offset-x: 0;
        icon-offset-y: -20;
        allow-overlap: true;
    }
    
Note: See TracTickets for help on using tickets.