Changeset 4051 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2011-04-20T19:09:23+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/validation
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r3946 r4051 31 31 import org.openstreetmap.josm.data.validation.tests.DuplicateNode; 32 32 import org.openstreetmap.josm.data.validation.tests.DuplicateWay; 33 import org.openstreetmap.josm.data.validation.tests.DuplicateRelation; 33 34 import org.openstreetmap.josm.data.validation.tests.DuplicatedWayNodes; 34 35 import org.openstreetmap.josm.data.validation.tests.MultipolygonTest; … … 95 96 RelationChecker.class, // ID 1701 .. 1799 96 97 TurnrestrictionTest.class, // ID 1801 .. 1899 98 DuplicateRelation.class, // ID 1901 .. 1999 97 99 }; 98 100 -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java
r4043 r4051 34 34 { 35 35 36 private staticclass WayPair {36 private class WayPair { 37 37 public List<LatLon> coor; 38 38 public Map<String, String> keys; … … 56 56 } 57 57 58 private class WayPairNoTags { 59 public List<LatLon> coor; 60 public WayPairNoTags(List<LatLon> _coor) { 61 coor=_coor; 62 } 63 @Override 64 public int hashCode() { 65 return coor.hashCode(); 66 } 67 @Override 68 public boolean equals(Object obj) { 69 if (!(obj instanceof WayPairNoTags)) return false; 70 WayPairNoTags wp = (WayPairNoTags) obj; 71 return wp.coor.equals(coor); 72 } 73 } 74 58 75 protected static int DUPLICATE_WAY = 1401; 76 protected static int SAME_WAY = 1402; 59 77 60 78 /** Bag of all ways */ 61 79 MultiMap<WayPair, OsmPrimitive> ways; 80 81 /** Bag of all ways, regardless of tags */ 82 MultiMap<WayPairNoTags, OsmPrimitive> waysNoTags; 62 83 63 84 /** … … 66 87 public DuplicateWay() { 67 88 super(tr("Duplicated ways."), 68 tr("This test checks that there are no ways with same tags and same node coordinates."));89 tr("This test checks that there are no ways with same node coordinates and optionally also same tags.")); 69 90 } 70 91 … … 74 95 super.startTest(monitor); 75 96 ways = new MultiMap<WayPair, OsmPrimitive>(1000); 97 waysNoTags = new MultiMap<WayPairNoTags, OsmPrimitive>(1000); 76 98 } 77 99 … … 85 107 } 86 108 } 109 110 for(Set<OsmPrimitive> sameway : waysNoTags.values()) { 111 if( sameway.size() > 1) { 112 //Report error only if at least some tags are different, as otherwise the error was already reported as duplicated ways 113 Map<String, String> tags0=null; 114 boolean skip=true; 115 116 for(OsmPrimitive o : sameway) { 117 if (tags0==null) { 118 tags0=o.getKeys(); 119 removeUninterestingKeys(tags0); 120 } else { 121 Map<String, String> tagsCmp=o.getKeys(); 122 removeUninterestingKeys(tagsCmp); 123 if (!tagsCmp.equals(tags0)) { 124 skip=false; 125 break; 126 } 127 } 128 } 129 if (skip) continue; 130 TestError testError = new TestError(this, Severity.WARNING, tr("Ways with same position"), SAME_WAY, sameway); 131 errors.add(testError); 132 } 133 } 87 134 ways = null; 135 waysNoTags = null; 136 } 137 138 /** 139 * Remove uninteresting keys, like created_by to normalize the tags 140 */ 141 public void removeUninterestingKeys(Map<String, String> wkeys) { 142 wkeys.remove("created_by"); 88 143 } 89 144 … … 98 153 } 99 154 Map<String, String> wkeys = w.getKeys(); 100 wkeys.remove("created_by");155 removeUninterestingKeys(wkeys); 101 156 WayPair wKey = new WayPair(wLat, wkeys); 102 157 ways.put(wKey, w); 158 WayPairNoTags wKeyN = new WayPairNoTags(wLat); 159 waysNoTags.put(wKeyN, w); 103 160 } 104 161 … … 174 231 return false; 175 232 233 //Do not automatically fix same ways with different tags 234 if (testError.getCode()!=DUPLICATE_WAY) return false; 235 176 236 // We fix it only if there is no more than one way that is relation member. 177 237 Collection<? extends OsmPrimitive> sel = testError.getPrimitives();
Note:
See TracChangeset
for help on using the changeset viewer.