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

Last change on this file since 4505 was 4505, checked in by simon04, 13 years ago

fix #5954 - validator: issue warning for wrong coastline/land direction

  • Property svn:eol-style set to native
File size: 1.8 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 int WRONGLY_ORDERED_COAST = 1001;
22 //protected static int WRONGLY_ORDERED_WATER = 1002;
23 protected static int WRONGLY_ORDERED_LAND = 1003;
24
25 /**
26 * Constructor
27 */
28 public WronglyOrderedWays() {
29 super(tr("Wrongly Ordered Ways."),
30 tr("This test checks the direction of water, land and coastline ways."));
31 }
32
33 @Override
34 public void visit(Way w) {
35
36 if (!w.isUsable() || !w.isClosed())
37 return;
38
39 String natural = w.get("natural");
40 if (natural == null) {
41 return;
42 } else if ("coastline".equals(natural) && Geometry.isClockwise(w)) {
43 reportError(w, tr("Reversed coastline: land not on left side"), WRONGLY_ORDERED_COAST);
44 /*} else if ("water".equals(natural) && !Geometry.isClockwise(w)) {
45 reportError(w, tr("Reversed water: land not on left side"), WRONGLY_ORDERED_WATER);*/
46 } else if ("land".equals(natural) && Geometry.isClockwise(w)) {
47 reportError(w, tr("Reversed land: land not on left side"), WRONGLY_ORDERED_LAND);
48 } else {
49 return;
50 }
51
52 }
53
54 private void reportError(Way w, String msg, int type) {
55 errors.add(new TestError(this, Severity.WARNING, msg, type, Collections.singletonList(w)));
56 }
57}
Note: See TracBrowser for help on using the repository browser.