Changeset 478 in josm for trunk/src/org/openstreetmap/josm/data/osm/visitor
- Timestamp:
- 2007-12-01T13:58:58+01:00 (18 years ago)
- File:
-
- 1 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();
Note:
See TracChangeset
for help on using the changeset viewer.
