Changeset 3671 in josm for trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java
- Timestamp:
- 2010-11-25T09:45:38+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java
r3669 r3671 40 40 keys=_keys; 41 41 } 42 42 43 @Override 43 44 public int hashCode() { 44 45 return coor.hashCode()+keys.hashCode(); 45 46 } 47 46 48 @Override 47 49 public boolean equals(Object obj) { 48 if (!(obj instanceof WayPair)) return false; 50 if (!(obj instanceof WayPair)) 51 return false; 49 52 WayPair wp = (WayPair) obj; 50 53 return wp.coor.equals(coor) && wp.keys.equals(keys); … … 60 63 * Constructor 61 64 */ 62 public DuplicateWay() 63 { 65 public DuplicateWay() { 64 66 super(tr("Duplicated ways")+".", 65 67 tr("This test checks that there are no ways with same tags and same node coordinates.")); … … 68 70 69 71 @Override 70 public void startTest(ProgressMonitor monitor) 71 { 72 public void startTest(ProgressMonitor monitor) { 72 73 super.startTest(monitor); 73 74 ways = new Bag<WayPair, OsmPrimitive>(1000); … … 75 76 76 77 @Override 77 public void endTest() 78 { 78 public void endTest() { 79 79 super.endTest(); 80 for(List<OsmPrimitive> duplicated : ways.values() ) 81 { 82 if( duplicated.size() > 1) 83 { 80 for (List<OsmPrimitive> duplicated : ways.values()) { 81 if (duplicated.size() > 1) { 84 82 TestError testError = new TestError(this, Severity.ERROR, tr("Duplicated ways"), DUPLICATE_WAY, duplicated); 85 errors.add( testError);83 errors.add(testError); 86 84 } 87 85 } … … 90 88 91 89 @Override 92 public void visit(Way w) 93 { 94 if( !w.isUsable() ) 90 public void visit(Way w) { 91 if (!w.isUsable()) 95 92 return; 96 93 List<Node> wNodes=w.getNodes(); 97 94 Vector<LatLon> wLat=new Vector<LatLon>(wNodes.size()); 98 for (int i=0;i<wNodes.size();i++) {99 95 for (int i=0;i<wNodes.size();i++) { 96 wLat.add(wNodes.get(i).getCoor()); 100 97 } 101 98 Map<String, String> wkeys=w.getKeys(); … … 109 106 */ 110 107 @Override 111 public Command fixError(TestError testError) 112 { 108 public Command fixError(TestError testError) { 113 109 Collection<? extends OsmPrimitive> sel = testError.getPrimitives(); 114 110 HashSet<Way> ways = new HashSet<Way>(); 115 111 116 for (OsmPrimitive osm : sel) 117 if (osm instanceof Way) 112 for (OsmPrimitive osm : sel) { 113 if (osm instanceof Way) { 118 114 ways.add((Way)osm); 115 } 116 } 119 117 120 if ( ways.size() < 2)118 if (ways.size() < 2) 121 119 return null; 122 120 … … 171 169 172 170 @Override 173 public boolean isFixable(TestError testError) 174 { 171 public boolean isFixable(TestError testError) { 175 172 if (!(testError.getTester() instanceof DuplicateWay)) 176 173 return false; … … 180 177 HashSet<Way> ways = new HashSet<Way>(); 181 178 182 for (OsmPrimitive osm : sel) 183 if (osm instanceof Way) 179 for (OsmPrimitive osm : sel) { 180 if (osm instanceof Way) { 184 181 ways.add((Way)osm); 182 } 183 } 185 184 186 185 if (ways.size() < 2)
Note:
See TracChangeset
for help on using the changeset viewer.