Changeset 2433 in josm
- Timestamp:
- 2009-11-10T21:25:40+01:00 (15 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java
r2343 r2433 18 18 import org.openstreetmap.josm.Main; 19 19 import org.openstreetmap.josm.data.osm.DataSet; 20 import org.openstreetmap.josm.data.osm.DataSetMerger; 20 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 22 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 22 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor;23 23 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 24 24 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 210 210 } 211 211 212 MergeVisitor visitor = new MergeVisitor(targetLayer.data, parents);212 DataSetMerger visitor = new DataSetMerger(targetLayer.data, parents); 213 213 visitor.merge(); 214 214 SwingUtilities.invokeLater( … … 239 239 reader = null; 240 240 } 241 MergeVisitor visitor = new MergeVisitor(parents, ds);241 DataSetMerger visitor = new DataSetMerger(parents, ds); 242 242 visitor.merge(); 243 243 } -
trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r2381 r2433 15 15 import org.openstreetmap.josm.Main; 16 16 import org.openstreetmap.josm.data.osm.DataSet; 17 import org.openstreetmap.josm.data.osm.DataSetMerger; 17 18 import org.openstreetmap.josm.data.osm.Node; 18 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 20 21 import org.openstreetmap.josm.data.osm.Relation; 21 22 import org.openstreetmap.josm.data.osm.Way; 22 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor;23 23 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 24 24 import org.openstreetmap.josm.gui.PleaseWaitRunnable; … … 213 213 initMultiFetchReaderWithRelations(reader); 214 214 theirDataSet = reader.parseOsm(progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)); 215 MergeVisitor merger = new MergeVisitor(ds, theirDataSet);215 DataSetMerger merger = new DataSetMerger(ds, theirDataSet); 216 216 merger.merge(); 217 217 // a ways loaded with MultiFetch may be incomplete because at least one of its … … 223 223 OsmServerObjectReader reader = new OsmServerObjectReader(w.getId(), OsmPrimitiveType.WAY, true /* full */); 224 224 theirDataSet = reader.parseOsm(progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)); 225 merger = new MergeVisitor(ds, theirDataSet);225 merger = new DataSetMerger(ds, theirDataSet); 226 226 merger.merge(); 227 227 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java
r2418 r2433 1 package org.openstreetmap.josm.data.osm .visitor;1 package org.openstreetmap.josm.data.osm; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; … … 13 13 14 14 import org.openstreetmap.josm.data.conflict.ConflictCollection; 15 import org.openstreetmap.josm.data.osm.DataSet;16 import org.openstreetmap.josm.data.osm.Node;17 import org.openstreetmap.josm.data.osm.OsmPrimitive;18 import org.openstreetmap.josm.data.osm.Relation;19 import org.openstreetmap.josm.data.osm.RelationMember;20 import org.openstreetmap.josm.data.osm.Way;21 15 22 16 /** 23 * A visitor that gets a data set at construction time and merges every visited object24 * into it.25 * 17 * A dataset merger which takes a target and a source dataset and merges the source data set 18 * onto the target dataset. 19 * 26 20 */ 27 public class MergeVisitor extends AbstractVisitor {28 private static Logger logger = Logger.getLogger( MergeVisitor.class.getName());21 public class DataSetMerger { 22 private static Logger logger = Logger.getLogger(DataSetMerger.class.getName()); 29 23 30 24 /** the collection of conflicts created during merging */ … … 51 45 * The visitor will merge <code>theirDataSet</code> onto <code>myDataSet</code> 52 46 * 53 * @param myDataSet dataset with my primitives 54 * @param theirDataSet dataset with their primitives. 55 */ 56 public MergeVisitor(DataSet myDataSet, DataSet theirDataSet) { 47 * @param myDataSet dataset with my primitives. Must not be null. 48 * @param theirDataSet dataset with their primitives. Ignored, if null. 49 * @throws IllegalArgumentException thrown if myDataSet is null 50 */ 51 public DataSetMerger(DataSet myDataSet, DataSet theirDataSet) throws IllegalArgumentException { 52 if (myDataSet == null) 53 throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null")); 57 54 this.myDataSet = myDataSet; 58 55 this.theirDataSet = theirDataSet; … … 82 79 // 83 80 if (mergeById(other)) 81 return; 82 if (!other.isVisible()) 83 // ignore it 84 84 return; 85 85 } else { … … 116 116 } 117 117 } 118 118 119 // If we get here we didn't find a suitable primitive in 119 120 // my dataset. Create a clone and add it to my dataset. … … 129 130 mergedMap.put(other.getUniqueId(), my.getUniqueId()); 130 131 fixReferences.add(other.getUniqueId()); 131 }132 133 public void visit(Node other) {134 mergePrimitive(other);135 }136 137 public void visit(Way other) {138 mergePrimitive(other);139 }140 141 public void visit(Relation other) {142 mergePrimitive(other);143 132 } 144 133 … … 357 346 */ 358 347 public void merge() { 348 if (theirDataSet == null) 349 return; 359 350 for (Node node: theirDataSet.getNodes()) { 360 node.visit(this);351 mergePrimitive(node); 361 352 } 362 353 for (Way way: theirDataSet.getWays()) { 363 way.visit(this);354 mergePrimitive(way); 364 355 } 365 356 for (Relation relation: theirDataSet.getRelations()) { 366 relation.visit(this);357 mergePrimitive(relation); 367 358 } 368 359 fixReferences(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java
r2381 r2433 30 30 import org.openstreetmap.josm.Main; 31 31 import org.openstreetmap.josm.data.osm.DataSet; 32 import org.openstreetmap.josm.data.osm.DataSetMerger; 32 33 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 33 34 import org.openstreetmap.josm.data.osm.Relation; 34 35 import org.openstreetmap.josm.data.osm.RelationMember; 35 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor;36 36 import org.openstreetmap.josm.gui.DefaultNameFormatter; 37 37 import org.openstreetmap.josm.gui.ExceptionDialogUtil; … … 380 380 protected void mergeDataSet(DataSet ds) { 381 381 if (ds != null) { 382 final MergeVisitor visitor = new MergeVisitor(getLayer().data, ds);382 final DataSetMerger visitor = new DataSetMerger(getLayer().data, ds); 383 383 visitor.merge(); 384 384 // FIXME: this is necessary because there are dialogs listening … … 490 490 protected void mergeDataSet(DataSet dataSet) { 491 491 if (dataSet != null) { 492 final MergeVisitor visitor = new MergeVisitor(getLayer().data, dataSet);492 final DataSetMerger visitor = new DataSetMerger(getLayer().data, dataSet); 493 493 visitor.merge(); 494 494 // FIXME: this is necessary because there are dialogs listening -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r2381 r2433 57 57 import org.openstreetmap.josm.data.osm.DataSet; 58 58 import org.openstreetmap.josm.data.osm.DataSource; 59 import org.openstreetmap.josm.data.osm.DataSetMerger; 59 60 import org.openstreetmap.josm.data.osm.OsmPrimitive; 60 61 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 61 62 import org.openstreetmap.josm.data.osm.Relation; 62 63 import org.openstreetmap.josm.data.osm.RelationMember; 63 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor;64 64 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 65 65 import org.openstreetmap.josm.gui.DefaultNameFormatter; … … 1447 1447 if (dataSet != null) { 1448 1448 changed = true; 1449 final MergeVisitor visitor = new MergeVisitor(curLayer.data, dataSet);1449 final DataSetMerger visitor = new DataSetMerger(curLayer.data, dataSet); 1450 1450 visitor.merge(); 1451 1451 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java
r2401 r2433 14 14 import org.openstreetmap.josm.data.osm.DataSet; 15 15 import org.openstreetmap.josm.data.osm.DataSource; 16 import org.openstreetmap.josm.data.osm.DataSetMerger; 16 17 import org.openstreetmap.josm.data.osm.Relation; 17 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor;18 18 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 19 19 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 164 164 referrers = reader.parseOsm(progressMonitor.createSubTaskMonitor(1, false)); 165 165 if (referrers != null) { 166 final MergeVisitor visitor = new MergeVisitor(getLayer().data, referrers);166 final DataSetMerger visitor = new DataSetMerger(getLayer().data, referrers); 167 167 visitor.merge(); 168 168 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationTree.java
r2273 r2433 18 18 import org.openstreetmap.josm.Main; 19 19 import org.openstreetmap.josm.data.osm.DataSet; 20 import org.openstreetmap.josm.data.osm.DataSetMerger; 20 21 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 21 22 import org.openstreetmap.josm.data.osm.Relation; 22 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor;23 23 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 24 24 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; … … 136 136 return; 137 137 } 138 MergeVisitor visitor = new MergeVisitor(Main.main.getEditLayer().data, ds);138 DataSetMerger visitor = new DataSetMerger(Main.main.getEditLayer().data, ds); 139 139 visitor.merge(); 140 140 if (! visitor.getConflicts().isEmpty()) { -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r2414 r2433 50 50 import org.openstreetmap.josm.data.osm.DataSet; 51 51 import org.openstreetmap.josm.data.osm.DataSource; 52 import org.openstreetmap.josm.data.osm.DataSetMerger; 52 53 import org.openstreetmap.josm.data.osm.Node; 53 54 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 57 58 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 58 59 import org.openstreetmap.josm.data.osm.visitor.MapPaintVisitor; 59 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor;60 60 import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor; 61 61 import org.openstreetmap.josm.gui.HelpAwareOptionPane; … … 277 277 */ 278 278 public void mergeFrom(final DataSet from) { 279 final MergeVisitor visitor = new MergeVisitor(data,from);279 final DataSetMerger visitor = new DataSetMerger(data,from); 280 280 visitor.merge(); 281 281 -
trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
r2273 r2433 14 14 15 15 import org.openstreetmap.josm.data.osm.DataSet; 16 import org.openstreetmap.josm.data.osm.DataSetMerger; 16 17 import org.openstreetmap.josm.data.osm.Node; 17 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 20 21 import org.openstreetmap.josm.data.osm.RelationMember; 21 22 import org.openstreetmap.josm.data.osm.Way; 22 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor;23 23 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 24 24 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 387 387 */ 388 388 protected void merge(DataSet from) { 389 final MergeVisitor visitor = new MergeVisitor(outputDataSet,from);389 final DataSetMerger visitor = new DataSetMerger(outputDataSet,from); 390 390 visitor.merge(); 391 391 } -
trunk/src/org/openstreetmap/josm/io/OsmServerBackreferenceReader.java
r2381 r2433 9 9 10 10 import org.openstreetmap.josm.data.osm.DataSet; 11 import org.openstreetmap.josm.data.osm.DataSetMerger; 11 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 13 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 13 14 import org.openstreetmap.josm.data.osm.Relation; 14 15 import org.openstreetmap.josm.data.osm.Way; 15 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor;16 16 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 17 17 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 227 227 OsmServerObjectReader reader = new OsmServerObjectReader(way.getId(), OsmPrimitiveType.from(way), true /* read full */); 228 228 DataSet wayDs = reader.parseOsm(progressMonitor.createSubTaskMonitor(1, false)); 229 MergeVisitor visitor = new MergeVisitor(ds, wayDs);229 DataSetMerger visitor = new DataSetMerger(ds, wayDs); 230 230 visitor.merge(); 231 231 } … … 238 238 OsmServerObjectReader reader = new OsmServerObjectReader(relation.getId(), OsmPrimitiveType.from(relation), true /* read full */); 239 239 DataSet wayDs = reader.parseOsm(progressMonitor.createSubTaskMonitor(1, false)); 240 MergeVisitor visitor = new MergeVisitor(ds, wayDs);240 DataSetMerger visitor = new DataSetMerger(ds, wayDs); 241 241 visitor.merge(); 242 242 } … … 267 267 if (primitiveType.equals(OsmPrimitiveType.NODE)) { 268 268 DataSet ds = getReferringWays(progressMonitor.createSubTaskMonitor(1, false)); 269 MergeVisitor visitor = new MergeVisitor(ret,ds);269 DataSetMerger visitor = new DataSetMerger(ret,ds); 270 270 visitor.merge(); 271 271 ret = visitor.getMyDataSet(); 272 272 } 273 273 DataSet ds = getReferringRelations(progressMonitor.createSubTaskMonitor(1, false)); 274 MergeVisitor visitor = new MergeVisitor(ret,ds);274 DataSetMerger visitor = new DataSetMerger(ret,ds); 275 275 visitor.merge(); 276 276 ret = visitor.getMyDataSet(); -
trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeVisitorTest.java
r2417 r2433 22 22 import org.openstreetmap.josm.data.coor.LatLon; 23 23 import org.openstreetmap.josm.data.osm.DataSet; 24 import org.openstreetmap.josm.data.osm.DataSetMerger; 24 25 import org.openstreetmap.josm.data.osm.Node; 25 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 95 96 96 97 97 MergeVisitor visitor = new MergeVisitor(my,their);98 DataSetMerger visitor = new DataSetMerger(my,their); 98 99 visitor.merge(); 99 100 100 101 Node n2 = (Node)my.getPrimitiveById(1, OsmPrimitiveType.NODE); 101 102 assertTrue(visitor.getConflicts().isEmpty()); 103 assertTrue(n1 != n2); // make sure we have a clone 102 104 assertEquals(1, n2.getId()); 103 105 assertEquals(1, n2.getVersion()); … … 131 133 132 134 133 MergeVisitor visitor = new MergeVisitor(my,their);135 DataSetMerger visitor = new DataSetMerger(my,their); 134 136 visitor.merge(); 135 137 136 138 Node n2 = (Node)my.getPrimitiveById(1, OsmPrimitiveType.NODE); 137 139 assertTrue(visitor.getConflicts().isEmpty()); 140 assertTrue(n == n2); // make sure the merged node is still the original node 141 assertTrue(n2.getDataSet() == my); 138 142 assertEquals(1, n2.getId()); 139 143 assertEquals(2, n2.getVersion()); … … 144 148 145 149 /** 146 * node with same id, my is modified, their has a higher version150 * Node with same id, my is modified, their has a higher version 147 151 * => results in a conflict 148 152 * … … 171 175 172 176 173 MergeVisitor visitor = new MergeVisitor(my,their);177 DataSetMerger visitor = new DataSetMerger(my,their); 174 178 visitor.merge(); 175 179 176 180 Node n2 = (Node)my.getPrimitiveById(1, OsmPrimitiveType.NODE); 177 181 assertEquals(1,visitor.getConflicts().size()); 178 assertEquals(n, n2); 182 assertTrue(n == n2); 183 assertTrue(n1 != n2); 184 assertTrue(n1.getDataSet() == their); 179 185 } 180 186 … … 207 213 208 214 209 MergeVisitor visitor = new MergeVisitor(my,their);215 DataSetMerger visitor = new DataSetMerger(my,their); 210 216 visitor.merge(); 211 217 212 218 Node n2 = (Node)my.getPrimitiveById(1, OsmPrimitiveType.NODE); 213 219 assertEquals(1,visitor.getConflicts().size()); 214 assertEquals(n, n2); 220 assertTrue(n == n2); 221 assertTrue(n1 != n2); 222 assertTrue(n1.getDataSet() == their); 215 223 } 216 224 … … 240 248 241 249 242 MergeVisitor visitor = new MergeVisitor(my,their);250 DataSetMerger visitor = new DataSetMerger(my,their); 243 251 visitor.merge(); 244 252 … … 246 254 assertEquals(1,visitor.getConflicts().size()); 247 255 assertEquals(true, n2.isVisible()); 256 assertTrue(n == n2); 257 assertTrue(n1 != n2); 258 assertTrue(n1.getDataSet() == their); 248 259 } 249 260 … … 269 280 270 281 271 MergeVisitor visitor = new MergeVisitor(my,their);282 DataSetMerger visitor = new DataSetMerger(my,their); 272 283 visitor.merge(); 273 284 … … 275 286 assertEquals(0,visitor.getConflicts().size()); 276 287 assertEquals(true, n2.isVisible()); 288 assertTrue(n == n2); 289 assertTrue(n.getDataSet() == my); 290 assertTrue(n1.getDataSet() == their); 277 291 } 278 292 … … 297 311 298 312 299 MergeVisitor visitor = new MergeVisitor(my,their);313 DataSetMerger visitor = new DataSetMerger(my,their); 300 314 visitor.merge(); 301 315 302 316 assertEquals(1,visitor.getConflicts().size()); 317 assertTrue(n.getDataSet() == my); 318 assertTrue(n1.getDataSet() == their); 303 319 } 304 320 … … 324 340 325 341 326 MergeVisitor visitor = new MergeVisitor(my,their); 327 visitor.merge(); 328 329 assertEquals(0,visitor.getConflicts().size()); 342 DataSetMerger visitor = new DataSetMerger(my,their); 343 visitor.merge(); 344 345 assertEquals(0,visitor.getConflicts().size()); 346 Node n2 = (Node)my.getNodes().toArray()[0]; 347 assertTrue(n2 == n); 348 assertTrue(n2.isDeleted()); 330 349 } 331 350 … … 352 371 353 372 354 MergeVisitor visitor = new MergeVisitor(my,their);373 DataSetMerger visitor = new DataSetMerger(my,their); 355 374 visitor.merge(); 356 375 357 376 Node n2 = (Node)my.getPrimitiveById(1,OsmPrimitiveType.NODE); 358 377 assertEquals(0,visitor.getConflicts().size()); 359 assertEquals( 2, my.getNodes().size());378 assertEquals(1, my.getNodes().size()); 360 379 assertEquals(n,n2); 361 380 } … … 398 417 399 418 400 MergeVisitor visitor = new MergeVisitor(my,their);419 DataSetMerger visitor = new DataSetMerger(my,their); 401 420 visitor.merge(); 402 421 … … 406 425 assertEquals(true, n1.getTimestamp().equals(n2.getTimestamp())); 407 426 assertEquals(theirUser,n2.getUser()); 427 assertTrue(n2 == n); 428 assertTrue(n2 != n1); 429 assertTrue(n2.getDataSet() == my); 408 430 } 409 431 … … 436 458 437 459 438 MergeVisitor visitor = new MergeVisitor(my,their);460 DataSetMerger visitor = new DataSetMerger(my,their); 439 461 visitor.merge(); 440 462 … … 444 466 assertEquals(true, n1.getTimestamp().equals(n2.getTimestamp())); 445 467 assertEquals(false, n2.incomplete); 468 assertTrue(n2 == n); 446 469 } 447 470 … … 499 522 500 523 501 MergeVisitor visitor = new MergeVisitor(my,their);524 DataSetMerger visitor = new DataSetMerger(my,their); 502 525 visitor.merge(); 503 526 … … 511 534 assertEquals(1,merged.getNode(0).getId()); 512 535 assertEquals(2,merged.getNode(1).getId()); 513 536 assertTrue(merged == myWay); 537 assertTrue(merged.getDataSet() == my); 538 539 Node mergedNode = (Node)my.getPrimitiveById(1, OsmPrimitiveType.NODE); 540 assertTrue(mergedNode == n1); 541 mergedNode = (Node)my.getPrimitiveById(2, OsmPrimitiveType.NODE); 542 assertTrue(mergedNode == n2); 514 543 } 515 544 … … 524 553 public void waySimple_AdditionalNodesAndChangedNodes() { 525 554 555 // -- my data set 526 556 DataSet my = new DataSet(); 527 557 my.setVersion("0.6"); … … 540 570 myWay.addNode(n2); 541 571 my.addPrimitive(myWay); 572 573 // --- their data set 542 574 543 575 DataSet their = new DataSet(); … … 566 598 their.addPrimitive(theirWay); 567 599 568 569 MergeVisitor visitor = new MergeVisitor(my,their); 600 DataSetMerger visitor = new DataSetMerger(my,their); 570 601 visitor.merge(); 571 602 … … 579 610 assertEquals(2,merged.getNode(2).getId()); 580 611 assertEquals("value1",merged.getNode(2).get("key1")); 612 613 assertTrue(merged.getNode(0) == n1); 614 assertTrue(merged.getNode(1) != n5); // must be clone of the original node in their 615 assertTrue(merged.getNode(2) == n2); 581 616 } 582 617 … … 636 671 637 672 638 MergeVisitor visitor = new MergeVisitor(my,their);673 DataSetMerger visitor = new DataSetMerger(my,their); 639 674 visitor.merge(); 640 675 … … 684 719 their.addPrimitive(theirWay); 685 720 686 MergeVisitor visitor = new MergeVisitor(my,their);721 DataSetMerger visitor = new DataSetMerger(my,their); 687 722 visitor.merge(); 688 723 … … 699 734 * their way can be merged on my way. No conflict. 700 735 * 701 *702 *703 736 */ 704 737 @Test 705 738 public void waySimple_twoWaysWithNoId_NodesWithId() { 706 739 740 // -- my data set 707 741 DataSet my = new DataSet(); 708 742 my.setVersion("0.6"); … … 721 755 my.addPrimitive(myWay); 722 756 757 // -- their data set 723 758 DataSet their = new DataSet(); 724 759 their.setVersion("0.6"); … … 739 774 their.addPrimitive(theirWay); 740 775 741 MergeVisitor visitor = new MergeVisitor(my,their); 742 visitor.merge(); 743 744 assertEquals(0,visitor.getConflicts().size()); 745 assertEquals("their", myWay.getUser().getName()); 746 assertEquals(1111, myWay.getUser().getId()); 747 assertEquals(1111, myWay.getUser().getId()); 748 assertEquals(theirWay.getTimestamp(), myWay.getTimestamp()); 776 DataSetMerger visitor = new DataSetMerger(my,their); 777 visitor.merge(); 778 779 // -- tests 780 Way merged = (Way)my.getWays().toArray()[0]; 781 assertEquals(0,visitor.getConflicts().size()); 782 assertEquals("their", merged.getUser().getName()); 783 assertEquals(1111, merged.getUser().getId()); 784 assertEquals(theirWay.getTimestamp(), merged.getTimestamp()); 785 assertTrue(merged == myWay); 786 assertTrue(merged.getNode(0) == n1); 787 assertTrue(merged.getNode(1) == n2); 749 788 } 750 789 … … 758 797 public void waySimple_twoWaysWithNoId_NodesWithoutId() { 759 798 799 // -- my data set 760 800 DataSet my = new DataSet(); 761 801 my.setVersion("0.6"); … … 772 812 my.addPrimitive(myWay); 773 813 814 // -- their data set 774 815 DataSet their = new DataSet(); 775 816 their.setVersion("0.6"); … … 789 830 their.addPrimitive(theirWay); 790 831 791 MergeVisitor visitor = new MergeVisitor(my,their); 792 visitor.merge(); 793 794 assertEquals(0,visitor.getConflicts().size()); 795 assertEquals("their", myWay.getUser().getName()); 796 assertEquals(1111, myWay.getUser().getId()); 797 assertEquals(theirWay.getTimestamp(), myWay.getTimestamp()); 832 DataSetMerger visitor = new DataSetMerger(my,their); 833 visitor.merge(); 834 835 // -- tests 836 Way merged = (Way)my.getWays().toArray()[0]; 837 assertEquals(0,visitor.getConflicts().size()); 838 assertEquals("their", merged.getUser().getName()); 839 assertEquals(1111, merged.getUser().getId()); 840 assertEquals(theirWay.getTimestamp(), merged.getTimestamp()); 841 assertTrue(merged == myWay); 842 assertTrue(merged.getNode(0) == n1); 843 assertTrue(merged.getNode(1) == n2); 798 844 } 799 845 … … 810 856 public void wayComplex_mergingADeletedNode() { 811 857 858 // -- my dataset 812 859 DataSet my = new DataSet(); 813 860 my.setVersion("0.6"); … … 833 880 their.addPrimitive(n5); 834 881 835 882 // -- their data set 836 883 Way theirWay = new Way(); 837 884 theirWay.setOsmId(4,1); … … 843 890 their.addPrimitive(theirWay); 844 891 845 MergeVisitor visitor = new MergeVisitor(my,their);892 DataSetMerger visitor = new DataSetMerger(my,their); 846 893 visitor.merge(); 847 894 … … 852 899 853 900 Node n = (Node)my.getPrimitiveById(1,OsmPrimitiveType.NODE); 901 assertTrue(!myWay.getNodes().contains(n)); 854 902 assertTrue(n != null); 855 903 } … … 857 905 /** 858 906 * My dataset includes a deleted node. 859 * Their dataset includes a relation with thre nodes, the first one being my node.907 * Their dataset includes a relation with three nodes, the first one being my node. 860 908 * 861 909 * => the merged relation should include two nodes only. the deleted node should still be … … 898 946 their.addPrimitive(theirRelation); 899 947 900 MergeVisitor visitor = new MergeVisitor(my,their);948 DataSetMerger visitor = new DataSetMerger(my,their); 901 949 visitor.merge(); 902 950 … … 934 982 their.setVersion("0.6"); 935 983 936 MergeVisitor visitor = new MergeVisitor(my,their);984 DataSetMerger visitor = new DataSetMerger(my,their); 937 985 visitor.merge(); 938 986 … … 997 1045 my.addPrimitive(w6); 998 1046 999 MergeVisitor visitor = new MergeVisitor(my,their);1047 DataSetMerger visitor = new DataSetMerger(my,their); 1000 1048 visitor.merge(); 1001 1049
Note:
See TracChangeset
for help on using the changeset viewer.