public class DataSetMerger extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private ConflictCollection |
conflicts
the collection of conflicts created during merging
|
private java.util.Map<PrimitiveId,PrimitiveId> |
mergedMap
A map of all primitives that got replaced with other primitives.
|
private java.util.Set<OsmPrimitive> |
objectsToDelete |
private java.util.Set<PrimitiveId> |
objectsWithChildrenToMerge
a set of primitive ids for which we have to fix references (to nodes and
to relation members) after the first phase of merging
|
private DataSet |
sourceDataSet
the source dataset where primitives are merged from
|
private DataSet |
targetDataSet
the target dataset for merging
|
Constructor and Description |
---|
DataSetMerger(DataSet targetDataSet,
DataSet sourceDataSet)
constructor
The visitor will merge
sourceDataSet onto targetDataSet |
Modifier and Type | Method and Description |
---|---|
protected void |
addConflict(Conflict<?> c) |
protected void |
addConflict(OsmPrimitive my,
OsmPrimitive their) |
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.
|
protected void |
fixIncomplete(Way other) |
void |
fixReferences()
Postprocess the dataset and fix all merged references to point to the actual
data.
|
ConflictCollection |
getConflicts()
replies the map of conflicts
|
protected OsmPrimitive |
getMergeTarget(OsmPrimitive mergeSource) |
DataSet |
getTargetDataSet()
replies my dataset
|
void |
merge()
Runs the merge operation.
|
void |
merge(ProgressMonitor progressMonitor)
Runs the merge operation.
|
void |
merge(ProgressMonitor progressMonitor,
boolean mergeBounds)
Runs the merge operation.
|
private boolean |
mergeById(OsmPrimitive source)
Tries to merge a primitive
source into an existing primitive with the same id. |
private void |
mergeNodeList(Way source)
Merges the node list of a source way onto its target way.
|
protected void |
mergePrimitive(OsmPrimitive source,
java.util.Collection<? extends OsmPrimitive> candidates)
Merges a primitive onto primitives dataset.
|
private void |
mergeRelationMembers(Relation source)
Merges the relation members of a source relation onto the corresponding target relation.
|
private static void |
resetPrimitive(OsmPrimitive osm) |
private final ConflictCollection conflicts
private final DataSet targetDataSet
private final DataSet sourceDataSet
private final java.util.Map<PrimitiveId,PrimitiveId> mergedMap
private final java.util.Set<PrimitiveId> objectsWithChildrenToMerge
private final java.util.Set<OsmPrimitive> objectsToDelete
public DataSetMerger(DataSet targetDataSet, DataSet sourceDataSet)
sourceDataSet
onto targetDataSet
targetDataSet
- dataset with my primitives. Must not be null.sourceDataSet
- dataset with their primitives. Ignored, if null.java.lang.IllegalArgumentException
- if myDataSet is nullprotected void mergePrimitive(OsmPrimitive source, java.util.Collection<? extends OsmPrimitive> candidates)
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.source
- the primitive to mergecandidates
- a set of possible candidates for a new primitiveprotected OsmPrimitive getMergeTarget(OsmPrimitive mergeSource)
protected void addConflict(Conflict<?> c)
protected void addConflict(OsmPrimitive my, OsmPrimitive their)
protected void fixIncomplete(Way other)
public void fixReferences()
protected void deleteMarkedObjects()
private static void resetPrimitive(OsmPrimitive osm)
private void mergeNodeList(Way source)
source
- the source wayjava.lang.IllegalStateException
- if no target way can be found for the source wayjava.lang.IllegalStateException
- if there isn't a target node for one of the nodes in the source wayprivate void mergeRelationMembers(Relation source)
source
- the source relationjava.lang.IllegalStateException
- if there is no corresponding target relationjava.lang.IllegalStateException
- if there isn't a corresponding target object for one of the relation
members in sourceprivate boolean mergeById(OsmPrimitive source)
source
into an existing primitive with the same id.source
- the source primitive which is to be merged into a target primitivesource
into a target object; false, otherwisepublic void merge()
OsmPrimitive
s are in
getTargetDataSet()
.
See getConflicts()
for a map of conflicts after the merge operation.public void merge(ProgressMonitor progressMonitor)
OsmPrimitive
s are in
getTargetDataSet()
.
See getConflicts()
for a map of conflicts after the merge operation.progressMonitor
- The progress monitorpublic void merge(ProgressMonitor progressMonitor, boolean mergeBounds)
OsmPrimitive
s are in
getTargetDataSet()
.
See getConflicts()
for a map of conflicts after the merge operation.progressMonitor
- The progress monitormergeBounds
- Whether or not to merge the bounds of the new DataSet to
the existing DataSetpublic DataSet getTargetDataSet()
public ConflictCollection getConflicts()