Changeset 6515 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2013-12-23T18:52:41+01:00 (11 years ago)
Author:
simon04
Message:

fix #3531 - validator: unconnected ways: handle highway/railway/waterway/natural+landuse/power separately

Location:
trunk/src/org/openstreetmap/josm/data/validation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r6506 r6515  
    9999        UnclosedWays.class, // ID 1101 .. 1199
    100100        TagChecker.class, // ID 1201 .. 1299
    101         UnconnectedWays.class, // ID 1301 .. 1399
     101        UnconnectedWays.UnconnectedHighways.class, // ID 1301 .. 1399
     102        UnconnectedWays.UnconnectedRailways.class, // ID 1301 .. 1399
     103        UnconnectedWays.UnconnectedWaterways.class, // ID 1301 .. 1399
     104        UnconnectedWays.UnconnectedNaturalOrLanduse.class, // ID 1301 .. 1399
     105        UnconnectedWays.UnconnectedPower.class, // ID 1301 .. 1399
    102106        DuplicateWay.class, // ID 1401 .. 1499
    103107        NameMismatch.class, // ID  1501 ..  1599
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r6494 r6515  
    2222import org.openstreetmap.josm.data.osm.BBox;
    2323import org.openstreetmap.josm.data.osm.Node;
     24import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2425import org.openstreetmap.josm.data.osm.OsmUtils;
    2526import org.openstreetmap.josm.data.osm.QuadBuckets;
     
    3233
    3334/**
    34  * Tests if there are segments that crosses in the same layer
     35 * Tests if there are segments that crosses in the same layer.
     36 * <br/>
     37 * This class is abstract since highway/railway/waterway/… ways must be handled separately.
     38 * An actual implementation must override {@link #isPrimitiveUsable(OsmPrimitive)}
     39 * to denote which kind of primitives can be handled.
    3540 *
    3641 * @author frsantos
    3742 */
    38 public class UnconnectedWays extends Test {
     43public abstract class UnconnectedWays extends Test {
     44
     45    public static class UnconnectedHighways extends UnconnectedWays {
     46
     47        @Override
     48        public boolean isPrimitiveUsable(OsmPrimitive p) {
     49            return super.isPrimitiveUsable(p) && p.hasKey("highway");
     50        }
     51    }
     52
     53    public static class UnconnectedRailways extends UnconnectedWays {
     54
     55        @Override
     56        public boolean isPrimitiveUsable(OsmPrimitive p) {
     57            return super.isPrimitiveUsable(p) && p.hasKey("railway");
     58        }
     59    }
     60
     61    public static class UnconnectedWaterways extends UnconnectedWays {
     62
     63        @Override
     64        public boolean isPrimitiveUsable(OsmPrimitive p) {
     65            return super.isPrimitiveUsable(p) && p.hasKey("waterway");
     66        }
     67    }
     68
     69    public static class UnconnectedNaturalOrLanduse extends UnconnectedWays {
     70
     71        @Override
     72        public boolean isPrimitiveUsable(OsmPrimitive p) {
     73            return super.isPrimitiveUsable(p) && (p.hasKey("natural") || p.hasKey("landuse"));
     74        }
     75    }
     76
     77    public static class UnconnectedPower extends UnconnectedWays {
     78
     79        @Override
     80        public boolean isPrimitiveUsable(OsmPrimitive p) {
     81            return super.isPrimitiveUsable(p) && p.hasKey("power");
     82        }
     83    }
    3984
    4085    protected static final int UNCONNECTED_WAYS = 1301;
     
    343388    }
    344389
    345     @Override
    346     public void visit(Node n) {
    347     }
    348 
    349390    private void addNode(Node n, QuadBuckets<Node> s) {
    350391        boolean m = middlenodes.contains(n);
Note: See TracChangeset for help on using the changeset viewer.