Class DataSetMerger


  • public class DataSetMerger
    extends java.lang.Object
    A dataset merger which takes a target and a source dataset and merges the source data set onto the target dataset.
    • Constructor Detail

      • DataSetMerger

        public DataSetMerger​(DataSet targetDataSet,
                             DataSet sourceDataSet)
        constructor

        The visitor will merge sourceDataSet onto targetDataSet

        Parameters:
        targetDataSet - dataset with my primitives. Must not be null.
        sourceDataSet - dataset with their primitives. Ignored, if null.
        Throws:
        java.lang.IllegalArgumentException - if myDataSet is null
    • Method Detail

      • mergePrimitive

        protected void mergePrimitive​(OsmPrimitive source,
                                      java.util.Collection<? extends OsmPrimitive> candidates)
        Merges a primitive onto primitives dataset.

        If other.id != 0 it tries to merge it with an corresponding primitive from my dataset with the same id. If this is not possible a conflict is remembered in conflicts.

        If other.id == 0 (new primitive) it tries to find a primitive in my dataset with id == 0 which is semantically equal. If it finds one it merges its technical attributes onto my primitive.

        Parameters:
        source - the primitive to merge
        candidates - a set of possible candidates for a new primitive
      • fixReferences

        public void fixReferences()
        Postprocess the dataset and fix all merged references to point to the actual data.
      • deleteMarkedObjects

        protected void deleteMarkedObjects()
        Deleted objects in objectsToDelete set and create conflicts for objects that cannot be deleted because they're referenced in the target dataset.
      • mergeNodeList

        private void mergeNodeList​(Way source)
        Merges the node list of a source way onto its target way.
        Parameters:
        source - the source way
        Throws:
        java.lang.IllegalStateException - if no target way can be found for the source way
        java.lang.IllegalStateException - if there isn't a target node for one of the nodes in the source way
      • mergeRelationMembers

        private void mergeRelationMembers​(Relation source)
        Merges the relation members of a source relation onto the corresponding target relation.
        Parameters:
        source - the source relation
        Throws:
        java.lang.IllegalStateException - if there is no corresponding target relation
        java.lang.IllegalStateException - if there isn't a corresponding target object for one of the relation members in source
      • mergeById

        private boolean mergeById​(OsmPrimitive source)
        Tries to merge a primitive source into an existing primitive with the same id.
        Parameters:
        source - the source primitive which is to be merged into a target primitive
        Returns:
        true, if this method was able to merge source into a target object; false, otherwise
      • merge

        public void merge​(ProgressMonitor progressMonitor,
                          boolean mergeBounds)
        Runs the merge operation. Successfully merged OsmPrimitives are in getTargetDataSet().

        See getConflicts() for a map of conflicts after the merge operation.

        Parameters:
        progressMonitor - The progress monitor
        mergeBounds - Whether or not to merge the bounds of the new DataSet to the existing DataSet
        Since:
        15127