source: josm/trunk/src/org/openstreetmap/josm/data/validation/tests/WronglyOrderedWays.java@ 6240

Last change on this file since 6240 was 6240, checked in by Don-vip, 11 years ago

Sonar - fix some issues in data.validation.tests

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. See LICENSE file for details.
2package org.openstreetmap.josm.data.validation.tests;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.Collections;
7
8import org.openstreetmap.josm.data.osm.Way;
9import org.openstreetmap.josm.data.validation.Severity;
10import org.openstreetmap.josm.data.validation.Test;
11import org.openstreetmap.josm.data.validation.TestError;
12import org.openstreetmap.josm.tools.Geometry;
13
14/**
15 * Check cyclic ways for errors
16 *
17 * @author jrreid
18 */
19public class WronglyOrderedWays extends Test {
20
21 protected static final int WRONGLY_ORDERED_COAST = 1001;
22 protected static final int WRONGLY_ORDERED_LAND = 1003;
23
24 /**
25 * Constructor
26 */
27 public WronglyOrderedWays() {
28 super(tr("Wrongly Ordered Ways"),
29 tr("This test checks the direction of water, land and coastline ways."));
30 }
31
32 @Override
33 public void visit(Way w) {
34
35 if (!w.isUsable() || !w.isClosed())
36 return;
37
38 String natural = w.get("natural");
39 if (natural == null)
40 return;
41 else if ("coastline".equals(natural) && Geometry.isClockwise(w)) {
42 reportError(w, tr("Reversed coastline: land not on left side"), WRONGLY_ORDERED_COAST);
43 } else if ("land".equals(natural) && Geometry.isClockwise(w)) {
44 reportError(w, tr("Reversed land: land not on left side"), WRONGLY_ORDERED_LAND);
45 } else
46 return;
47
48 }
49
50 private void reportError(Way w, String msg, int type) {
51 errors.add(new TestError(this, Severity.WARNING, msg, type, Collections.singletonList(w)));
52 }
53}
Note: See TracBrowser for help on using the repository browser.