source: josm/trunk/src/org/openstreetmap/josm/data/validation/tests/SelfIntersectingWay.java@ 9921

Last change on this file since 9921 was 8382, checked in by Don-vip, 9 years ago

fix copyright/license headers globally (missed a few files)

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.validation.tests;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.Arrays;
7import java.util.HashSet;
8import java.util.Set;
9
10import org.openstreetmap.josm.data.osm.Node;
11import org.openstreetmap.josm.data.osm.Way;
12import org.openstreetmap.josm.data.validation.Severity;
13import org.openstreetmap.josm.data.validation.Test;
14import org.openstreetmap.josm.data.validation.TestError;
15
16/**
17 * Checks for self-intersecting ways.
18 */
19public class SelfIntersectingWay extends Test {
20
21 protected static final int SELF_INTERSECT = 401;
22
23 /**
24 * Constructs a new {@code SelfIntersectingWay} test.
25 */
26 public SelfIntersectingWay() {
27 super(tr("Self-intersecting ways"),
28 tr("This test checks for ways " +
29 "that contain some of their nodes more than once."));
30 }
31
32 @Override
33 public void visit(Way w) {
34 Set<Node> nodes = new HashSet<>();
35
36 for (int i = 1; i < w.getNodesCount() - 1; i++) {
37 Node n = w.getNode(i);
38 if (nodes.contains(n)) {
39 errors.add(new TestError(this,
40 Severity.WARNING, tr("Self-intersecting ways"), SELF_INTERSECT,
41 Arrays.asList(w), Arrays.asList(n)));
42 break;
43 } else {
44 nodes.add(n);
45 }
46 }
47 }
48}
Note: See TracBrowser for help on using the repository browser.