Modify

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#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 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)

Attachments (0)

Change History (7)

comment:1 by taylor.smock, 2 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;
    }
    

comment:2 by mikeho, 2 years ago

Where can I find this (History - A couple of notes:) in a normal/standard documentation?

comment:3 by taylor.smock, 2 years ago

  1. 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.
  2. I don't know if this is explicitly documented somewhere. But it should probably be documented in wiki:Help/Styles/Images#Includingimagesinstyles .
  3. 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 mikeho, 2 years ago

  1. many Tanks !
  2. 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:

  1. 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 ? */
...
...
...
  1. How to use variabel in MAPCSS for some calculation? Are functions like SINUS, COSINUS available?
  1. 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

Last edited 2 years ago by taylor.smock (previous) (diff)

comment:5 by taylor.smock, 2 years ago

  1. #josm on OFTC IRC has some activity. I'm on it, but only Monday-Thursday.
  2. Not currently possible. Sorry.
  3. 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 use prop("_x") to get it back. You can do something like _x: 5; _angle: cos(prop("_x"));.
  4. Have you looked at text-anchor-horizontal?

comment:6 by mikeho, 2 years ago

additional question:
who to get osmstimestamp in a format like this: YYYY-MM-DD hh:mm:ss

comment:7 by taylor.smock, 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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.