Modify

Opened 4 months ago

Closed 4 months ago

Last modified 3 months ago

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

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)

start-error.txt (2.9 KB) - added by GerdP 4 months ago.
Lane and road attributes.PNG (472.3 KB) - added by GerdP 4 months ago.

Download all attachments as: .zip

Change History (20)

comment:1 Changed 4 months ago by Don-vip

Description: modified (diff)

comment:2 Changed 4 months ago by Don-vip

Resolution: fixed
Status: assignedclosed

In 14484/josm:

fix #17058 - Cannot add assertMatch/assertNoMatch declarations with inside() selector

comment:3 Changed 4 months ago by GerdP

Several unit tests fail because relations now have an unexpected node member at (0,0)

comment:4 Changed 4 months ago by Don-vip

In 14486/josm:

see #17058 - fix unit tests

comment:5 Changed 4 months ago by Don-vip

It broke Styles/Lane_and_Road_Attributes don't know why yet.

comment:6 Changed 4 months ago by GerdP

Maybe it was r14481?

comment:7 Changed 4 months ago by Don-vip

Yes, but I don't understand why. My new rule should only catch declarations starting with -.

Changed 4 months ago by GerdP

Attachment: start-error.txt added

comment:8 Changed 4 months ago by GerdP

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 Changed 4 months ago by Don-vip

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 Changed 4 months ago by GerdP

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:11 Changed 4 months ago by Don-vip

Yes r14489 did the trick :)

comment:12 Changed 4 months ago by GerdP

Really? On my machine Styles/Lane_and_Road_Attributes looks almost like Wireframe View.

comment:13 Changed 4 months ago by Don-vip

Works fine for me, you probably need to recompile the .jj file.

Changed 4 months ago by GerdP

comment:14 Changed 4 months ago by GerdP

I tried from Eclipse as well as command line after

  • svn up
  • ant clean dist
  • cd dist
  • java -jar josm-custom.jar

See

comment:15 Changed 4 months ago by GerdP

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 Changed 4 months ago by Klumbumbus

Resolution: fixed
Status: closedreopened

I tried to readd the assert, but the assertMatch statements fail.

  • territories.mapcss

     
    1010*[addr:street =~ /(?i).*Strasse.*/][addr:street !~ /(?i).*Strasser.*/][inside("DE,AT")],
    1111*[name =~ /(?i).*Strasse.*/][name !~ /(?i).*Strasser.*/][inside("DE,AT")] {
    1212  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 
    1318}
    1419*[addr:street =~ /(?i).*Straße.*/][inside("LI,CH")],
    1520*[name =~ /(?i).*Straße.*/][inside("LI,CH")] {
    1621  throwError: tr("street name contains ß");
     22  assertMatch: "way name=Hauptstraße";
     23  assertNoMatch: "way name=Hauptstrasse";
    1724}
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])

comment:17 Changed 4 months ago by Don-vip

Resolution: fixed
Status: reopenedclosed

In 14540/josm:

fix #17058 - support assertions with several countries

comment:18 Changed 3 months ago by Klumbumbus

In 14552/josm:

  • see #16301 - make id mandatory
  • see #17058 - add asserts to territories.mapcss

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Don-vip.
as The resolution will be set.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.