Changeset 18122 in osm for applications


Ignore:
Timestamp:
2009-10-13T21:36:03+02:00 (15 years ago)
Author:
skela
Message:

Fixed #3669 in the JOSM Validator plugin: Do not complain about nodes
with same name if each same-name node has a unique ref value.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/NodesWithSameName.java

    r17722 r18122  
    66import java.util.List;
    77import java.util.HashMap;
     8import java.util.HashSet;
    89import java.util.ArrayList;
    910
     
    2627
    2728    @Override public void startTest(ProgressMonitor monitor) {
    28         super.startTest(monitor);
     29        super.startTest(monitor);
    2930        namesToNodes = new HashMap<String, List<Node>>();
    3031    }
     
    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        }
Note: See TracChangeset for help on using the changeset viewer.