Changeset 478 in josm for trunk/src/org
- Timestamp:
- 2007-12-01T13:58:58+01:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r371 r478 33 33 private final DataSet mergeds; 34 34 35 private final HashMap<Long, Node> nodeshash = new HashMap<Long, Node>(); 36 private final HashMap<Long, Way> wayshash = new HashMap<Long, Way>(); 37 private final HashMap<Long, Relation> relshash = new HashMap<Long, Relation>(); 38 35 39 /** 36 40 * A list of all primitives that got replaced with other primitives. … … 44 48 this.ds = ds; 45 49 this.mergeds = mergeds; 50 51 for (Node n : ds.nodes) if (n.id != 0) nodeshash.put(n.id, n); 52 for (Way w : ds.ways) if (w.id != 0) wayshash.put(w.id, w); 53 for (Relation r : ds.relations) if (r.id != 0) relshash.put(r.id, r); 46 54 } 47 55 … … 51 59 */ 52 60 public void visit(Node other) { 53 if (mergeAfterId(ds.nodes, other))61 if (mergeAfterId(ds.nodes, nodeshash, other)) 54 62 return; 55 63 … … 82 90 public void visit(Way other) { 83 91 fixWay(other); 84 if (mergeAfterId(ds.ways, other))92 if (mergeAfterId(ds.ways, wayshash, other)) 85 93 return; 86 94 … … 117 125 public void visit(Relation other) { 118 126 fixRelation(other); 119 if (mergeAfterId(ds.relations, other))127 if (mergeAfterId(ds.relations, relshash, other)) 120 128 return; 121 129 … … 275 283 * @return <code>true</code>, if no merge is needed or merge is performed already. 276 284 */ 277 private <P extends OsmPrimitive> boolean mergeAfterId(Collection<P> primitives, P other) { 285 private <P extends OsmPrimitive> boolean mergeAfterId( 286 Collection<P> primitives, HashMap<Long, P> hash, P other) { 287 // Fast-path merging of identical objects 288 if (hash.containsKey(other.id)) { 289 P my = hash.get(other.id); 290 if (my.realEqual(other, true)) { 291 merged.put(other, my); 292 return true; 293 } 294 } 295 278 296 for (P my : primitives) { 279 297 Date myd = my.timestamp == null ? new Date(0) : my.getTimestamp(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r464 r478 251 251 buttonPanel.add(deleteButton); 252 252 253 mergeButton.setToolTipText(tr("Merge the selected layer into the layer directly below."));253 mergeButton.setToolTipText(tr("Merge the layer directly below into the selected layer.")); 254 254 mergeButton.addActionListener(new ActionListener(){ 255 255 public void actionPerformed(ActionEvent e) { 256 Layer l From= (Layer)instance.getSelectedValue();257 Layer l To= (Layer)model.get(instance.getSelectedIndex()+1);256 Layer lTo = (Layer)instance.getSelectedValue(); 257 Layer lFrom = (Layer)model.get(instance.getSelectedIndex()+1); 258 258 lTo.mergeFrom(lFrom); 259 instance.setSelectedValue(lTo, true);260 259 mapView.removeLayer(lFrom); 260 updateButtonEnabled(); 261 mapView.repaint(); 261 262 } 262 263 }); … … 277 278 boolean enable = model.getSize() > 1; 278 279 enable = enable && sel < model.getSize()-1; 279 enable = enable && l.isMergable((Layer)model.get(sel+1));280 enable = enable && ((Layer)model.get(sel+1)).isMergable(l); 280 281 mergeButton.setEnabled(enable); 281 282 upButton.setEnabled(sel > 0);
Note:
See TracChangeset
for help on using the changeset viewer.