Changeset 16793 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2020-07-18T06:38:46+02:00 (4 years ago)
Author:
GerdP
Message:

see #19312: detect circular dependencies in relations

  • implement preference key validator.relation.allow.complex.dependency to disable warnings from validator or relation editor when multiple relations generate a dependency loop
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java

    r16652 r16793  
    2525import org.openstreetmap.josm.data.osm.Relation;
    2626import org.openstreetmap.josm.data.osm.RelationMember;
     27import org.openstreetmap.josm.data.preferences.BooleanProperty;
    2728import org.openstreetmap.josm.data.validation.OsmValidator;
    2829import org.openstreetmap.josm.data.validation.Severity;
     
    6970    public static final int RELATION_LOOP    = 1710;
    7071    // CHECKSTYLE.ON: SingleSpaceSeparator
     72
     73    // see 19312 comment:17
     74    private static final BooleanProperty ALLOW_COMPLEX_LOOP = new BooleanProperty("validator.relation.allow.complex.dependency", false);
    7175
    7276    /**
     
    405409    @Override
    406410    public void endTest() {
     411        if (Boolean.TRUE.equals(ALLOW_COMPLEX_LOOP.get())) {
     412            loops.removeIf(loop -> loop.size() > 2);
     413        }
    407414        loops.forEach(loop -> errors.add(TestError.builder(this, Severity.ERROR, RELATION_LOOP)
    408415                .message(loop.size() == 2 ? tr("Relation contains itself as a member")
     
    465472        path.add(parent);
    466473        test.checkLoop(child, path);
     474        if (Boolean.TRUE.equals(ALLOW_COMPLEX_LOOP.get())) {
     475            test.loops.removeIf(loop -> loop.size() > 2);
     476        }
    467477        if (test.loops.isEmpty())
    468478            return Collections.emptyList();
Note: See TracChangeset for help on using the changeset viewer.