#17058 closed defect (fixed)
Cannot add assertMatch/assertNoMatch declarations with inside() selector
Reported by: | Don-vip | Owned by: | Don-vip |
---|---|---|---|
Priority: | normal | Milestone: | 18.12 |
Component: | Core validator | Version: | |
Keywords: | mapcss | Cc: | naoliv |
Description (last modified by )
From IRC it appears this is not possible to write this:
node[amenity=parking][inside("BR")] { throwWarning: "foo"; assertMatch: "node amenity=parking"; assertNoMatch: "node amenity=restaurant"; }
[17:28:55] <vorpalblade> For the validator.mapcss, does anyone know how to write an assertMatch for specific countries, e.g. [inside("US")]? [17:40:46] <@don-vip> vorpalblade take a look to Brazilian rules: https://github.com/OSMBrasil/validador-josm/blob/master/Rules_Brazilian-Specific.validator.mapcss [17:43:55] <vorpalblade> They don't appear to have any assertMatch/assertNoMatch statements. [18:00:29] <@don-vip> ah sorry I misunderstood. It's not possible, the "inside" keywork is only applicable to selectors [18:01:07] <@don-vip> why would you want to use this in the assertMatch clause ? [18:09:40] <vorpalblade> I want to specify the location of the assertMatch -- I always get errors on assertMatches inside checks which specify countries. If I remove the inside("COUNTRY"), the errors stop. [18:10:14] <vorpalblade> Example: *[name="TODO"][inside("US")] { throwError: tr("Name is TODO"); assertMatch: "node name=TODO"; } [19:41:11] <@don-vip> ah, probably we create primitives at (0,0) for assert rules [19:41:57] <@don-vip> we should create them at the centroid of the first country specified in an inside clause [20:20:57] <vorpalblade> OK. Thanks. I thought that might be the case, and if it was, I thought there *might* be a way to specify the lat/lon of the primitive. [22:36:58] <@don-vip> no I simply didn't think to it
This is because fake primitives created for the assertions are always located at (0,0) instead of the correct country.
Attachments (2)
Change History (23)
comment:1 by , 7 years ago
Description: | modified (diff) |
---|
comment:2 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:3 by , 7 years ago
Several unit tests fail because relations now have an unexpected node member at (0,0)
comment:7 by , 7 years ago
Yes, but I don't understand why. My new rule should only catch declarations starting with -
.
by , 7 years ago
Attachment: | start-error.txt added |
---|
comment:8 by , 7 years ago
Not sure but I think a simple ant dist after an svn update didn't update MapCSSParser.
I've now done ant clean dist and see the modifications in MapCSSParser, but now JOSM refuses to start, see start-error.txt
comment:9 by , 7 years ago
It seems your epsg
ant task has not run. Or if you run JOSM from eclipse you may have forgotten to refresh your project (F5).
comment:10 by , 7 years ago
Yes, sorry, F5 did the trick. I think you have to tell the parer that MINUS should only match at the beginning of the line.
< EXTIDENT: <MINUS> <IDENT> >
comment:12 by , 7 years ago
Really? On my machine Styles/Lane_and_Road_Attributes looks almost like Wireframe View.
by , 7 years ago
Attachment: | Lane and road attributes.PNG added |
---|
comment:14 by , 7 years ago
I tried from Eclipse as well as command line after
- svn up
- ant clean dist
- cd dist
- java -jar josm-custom.jar
comment:15 by , 7 years ago
With r14508 I've now pressed the Reset button in Map Paint Styles dialog and re-added the Lane and road attributes. After that action the style works again.
comment:16 by , 7 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
I tried to readd the assert, but the assertMatch
statements fail.
-
territories.mapcss
10 10 *[addr:street =~ /(?i).*Strasse.*/][addr:street !~ /(?i).*Strasser.*/][inside("DE,AT")], 11 11 *[name =~ /(?i).*Strasse.*/][name !~ /(?i).*Strasser.*/][inside("DE,AT")] { 12 12 throwError: tr("street name contains ss"); 13 assertMatch: "way name=Hauptstrasse"; 14 assertNoMatch: "way name=Hauptstraße"; 15 assertNoMatch: "way name=Kapitän-Strasser-Straße"; 16 assertNoMatch: "way name=Peter-Strasser-Platz"; 17 13 18 } 14 19 *[addr:street =~ /(?i).*Straße.*/][inside("LI,CH")], 15 20 *[name =~ /(?i).*Straße.*/][inside("LI,CH")] { 16 21 throwError: tr("street name contains ß"); 22 assertMatch: "way name=Hauptstraße"; 23 assertNoMatch: "way name=Hauptstrasse"; 17 24 }
INFO: Source Validatortests has been modified. Reloading it... Dec 09, 2018 6:02:13 PM org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker addMapCSS WARNING: Expecting test 'street name contains ss' (i.e., [*[addr:street'REGEX'(?i).*Strasse.*][addr:street'NREGEX'(?i).*Strasser.*][ParameterFunction~inside(class org.openstreetmap.josm.gui.mappaint.Environment,class java.lang.String <DE,AT>)], *[name'REGEX'(?i).*Strasse.*][name'NREGEX'(?i).*Strasser.*][ParameterFunction~inside(class org.openstreetmap.josm.gui.mappaint.Environment,class java.lang.String <DE,AT>)]]) to match way name=Hauptstrasse (i.e., TagMap[name=Hauptstrasse]) Dec 09, 2018 6:02:13 PM org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker addMapCSS WARNING: Expecting test 'street name contains ß' (i.e., [*[addr:street'REGEX'(?i).*Straße.*][ParameterFunction~inside(class org.openstreetmap.josm.gui.mappaint.Environment,class java.lang.String <LI,CH>)], *[name'REGEX'(?i).*Straße.*][ParameterFunction~inside(class org.openstreetmap.josm.gui.mappaint.Environment,class java.lang.String <LI,CH>)]]) to match way name=Hauptstraße (i.e., TagMap[name=Hauptstraße])
follow-up: 20 comment:19 by , 6 years ago
I think this ticket is still not fully fixed. See r15325 I added:
*[aeroway=aerodrome][!icao][faa!~/\d/][inside("US")], *[aeroway=aerodrome][!iata][faa!~/\d/][inside("US")] { throwOther: tr("{0} without {1}", "{0.tag}", "{1.key}"); group: tr("Airport tagging"); /* assertNoMatch: "way aeroway=aerodrome faa=OK12"; not properly working due to inside() */ /* assertMatch: "way aeroway=aerodrome faa=ORD"; */ }
I commented the asserts because one doesn't work and the other fails when [inside("US")]
is used. Or did I anything wrong?
In 14484/josm: