Changeset 3040 in josm for trunk


Ignore:
Timestamp:
2010-02-25T00:18:42+01:00 (10 years ago)
Author:
mjulius
Message:

in DataSetMerger use PrimitiveId instead of UniqueId for mergedMap - UniqueIds are not unique across primitive types.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java

    r3039 r3040  
    3535    /**
    3636     * A map of all primitives that got replaced with other primitives.
    37      * Key is the primitive id in their dataset, the value is the id in my dataset
    38      */
    39     private final Map<Long, Long> mergedMap;
     37     * Key is the PrimitiveId in their dataset, the value is the PrimitiveId in my dataset
     38     */
     39    private final Map<PrimitiveId, PrimitiveId> mergedMap;
    4040    /** a set of primitive ids for which we have to fix references (to nodes and
    4141     * to relation members) after the first phase of merging
     
    5858        this.sourceDataSet = sourceDataSet;
    5959        conflicts = new ConflictCollection();
    60         mergedMap = new HashMap<Long, Long>();
     60        mergedMap = new HashMap<PrimitiveId, PrimitiveId>();
    6161        objectsWithChildrenToMerge = new HashSet<PrimitiveId>();
    6262        deletedObjectsToUnlink = new HashSet<OsmPrimitive>();
     
    106106                }
    107107                if (target.hasEqualSemanticAttributes(source)) {
    108                     mergedMap.put(source.getUniqueId(), target.getUniqueId());
     108                    mergedMap.put(source.getPrimitiveId(), target.getPrimitiveId());
    109109                    // copy the technical attributes from other
    110110                    // version
     
    131131        target.mergeFrom(source);
    132132        targetDataSet.addPrimitive(target);
    133         mergedMap.put(source.getUniqueId(), target.getUniqueId());
     133        mergedMap.put(source.getPrimitiveId(), target.getPrimitiveId());
    134134        objectsWithChildrenToMerge.add(source.getPrimitiveId());
    135135    }
    136136
    137137    protected OsmPrimitive getMergeTarget(OsmPrimitive mergeSource) throws IllegalStateException{
    138         Long targetId = mergedMap.get(mergeSource.getUniqueId());
     138        PrimitiveId targetId = mergedMap.get(mergeSource.getPrimitiveId());
    139139        if (targetId == null)
    140140            return null;
    141         return targetDataSet.getPrimitiveById(targetId, mergeSource.getType());
     141        return targetDataSet.getPrimitiveById(targetId);
    142142    }
    143143
     
    278278            return false;
    279279        // found a corresponding target, remember it
    280         mergedMap.put(source.getUniqueId(), target.getUniqueId());
     280        mergedMap.put(source.getPrimitiveId(), target.getPrimitiveId());
    281281
    282282        if (target.getVersion() > source.getVersion())
Note: See TracChangeset for help on using the changeset viewer.