Changeset 224 in josm
- Timestamp:
- 2007-05-05T23:33:16+02:00 (18 years ago)
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/DownloadIncompleteAction.java
r218 r224 48 48 49 49 @Override protected void finish() { 50 MergeVisitor merger = new MergeVisitor(Main.ds );50 MergeVisitor merger = new MergeVisitor(Main.ds, reader.data); 51 51 for (OsmPrimitive osm : reader.data.allPrimitives()) 52 52 osm.visit(merger); -
src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r203 r224 29 29 30 30 private final DataSet ds; 31 private final DataSet mergeds; 31 32 32 33 /** … … 43 44 private final Map<Segment, Segment> mergedSegments = new HashMap<Segment, Segment>(); 44 45 45 public MergeVisitor(DataSet ds ) {46 public MergeVisitor(DataSet ds, DataSet mergeds) { 46 47 this.ds = ds; 48 this.mergeds = mergeds; 47 49 } 48 50 … … 57 59 Node my = null; 58 60 for (Node n : ds.nodes) { 59 if (match(n, other) ) {61 if (match(n, other) && ((mergeds == null) || (!mergeds.nodes.contains(n)))) { 60 62 my = n; 61 63 break; … … 87 89 Segment my = null; 88 90 for (Segment ls : ds.segments) { 89 if (match(other, ls) ) {91 if (match(other, ls) && ((mergeds == null) || (!mergeds.segments.contains(ls)))) { 90 92 my = ls; 91 93 break; 92 94 } 93 95 } 96 94 97 if (my == null) 95 98 ds.segments.add(other); … … 145 148 Way my = null; 146 149 for (Way w : ds.ways) { 147 if (match(other, w) ) {150 if (match(other, w) && ((mergeds == null) || (!mergeds.ways.contains(w)))) { 148 151 my = w; 149 152 break; … … 291 294 else 292 295 my.keys.putAll(other.keys); 296 293 297 my.modified = true; 294 298 } -
src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r186 r224 157 157 158 158 @Override public void mergeFrom(final Layer from) { 159 final MergeVisitor visitor = new MergeVisitor(data );159 final MergeVisitor visitor = new MergeVisitor(data,((OsmDataLayer)from).data); 160 160 for (final OsmPrimitive osm : ((OsmDataLayer)from).data.allPrimitives()) 161 161 osm.visit(visitor); -
src/org/openstreetmap/josm/io/IncompleteDownloader.java
r219 r224 44 44 */ 45 45 private final Collection<Way> toDownload; 46 private MergeVisitor merger = new MergeVisitor(data );46 private MergeVisitor merger = new MergeVisitor(data, null); 47 47 48 48 public IncompleteDownloader(Collection<Way> toDownload) { -
test/org/openstreetmap/josm/data/osm/visitor/MergeVisitorTest.java
r209 r224 25 25 ds = new DataSet(); 26 26 dsNode = DataSetTestCaseHelper.createNode(ds); 27 v = new MergeVisitor(ds );27 v = new MergeVisitor(ds, null); 28 28 n = DataSetTestCaseHelper.createNode(null); 29 29 } … … 235 235 236 236 Segment ls2 = DataSetTestCaseHelper.createSegment(ds, n2[0], n2[1]); 237 v = new MergeVisitor(ds );237 v = new MergeVisitor(ds, null); 238 238 for (OsmPrimitive osm : ds2.allPrimitives()) 239 239 osm.visit(v); … … 249 249 Segment s = DataSetTestCaseHelper.createSegment(ds, n[0], n[1]); 250 250 Way w = DataSetTestCaseHelper.createWay(ds, s); 251 MergeVisitor v = new MergeVisitor(ds );251 MergeVisitor v = new MergeVisitor(ds, null); 252 252 v.visit(n[0]); 253 253 v.visit(n[1]); … … 281 281 w.id = 42; 282 282 // merge both 283 MergeVisitor v = new MergeVisitor(ds );283 MergeVisitor v = new MergeVisitor(ds, null); 284 284 v.visit(w); 285 285 v.fixReferences(); … … 299 299 s.timestamp = new Date(new Date().getTime()+1); 300 300 301 MergeVisitor v = new MergeVisitor(ds );301 MergeVisitor v = new MergeVisitor(ds, null); 302 302 v.visit(s); 303 303 v.fixReferences(); … … 308 308 public void testMergeIncompleteSegmentsAddToDataSet() throws Exception { 309 309 DataSet ds = new DataSet(); 310 MergeVisitor v = new MergeVisitor(ds );310 MergeVisitor v = new MergeVisitor(ds, null); 311 311 v.visit(createSegment(null, true, false, 1)); 312 312 assertEquals(1, ds.segments.size()); … … 330 330 newNode.timestamp = new Date(date.getTime()); 331 331 332 MergeVisitor v = new MergeVisitor(ds );332 MergeVisitor v = new MergeVisitor(ds, null); 333 333 v.visit(newNode); 334 334 … … 343 343 Segment s2 = new Segment(42); 344 344 345 MergeVisitor v = new MergeVisitor(ds );345 MergeVisitor v = new MergeVisitor(ds, null); 346 346 v.visit(s1); 347 347 v.visit(s2);
Note:
See TracChangeset
for help on using the changeset viewer.