Ticket #3669: NodesWithSameName.patch
File NodesWithSameName.patch, 1.7 KB (added by , 15 years ago) |
---|
-
plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/NodesWithSameName.java
import static org.openstreetmap.josm.too 5 5 import java.util.Map; 6 6 import java.util.List; 7 7 import java.util.HashMap; 8 import java.util.HashSet; 8 9 import java.util.ArrayList; 9 10 10 11 … … public class NodesWithSameName extends T 25 26 } 26 27 27 28 @Override public void startTest(ProgressMonitor monitor) { 28 29 super.startTest(monitor); 29 30 namesToNodes = new HashMap<String, List<Node>>(); 30 31 } 31 32 … … public class NodesWithSameName extends T 46 47 @Override public void endTest() { 47 48 for (List<Node> nodes : namesToNodes.values()) { 48 49 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 } 51 61 } 52 62 } 53 63 super.endTest();