Modify

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#21041 closed defect (fixed)

Some test not evaluated in preset validator

Reported by: Famlam Owned by: Don-vip
Priority: normal Milestone: 21.06
Component: Core Version: latest
Keywords: template_report validator presets Cc: simon04

Description (last modified by Famlam)

What steps will reproduce the problem?

  1. Enable "Run data validator on user input
  2. Add the following mapcss validator rule (to reproduce this problem easily)
    way[highway][waylength()<1] {
            throwWarning: tr("This way is less than 1 m");
    }
    
  3. Select any existing highway (clearly larger than 1 m). I chose way 24511833
  4. Click the preset corresponding to the highway setting (in this case the preset for tertiary roads)

What is the expected result?

Validator in presets dialog knows way length

What happens instead?

Validator in preset dialog doesn't know waylength (but pretends it knows and that it's short ;) )
https://josm.openstreetmap.de/raw-attachment/ticket/21041/Waylength%20error.png

Please provide any additional information below. Attach a screenshot if possible.

This feature was introduced in #19078

Edit: it also triggers if you use [waylength()=0] instead of [waylength()<1] so apparently it thinks the way is exactly 0m long.

URL:https://josm.openstreetmap.de/svn/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2021-06-02 22:03:39 +0200 (Wed, 02 Jun 2021)
Build-Date:2021-06-02 20:11:30
Revision:17919
Relative:URL: ^/trunk

Identification: JOSM/1.5 (17919 nl) Windows 10 64-Bit
OS Build number: Windows 10 Home 2009 (19043)
Memory Usage: 534 MB / 1820 MB (164 MB allocated, but free)
Java version: 1.8.0_291-b10, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
Look and Feel: com.sun.java.swing.plaf.windows.WindowsLookAndFeel
Screen: \Display0 1920×1080 (scaling 1.00×1.00)
Maximum Screen Size: 1920×1080
Best cursor sizes: 16×16→32×32, 32×32→32×32
System property file.encoding: Cp1252
System property sun.jnu.encoding: Cp1252
Locale info: nl_NL
Numbers with default locale: 1234567890 -> 1234567890
Dataset consistency test: No problems found

Plugins:
+ OpeningHoursEditor (35640)
+ SimplifyArea (35640)
+ imagery_offset_db (35640)
+ pt_assistant (1ff2e15)
+ reverter (35732)
+ tageditor (35640)
+ turnlanes-tagging (288)
+ undelete (35640)
+ utilsplugin2 (35691)

Tagging presets:
+ http://mijndev.openstreetmap.nl/~allroads/JOSM/Presets/NL-Fiets.zip

Map paint styles:
- https://josm.openstreetmap.de/josmfile?page=Styles/Lane_and_Road_Attributes&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/PublicTransport&zip=1
+ %UserProfile%\Documents\tijdelijke bestanden\josm-eigen.mappaint.mapcss
+ https://josm.openstreetmap.de/josmfile?page=Styles/Sidewalks&zip=1

Validator rules:
+ %UserProfile%\Documents\tijdelijke bestanden\josm-eigen.validator.mapcss

Last errors/warnings:
- 00007.469 E: Lokaliseren van afbeelding 'bus.png' mislukt

Attachments (2)

Waylength error.png (133.6 KB ) - added by Famlam 4 years ago.
Step-by-step.png (265.7 KB ) - added by Famlam 4 years ago.
Reproduction steps in pictures

Download all attachments as: .zip

Change History (14)

by Famlam, 4 years ago

Attachment: Waylength error.png added

comment:1 by Famlam, 4 years ago

Description: modified (diff)

comment:2 by Klumbumbus, 4 years ago

Currently one internal rule is affected in combinations.mapcss

way[waterway][layer][layer=~/^(-1|-2|-3|-4|-5)$/][!tunnel][culvert!=yes][covered!=yes][pipeline!=yes][location!=underground][eval(waylength()) <= 400]

comment:3 by skyper, 4 years ago

Owner: changed from team to Famlam
Status: newneedinfo

Cannot reproduce with latest. I get the informal warning about waterways and the mentioned rule about short highways leads to a warning. Additionally waylength() works with search if set to mapcss.

I do not really understand how presets come into play and I can only guess you are using match_expression="" which is broken, see #20843. May you, please, add a complete preset example demonstrating the problem. Thanks

Relative:URL: ^/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2021-06-22 22:57:10 +0200 (Tue, 22 Jun 2021)
Revision:17942
Build-Date:2021-06-23 01:31:04
URL:https://josm.openstreetmap.de/svn/trunk
Last edited 4 years ago by skyper (previous) (diff)

comment:4 by Famlam, 4 years ago

Hello Skyper,

