JOSM MapCSS - setting of "type: double;" does not work

In an offline mapping project of mine, I tag elements with e.g. start_year=2000. So I can filter elements by year, which I do via mapcss. The following code works fine:


way[start_year > 2000] {
    opacity: 0.1;
}

Every way that did not exist in 2000 is displayed with minimum opacity. Now I want to make the year a parameter like this:

setting::start_year_to_display {
  type: double;
  label: tr("Year of the Map");
  default: 2000;
}

way[start_year > setting("start_year_to_display")] {
    opacity: 0.1;
}

This does NOT work. Where is the mistake?

Edit: removed incorrect blank in the second code example, thanks to @alester

I’m not familiar with MapCSS and this may not be helpful, but it looks like you may have an extra space at the end of start_year_to_display on line 7. I don’t know if this would trip things up or not.

Thank you for the hint. The blank would definitely trip things up. Unfortunately the problem remains, the blank obviously creeped in during trouble shooting.

Here is a complete example for testing. A simple osm-File (the single node is just for displaying the value of the setting):

<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6' upload="never" generator='JOSM'>
  <node id='-125743' action='modify' visible='true' lat='49.92' lon='2.63' />
  <node id='-125744' action='modify' visible='true' lat='49.92' lon='2.68' />
  <node id='-125746' action='modify' visible='true' lat='49.91' lon='2.63' />
  <node id='-125747' action='modify' visible='true' lat='49.91' lon='2.68' />
  <node id='-125822' action='modify' visible='true' lat='49.93' lon='2.63'>
    <tag k='show_year' v='yes' />
  </node>
  <way id='-103879' action='modify' visible='true'>
    <nd ref='-125743' />
    <nd ref='-125744' />
    <tag k='start_year' v='2020' />
  </way>
  <way id='-103881' action='modify' visible='true'>
    <nd ref='-125746' />
    <nd ref='-125747' />
    <tag k='start_year' v='1990' />
  </way>
</osm>

and the complete sample mapcss-File:

setting::start_year_to_display  {
  type: double;
  label: tr("Year of the Map");
  default: 2000;
}

way {
    width:5;
    color:#808080;
}

way[start_year>setting("start_year_to_display")] {
    opacity: 0.2;
    color:#FF0000;
}

way[start_year<setting("start_year_to_display")] {
    opacity: 1.0;
    color:#00FF00;
}

node[show_year=yes] {
    text: setting("start_year_to_display");
    font-size:20;
}

The above line should appear red and translucent, the below line green and opaque. But both appear gray. Displaying the value of the setting via text: setting(“start_year_to_display”); works.

Sorry, I am not quite that familar with styles but from the examples on the documentation I can guess that only boolean might be supported in the selection part.

Anyway, you might want to create a ticket on JOSM trac, to get more attendance.

You might be right that my intended use of settings from type double in selectors is not supported (I did indeed generalize from boolean settings).

I keep in mind to open a ticket on JOSM trac, although I’m not sure if this is the right place since my topic seems to be a feature request rather than a bug report.

JOSM trac has three types of ticket, defects, enhancement and tasks. It is the only place I know about to ask for JOSM improvements and you are invited to create new tickets. Please, don’t be shy.
I am undecided if this is a bug or an unsupported use but at least documentation could be improved to explain where the different types of settings can be used. Guess what, the documentation is on JOSM trac and you’ll find the component “wiki content” for tickets, too. :wink: