Ticket #3669: NodesWithSameName.patch

File NodesWithSameName.patch, 1.7 KB (added by skela, 15 years ago)

Patch to ignore same-name nodes with unique ref

  • plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/NodesWithSameName.java

    import static org.openstreetmap.josm.too  
    55import java.util.Map;
    66import java.util.List;
    77import java.util.HashMap;
     8import java.util.HashSet;
    89import java.util.ArrayList;
    910
    1011
    public class NodesWithSameName extends T  
    2526    }
    2627
    2728    @Override public void startTest(ProgressMonitor monitor) {
    28         super.startTest(monitor);
     29        super.startTest(monitor);
    2930        namesToNodes = new HashMap<String, List<Node>>();
    3031    }
    3132
    public class NodesWithSameName extends T  
    4647    @Override public void endTest() {
    4748        for (List<Node> nodes : namesToNodes.values()) {
    4849            if (nodes.size() > 1) {
    49                 errors.add(new TestError(this, Severity.OTHER,
    50                     tr("Nodes with same name"), SAME_NAME, nodes));
     50                // Report the same-name nodes, unless each has a unique ref=*.
     51                HashSet<String> refs = new HashSet<String>();
     52
     53                for (Node n : nodes) {
     54                    String ref = n.get("ref");
     55                    if (ref == null || !refs.add(ref)) {
     56                        errors.add(new TestError(this, Severity.OTHER,
     57                            tr("Nodes with same name"), SAME_NAME, nodes));
     58                        break;
     59                    }
     60                }
    5161            }
    5262        }
    5363        super.endTest();