osmose-backend icon indicating copy to clipboard operation
osmose-backend copied to clipboard

Load of Osmose MapCSS in JOSM

Open frodrigo opened this issue 1 year ago • 5 comments

We try to list the Osmose MapCSS for JOSM. But the load of Osmose MapCSS fails on JOSM

  1. Ensure Osmose MapCSS are loadable by JOSM.
  2. Can/should we package all Osmose MapCSS in one Zip?
  3. Include translation from Osmose.

frodrigo avatar Apr 25 '23 20:04 frodrigo

Ensure Osmose MapCSS are loadable by JOSM.

With the PR in #1829 every rule can be loaded in JOSM. The issues were:

  • ' is a special character in JOSM. You can't use it for string quotations, and if you want to use it in a tr(...) string, you'll have to use '' to get a single apostrophe (we don't parse this: we just output two aposthrophes). Or replace it by i.e. `.)
  • [key1!=tag(key2)] doesn't work in JOSM. (And I'm actually surprised it does in Osmose as it looks to me as if you're comparing the string "key1" to the value of tag "key2", instead of the value of key1 with the value of key2). Anyway, the !=* operator works, and otherwise tag("key1")!=tag("key2") would've worked too
  • In autofixes, JOSM first executes all functions (like replace, before it parses placeholders like {0.value}. Hence, the hypothetical fixAdd: concat("x=", replace("{0.value}", "value", "key")); on way a=b would give x=a as output, rather than x=b.

(I encountered all of these before 😉, either in my Dutch filters or my local mapcss file)

The autofix of TagFix_destination is a difficult one and needs some work: fixAdd: concat("{1.key}=", replace("{1.value}", "|", ";")); where {1.key} is based on a regex. However, although the autofix just doesn't work, it doesn't break things either (and I don't have ideas on how to implement it for the regexes* 👼 ) so I guess it's ok for now. (* tag_regex(...) would not be able to determine if the match, if more than one, corresponds to the key in {1.key})

Famlam avatar Apr 26 '23 00:04 Famlam

You can't use it for string quotations

Should we remove simple quoted string from grammar ? https://github.com/osm-fr/osmose-backend/blob/master/mapcss/MapCSS.g4#L108

you'll have to use '' to get a single apostrophe (we don't parse this: we just output two aposthrophes)

We can fix this, but probably not in the grammar.

[key1!=tag(key2)] doesn't work in JOSM. (And I'm actually surprised it does in Osmose as it looks to me as if you're comparing the string "key1" to the value of tag "key2", instead of the value of key1 with the value of key2). Anyway, the !=* operator works, and otherwise

Ok, it generates the same python code.

In autofixes, JOSM first executes all functions [...]

Ok.

frodrigo avatar Apr 26 '23 21:04 frodrigo

Should we remove simple quoted string from grammar ? https://github.com/osm-fr/osmose-backend/blob/master/mapcss/MapCSS.g4#L108

I considered it as an additional feature we support :).

We can fix this, but probably not in the grammar.

Yes, it's not an urgent issue though as '' looks almost the same as " and usually that works out well. Since it only affects tr()-translated strings, probably the fix should be in its definition in mapcss_lib.py? But I don't think that would block this issue? I'm more concerned the other way around: e.g. in Dutch 's is pretty common (example: English: photos => Dutch: foto's), so Osmose translators (for point 3 of the initial post in this issue) would need to translate this as foto''s for it to work in JOSM, which looks very unnatural.

Famlam avatar Apr 26 '23 21:04 Famlam

  1. Can/should we package all Osmose MapCSS in one Zip?

The should be nammed *.validator.zip.

But only one MapCSS file is used from the zip.

We already build a zip with mapcss and i18n in this project: https://github.com/Jungle-Bus/transport_mapcss

cc @Klumbumbus

frodrigo avatar Apr 29 '23 21:04 frodrigo

Side note: with #1989 we'll be able to parse JOSM's '' as ' in Osmose, but if we want JOSM users to use our translated strings, we also have to convert all translations of Osmose containing ' to ''. Otherwise the ' is not used in the message by JOSM.

Famlam avatar Aug 18 '23 20:08 Famlam