Changeset 1567 in josm
- Timestamp:
- 2009-05-02T20:09:40+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/conflict/DeleteConflict.java
r1561 r1567 22 22 @Override public void apply(OsmPrimitive target, OsmPrimitive other) { 23 23 target.deleted = other.deleted; 24 target.version = Math.max(target.version, other.version); 24 int newversion = Math.max(target.version, other.version); 25 // set version on "other" as well in case user decides to keep local 26 target.version = newversion; 27 other.version = newversion; 28 25 29 } 26 30 } -
trunk/src/org/openstreetmap/josm/data/conflict/PositionConflict.java
r1561 r1567 25 25 ((Node)target).coor = ((Node)other).coor; 26 26 ((Node)target).eastNorth = ((Node)other).eastNorth; 27 target.version = Math.max(target.version, other.version); 27 int newversion = Math.max(target.version, other.version); 28 // set version on "other" as well in case user decides to keep local 29 target.version = newversion; 30 other.version = newversion; 28 31 } 29 32 } -
trunk/src/org/openstreetmap/josm/data/conflict/PropertyConflict.java
r1561 r1567 28 28 @Override public void apply(OsmPrimitive target, OsmPrimitive other) { 29 29 target.put(key, other.get(key)); 30 target.version = Math.max(target.version, other.version); 30 int newversion = Math.max(target.version, other.version); 31 // set version on "other" as well in case user decides to keep local 32 target.version = newversion; 33 other.version = newversion; 31 34 } 32 35 } -
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.