Changeset 4684 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2011-12-21T12:58:59+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
r4682 r4684 648 648 */ 649 649 public boolean hasSameTags(OsmPrimitive other) { 650 return getKeys().equals(other.getKeys()); 650 // We cannot directly use Arrays.equals(keys, other.keys) as keys is not ordered by key 651 // but we can at least check if both arrays are null or of the same size before creating 652 // and comparing the key maps (costly operation, see #7159) 653 return (keys == null && other.keys == null) 654 || (keys != null && other.keys != null && keys.length == other.keys.length && (keys.length == 0 || getKeys().equals(other.getKeys()))); 651 655 } 652 656 -
trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java
r4253 r4684 16 16 import org.openstreetmap.josm.data.conflict.Conflict; 17 17 import org.openstreetmap.josm.data.conflict.ConflictCollection; 18 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 18 19 import org.openstreetmap.josm.tools.CheckParameterUtil; 19 20 … … 77 78 * @param source the other primitive 78 79 */ 79 protected void mergePrimitive(OsmPrimitive source ) {80 protected void mergePrimitive(OsmPrimitive source, Collection<? extends OsmPrimitive> candidates) { 80 81 if (!source.isNew() ) { 81 82 // try to merge onto a matching primitive with the same … … 94 95 // yet but which is equal in its semantic attributes 95 96 // 96 Collection<? extends OsmPrimitive> candidates = null;97 switch (source.getType()) {98 case NODE: candidates = targetDataSet.getNodes(); break;99 case WAY: candidates = targetDataSet.getWays(); break;100 case RELATION: candidates = targetDataSet.getRelations(); break;101 default: throw new AssertionError();102 }103 97 for (OsmPrimitive target : candidates) { 104 98 if (!target.isNew() || target.isDeleted()) { … … 382 376 */ 383 377 public void merge() { 378 merge(null); 379 } 380 381 /** 382 * Runs the merge operation. Successfully merged {@see OsmPrimitive}s are in 383 * {@see #getMyDataSet()}. 384 * 385 * See {@see #getConflicts()} for a map of conflicts after the merge operation. 386 */ 387 public void merge(ProgressMonitor progressMonitor) { 384 388 if (sourceDataSet == null) 385 389 return; 390 if (progressMonitor != null) { 391 progressMonitor.beginTask(tr("Merging data..."), sourceDataSet.allPrimitives().size()); 392 } 386 393 targetDataSet.beginUpdate(); 387 394 try { 395 ArrayList<? extends OsmPrimitive> candidates = new ArrayList<Node>(targetDataSet.getNodes()); 388 396 for (Node node: sourceDataSet.getNodes()) { 389 mergePrimitive(node); 390 } 397 mergePrimitive(node, candidates); 398 if (progressMonitor != null) { 399 progressMonitor.worked(1); 400 } 401 } 402 candidates.clear(); 403 candidates = new ArrayList<Way>(targetDataSet.getWays()); 391 404 for (Way way: sourceDataSet.getWays()) { 392 mergePrimitive(way); 393 } 405 mergePrimitive(way, candidates); 406 if (progressMonitor != null) { 407 progressMonitor.worked(1); 408 } 409 } 410 candidates.clear(); 411 candidates = new ArrayList<Relation>(targetDataSet.getRelations()); 394 412 for (Relation relation: sourceDataSet.getRelations()) { 395 mergePrimitive(relation); 396 } 413 mergePrimitive(relation, candidates); 414 if (progressMonitor != null) { 415 progressMonitor.worked(1); 416 } 417 } 418 candidates.clear(); 397 419 fixReferences(); 398 420 } finally { 399 421 targetDataSet.endUpdate(); 400 422 } 423 if (progressMonitor != null) { 424 progressMonitor.finishTask(); 425 } 401 426 } 402 427 -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r4612 r4684 966 966 if (!isNew() && id != other.id) 967 967 return false; 968 if (isIncomplete() && ! other.isIncomplete() || !isIncomplete() && other.isIncomplete()) 968 // if (isIncomplete() && ! other.isIncomplete() || !isIncomplete() && other.isIncomplete()) 969 if (isIncomplete() ^ other.isIncomplete()) // exclusive or operator for performance (see #7159) 969 970 return false; 970 971 // can't do an equals check on the internal keys array because it is not ordered
Note:
See TracChangeset
for help on using the changeset viewer.