Changeset 11627 in josm for trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java
- Timestamp:
- 2017-02-26T00:59:32+01:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java
r11129 r11627 249 249 public Command fixError(TestError testError) { 250 250 Collection<? extends OsmPrimitive> sel = testError.getPrimitives(); 251 Set<Way> way s= new HashSet<>();251 Set<Way> wayz = new HashSet<>(); 252 252 253 253 for (OsmPrimitive osm : sel) { 254 254 if (osm instanceof Way && !osm.isDeleted()) { 255 way s.add((Way) osm);256 } 257 } 258 259 if (way s.size() < 2)255 wayz.add((Way) osm); 256 } 257 } 258 259 if (wayz.size() < 2) 260 260 return null; 261 261 262 262 long idToKeep = 0; 263 Way wayToKeep = way s.iterator().next();263 Way wayToKeep = wayz.iterator().next(); 264 264 // Find the way that is member of one or more relations. (If any) 265 265 Way wayWithRelations = null; 266 266 List<Relation> relations = null; 267 for (Way w : way s) {267 for (Way w : wayz) { 268 268 List<Relation> rel = OsmPrimitive.getFilteredList(w.getReferrers(), Relation.class); 269 269 if (!rel.isEmpty()) { … … 284 284 285 285 // Fix relations. 286 if (wayWithRelations != null && wayToKeep != wayWithRelations) {286 if (wayWithRelations != null && relations != null && wayToKeep != wayWithRelations) { 287 287 for (Relation rel : relations) { 288 288 Relation newRel = new Relation(rel); … … 297 297 } 298 298 299 // Delete all ways in the list300 // Note: nodes are not deleted, these can be detected and deleted at next pass301 way s.remove(wayToKeep);302 commands.add(new DeleteCommand(way s));299 // Delete all ways in the list 300 // Note: nodes are not deleted, these can be detected and deleted at next pass 301 wayz.remove(wayToKeep); 302 commands.add(new DeleteCommand(wayz)); 303 303 return new SequenceCommand(tr("Delete duplicate ways"), commands); 304 304 } … … 309 309 return false; 310 310 311 // Do not automatically fix same ways with different tags311 // Do not automatically fix same ways with different tags 312 312 if (testError.getCode() != DUPLICATE_WAY) return false; 313 313 314 314 // We fix it only if there is no more than one way that is relation member. 315 315 Collection<? extends OsmPrimitive> sel = testError.getPrimitives(); 316 Set<Way> way s= new HashSet<>();316 Set<Way> wayz = new HashSet<>(); 317 317 318 318 for (OsmPrimitive osm : sel) { 319 319 if (osm instanceof Way) { 320 way s.add((Way) osm);321 } 322 } 323 324 if (way s.size() < 2)320 wayz.add((Way) osm); 321 } 322 } 323 324 if (wayz.size() < 2) 325 325 return false; 326 326 327 327 int waysWithRelations = 0; 328 for (Way w : way s) {328 for (Way w : wayz) { 329 329 List<Relation> rel = OsmPrimitive.getFilteredList(w.getReferrers(), Relation.class); 330 330 if (!rel.isEmpty()) {
Note:
See TracChangeset
for help on using the changeset viewer.