I do not use any custom presets, I just use the (existing, unmodified) preset for highway=tertiary.
In #19078 a new feature was introduced that runs validation within the presets window, i.e. to warn you if you enter a bad value (for which you have to enable the setting described in the first step of 'how to reproduce').

This is fully unrelated to the button "validate" (to run the validator outside of the presets window) or "search": they work fine with waylength().
See the step by step how-to that I'll upload now

by Famlam, 4 years ago

Attachment: Step-by-step.png added

Reproduction steps in pictures

comment:5 by skyper, 4 years ago

Owner: changed from Famlam to team
Status: needinfonew

Oh sorry, I disabled that feature as it uses too much resources. Now, I can reproduce, thanks.

There are more problems as deleting the name=* from your example should give another warning Unnamed ways which I do not get.

comment:6 by skyper, 4 years ago

Keywords: waylength removed
Summary: waylength not evaluated in preset validatorSome test not evaluated in preset validator

Looking at #19078 again, I am not sure if all mapcss are supported, yet.

comment:7 by anonymous, 4 years ago

Perhaps good to mention that the check for unnamed ways is a java test (except for highway=unclassified, which is a mapcss check :confused: )
In UntaggedWay.java

comment:8 by skyper, 4 years ago

You are right about "unnamed ways". I rechecked and found other mapcss rules not working like Overlapping Areas:

area:closed:areaStyle  area:closed:areaStyle {
  throwOther: tr("Overlapping Areas");
}

or Public Transport GTFS: conflicting tags - `{0}` conflicts with `{1}` of the `route_master` relation.:

*[gtfs:route_id      ][count(split(";", tag("gtfs:route_id"))) > 1],
*[gtfs:shape_id      ][count(split(";", tag("gtfs:shape_id"))) > 1],
*[gtfs:trip_id       ][count(split(";", tag("gtfs:trip_id"))) > 1],
*[gtfs:trip_id:sample][count(split(";", tag("gtfs:trip_id:sample"))) > 1] {
  throwOther: tr("Multiple values `{0}` for `{1}=*`.", "{0.value}", "{0.key}");
  group: tr("Public Transport GTFS: value syntax");
  set MultipleID;
  assertMatch:   "relation gtfs:route_id=7-342-j1j-1;7-342-j1j-5";
  assertNoMatch: "relation gtfs:route_id=7-342-j1j-1.H";
}

relation!.MultipleID[count(split(";", parent_tag("gtfs:route_id"))) == 1] {
  set NoMultiId;
}
relation[gtfs:route_id      ][!(parent_tag("gtfs:route_id") == tag("gtfs:route_id"))].NoMultiId,
relation[gtfs:shape_id      ][!gtfs:route_id][!(parent_tag("gtfs:route_id") == get(regexp_match("(.+)\\.\\d+\\.[HR]$", tag("gtfs:shape_id")), 1))].NoMultiId,
relation[gtfs:trip_id       ][!gtfs:route_id][!gtfs:shape_id][!(parent_tag("gtfs:route_id") == get(regexp_match("^\\d+\\.T[023A]\\.(.+)\\.\\d+\\.[HR]$", tag("gtfs:trip_id")), 1))].NoMultiId,
relation[gtfs:trip_id:sample][!gtfs:route_id][!gtfs:shape_id][!(parent_tag("gtfs:route_id") == get(regexp_match("^\\d+\\.T[023A]\\.(.+)\\.\\d+\\.[HR]$", tag("gtfs:trip_id:sample")), 1))].NoMultiId {
  throwWarning:  tr("`{0}` conflicts with `{1}` of the `route_master` relation.", "{0.tag}", "gtfs:route_id=*");
  group: tr("Public Transport GTFS: conflicting tags");

comment:9 by Don-vip, 4 years ago

In TaggingPresetValidation, primitives being checked are first cloned, but it results in empty ways and relations:

    static OsmPrimitive clone(OsmPrimitive original) {
        if (original instanceof Node) {
            return new Node(((Node) original));
        } else if (original instanceof Way) {
            return new Way(((Way) original), false, false);
        } else if (original instanceof Relation) {
            return new Relation(((Relation) original), false, false);
        } else {
            throw new IllegalStateException();
        }
    }

comment:10 by Don-vip, 4 years ago

Milestone: 21.06
Owner: changed from team to Don-vip
Status: newassigned

comment:11 by Don-vip, 4 years ago

Resolution: fixed
Status: assignedclosed

In 17981/josm:

fix #21041 - Tagging preset validation: clone properly primitives children for nominal execution of validation tests

comment:12 by Don-vip, 4 years ago

In 18001/josm:

fix #21095 - see #21041 - fix NPE when opening the preset editor with new objects

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. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.