You are not logged in.

#1 2021-12-23 10:01:49

cul-de-sac
Member
Registered: 2019-03-18
Posts: 31

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

Last edited by cul-de-sac (2021-12-23 19:12:17)

Offline

#2 2021-12-23 18:06:55

alester
Member
Registered: 2011-09-21
Posts: 294

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

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.

Offline

#3 2021-12-23 19:17:36

cul-de-sac
Member
Registered: 2019-03-18
Posts: 31

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

alester wrote:

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.

Offline

#4 2021-12-23 20:03:24

cul-de-sac
Member
Registered: 2019-03-18
Posts: 31

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

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.

Offline

#5 2021-12-25 21:37:40

skyper
Member
Registered: 2020-06-08
Posts: 665

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

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.

Offline

#6 2021-12-26 10:08:53

cul-de-sac
Member
Registered: 2019-03-18
Posts: 31

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

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.

Offline

#7 2021-12-27 21:02:14

skyper
Member
Registered: 2020-06-08
Posts: 665

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

cul-de-sac wrote:

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

Offline

Board footer

Powered by FluxBB