Changeset 1567 in josm for trunk/src/org/openstreetmap/josm/data/osm
- Timestamp:
- 2009-05-02T20:09:40+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r1560 r1567 217 217 218 218 /** 219 * @return <code>true</code>, if no merge is needed or merge is performed already. 219 * Tries to merge a primitive <code>other</code> into an existing primitive with the same id. 220 * 221 * @param myPrimitives the complete set of my primitives (potential merge targets) 222 * @param myPrimitivesWithID the map of primitives (potential merge targets) with an id <> 0, for faster lookup 223 * by id. Key is the id, value the primitive with the given value. myPrimitives.valueSet() is a 224 * subset of primitives. 225 * @param other the other primitive which is to be merged with a primitive in primitives if possible 226 * @return true, if this method was able to merge <code>other</code> with an existing node; false, otherwise 220 227 */ 221 228 private <P extends OsmPrimitive> boolean mergeById( 222 Collection<P> primitives, HashMap<Long, P> hash, P other) { 223 // Fast-path merging of identical objects 224 if (hash.containsKey(other.id)) { 225 P my = hash.get(other.id); 226 if (my.realEqual(other, true)) { 229 Collection<P> myPrimitives, HashMap<Long, P> myPrimitivesWithID, P other) { 230 231 // merge other into an existing primitive with the same id, if possible 232 // 233 if (myPrimitivesWithID.containsKey(other.id)) { 234 P my = myPrimitivesWithID.get(other.id); 235 if (my.realEqual(other, true /* compare semantic fields only */)) { 236 // make sure the merge target becomes the higher version number 237 // and the later timestamp 238 // 239 my.version = Math.max(other.version, my.version); 240 if (other.getTimestamp().after(my.getTimestamp())) { 241 my.setTimestamp(other.getTimestamp()); 242 } 227 243 merged.put(other, my); 228 244 return true; … … 230 246 } 231 247 232 for (P my : primitives) { 233 if (my.realEqual(other, false)) { 248 // try to merge into one of the existing primitives 249 // 250 for (P my : myPrimitives) { 251 if (my.realEqual(other, false /* compare all fields */)) { 234 252 merged.put(other, my); 235 253 return true; // no merge needed.
Note:
See TracChangeset
for help on using the changeset viewer.