Changeset 6581 in josm for trunk/src/org
- Timestamp:
- 2013-12-31T15:10:06+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/validation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r6563 r6581 90 90 SelfIntersectingWay.class, // ID 401 .. 499 91 91 DuplicatedWayNodes.class, // ID 501 .. 599 92 CrossingWays.class, // ID 601 .. 699 92 CrossingWays.Ways.class, // ID 601 .. 699 93 CrossingWays.Boundaries.class, // ID 601 .. 699 94 CrossingWays.NaturalOrLanduse.class, // ID 601 .. 699 95 CrossingWays.Barrier.class, // ID 601 .. 699 93 96 SimilarNamedWays.class, // ID 701 .. 799 94 97 Coastlines.class, // ID 901 .. 999 -
trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java
r6580 r6581 15 15 import org.openstreetmap.josm.data.osm.Node; 16 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 import org.openstreetmap.josm.data.osm.Relation; 17 18 import org.openstreetmap.josm.data.osm.Way; 18 19 import org.openstreetmap.josm.data.osm.WaySegment; … … 30 31 * @author frsantos 31 32 */ 32 public class CrossingWays extends Test {33 public abstract class CrossingWays extends Test { 33 34 protected static final int CROSSING_WAYS = 601; 34 35 … … 40 41 private Map<List<Way>, List<WaySegment>> seenWays; 41 42 42 /** 43 * Constructor 44 */ 43 public static class Ways extends CrossingWays { 44 45 @Override 46 public boolean isPrimitiveUsable(OsmPrimitive w) { 47 return super.isPrimitiveUsable(w) 48 && !isProposedOrAbandoned(w) 49 && (w.hasKey("highway") 50 || w.hasKey("waterway") 51 || (w.hasKey("railway") && !isSubwayOrTram(w)) 52 || isCoastline(w) 53 || isBuilding(w)); 54 } 55 56 @Override 57 boolean ignoreWaySegmentCombination(Way w1, Way w2) { 58 if (!Utils.equal(getLayer(w1), getLayer(w2))) { 59 return true; 60 } 61 if (w1.hasKey("highway") && w2.hasKey("highway") && !Utils.equal(w1.get("level"), w2.get("level"))) { 62 return true; 63 } 64 if (isSubwayOrTram(w2)) { 65 return true; 66 } 67 if (isCoastline(w1) != isCoastline(w2)) { 68 return true; 69 } 70 if ((w1.hasTag("waterway", "river") && w2.hasTag("waterway", "riverbank")) 71 || (w2.hasTag("waterway", "river") && w1.hasTag("waterway", "riverbank"))) { 72 return true; 73 } 74 if (isProposedOrAbandoned(w2)) { 75 return true; 76 } 77 return false; 78 } 79 80 @Override 81 String createMessage(Way w1, Way w2) { 82 if (isBuilding(w1)) { 83 return ("Crossing buildings"); 84 } else if (w1.hasKey("waterway") && w2.hasKey("waterway")) { 85 return tr("Crossing waterways"); 86 } else if ((w1.hasKey("highway") && w2.hasKey("waterway")) 87 || (w2.hasKey("highway") && w1.hasKey("waterway"))) { 88 return tr("Crossing waterway/highway"); 89 } else { 90 return tr("Crossing ways"); 91 } 92 } 93 94 } 95 96 public static class Boundaries extends CrossingWays { 97 98 @Override 99 public boolean isPrimitiveUsable(OsmPrimitive p) { 100 return super.isPrimitiveUsable(p) && p.hasKey("boundary") 101 && (!(p instanceof Relation) || (((Relation) p).isMultipolygon() && !((Relation) p).hasIncompleteMembers())); 102 } 103 104 @Override 105 boolean ignoreWaySegmentCombination(Way w1, Way w2) { 106 return !Utils.equal(w1.get("boundary"), w2.get("boundary")); 107 } 108 109 @Override 110 String createMessage(Way w1, Way w2) { 111 return tr("Crossing boundaries"); 112 } 113 114 @Override 115 public void visit(Relation r) { 116 for (Way w : r.getMemberPrimitives(Way.class)) { 117 visit(w); 118 } 119 } 120 } 121 122 public static class NaturalOrLanduse extends CrossingWays { 123 124 @Override 125 public boolean isPrimitiveUsable(OsmPrimitive p) { 126 return super.isPrimitiveUsable(p) && (p.hasKey("natural") || p.hasKey("landuse")) 127 && (!(p instanceof Relation) || (((Relation) p).isMultipolygon() && !((Relation) p).hasIncompleteMembers())); 128 } 129 130 @Override 131 boolean ignoreWaySegmentCombination(Way w1, Way w2) { 132 return false; 133 } 134 135 @Override 136 String createMessage(Way w1, Way w2) { 137 return tr("Crossing natural/landuse"); 138 } 139 140 @Override 141 public void visit(Relation r) { 142 for (Way w : r.getMemberPrimitives(Way.class)) { 143 visit(w); 144 } 145 } 146 } 147 148 public static class Barrier extends CrossingWays { 149 150 @Override 151 public boolean isPrimitiveUsable(OsmPrimitive p) { 152 return super.isPrimitiveUsable(p) && p.hasKey("barrier"); 153 } 154 155 @Override 156 boolean ignoreWaySegmentCombination(Way w1, Way w2) { 157 return false; 158 } 159 160 @Override 161 String createMessage(Way w1, Way w2) { 162 return tr("Crossing barriers"); 163 } 164 } 165 45 166 public CrossingWays() { 46 super(tr("Crossing ways ."),167 super(tr("Crossing ways"), 47 168 tr("This test checks if two roads, railways, waterways or buildings crosses in the same layer, but are not connected by a node.")); 48 169 } … … 93 214 } 94 215 95 boolean ignoreWaySegmentCombination(Way w1, Way w2) { 96 if (!Utils.equal(getLayer(w1), getLayer(w2))) { 97 return true; 98 } 99 if (w1.hasKey("highway") && w2.hasKey("highway") && !Utils.equal(w1.get("level"), w2.get("level"))) { 100 return true; 101 } 102 if (isSubwayOrTram(w2)) { 103 return true; 104 } 105 if (isCoastline(w1) != isCoastline(w2)) { 106 return true; 107 } 108 if ((w1.hasTag("waterway", "river") && w2.hasTag("waterway", "riverbank")) 109 || (w2.hasTag("waterway", "river") && w1.hasTag("waterway", "riverbank"))) { 110 return true; 111 } 112 if (isProposedOrAbandoned(w2)) { 113 return true; 114 } 115 return false; 116 } 117 118 String createMessage(Way w1, Way w2) { 119 if (isBuilding(w1)) { 120 return ("Crossing buildings"); 121 } else if (w1.hasKey("waterway") && w2.hasKey("waterway")) { 122 return tr("Crossing waterways"); 123 } else if ((w1.hasKey("highway") && w2.hasKey("waterway")) 124 || (w2.hasKey("highway") && w1.hasKey("waterway"))) { 125 return tr("Crossing waterway/highway"); 126 } else { 127 return tr("Crossing ways"); 128 } 129 } 130 131 @Override 132 public boolean isPrimitiveUsable(OsmPrimitive w) { 133 return super.isPrimitiveUsable(w) 134 && !isProposedOrAbandoned(w) 135 && (w.hasKey("highway") 136 || w.hasKey("waterway") 137 || (w.hasKey("railway") && !isSubwayOrTram(w)) 138 || isCoastline(w) 139 || isBuilding(w)); 140 } 141 216 abstract boolean ignoreWaySegmentCombination(Way w1, Way w2); 217 218 abstract String createMessage(Way w1, Way w2); 142 219 143 220 @Override
Note:
See TracChangeset
for help on using the changeset viewer.