Package org.openstreetmap.josm.data.osm
Class DataSetMerger
java.lang.Object
org.openstreetmap.josm.data.osm.DataSetMerger
A dataset merger which takes a target and a source dataset and merges the source data set
onto the target dataset.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConflictCollectionthe collection of conflicts created during mergingprivate final Map<PrimitiveId,PrimitiveId> A map of all primitives that got replaced with other primitives.private final Set<OsmPrimitive>private final Set<PrimitiveId>a set of primitive ids for which we have to fix references (to nodes and to relation members) after the first phase of mergingprivate final DataSetthe source dataset where primitives are merged fromprivate final DataSetthe target dataset for merging -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddConflict(Conflict<?> c) protected voidaddConflict(OsmPrimitive my, OsmPrimitive their) protected voidDeleted objects in objectsToDelete set and create conflicts for objects that cannot be deleted because they're referenced in the target dataset.protected voidfixIncomplete(Way other) voidPostprocess the dataset and fix all merged references to point to the actual data.replies the map of conflictsprotected OsmPrimitivegetMergeTarget(OsmPrimitive mergeSource) replies my datasetvoidmerge()Runs the merge operation.voidmerge(ProgressMonitor progressMonitor) Runs the merge operation.voidmerge(ProgressMonitor progressMonitor, boolean mergeBounds) Runs the merge operation.private booleanmergeById(OsmPrimitive source) Tries to merge a primitivesourceinto an existing primitive with the same id.private voidmergeNodeList(Way source) Merges the node list of a source way onto its target way.protected voidmergePrimitive(OsmPrimitive source, Collection<? extends OsmPrimitive> candidates) Merges a primitive onto primitives dataset.private voidmergeRelationMembers(Relation source) Merges the relation members of a source relation onto the corresponding target relation.private voidreplaceConflict(Conflict<?> oldConflict, Conflict<?> newConflict)
-
Field Details
-
conflicts
the collection of conflicts created during merging -
targetDataSet
the target dataset for merging -
sourceDataSet
the source dataset where primitives are merged from -
mergedMap
A map of all primitives that got replaced with other primitives. Key is the PrimitiveId in their dataset, the value is the PrimitiveId in my dataset -
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 -
objectsToDelete
-
-
Constructor Details
-
DataSetMerger
constructorThe visitor will merge
sourceDataSetontotargetDataSet- Parameters:
targetDataSet- dataset with my primitives. Must not be null.sourceDataSet- dataset with their primitives. Ignored, if null.- Throws:
IllegalArgumentException- if myDataSet is null
-
-
Method Details
-
mergePrimitive
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 mergecandidates- a set of possible candidates for a new primitive
-
getMergeTarget
-
addConflict
-
addConflict
-
replaceConflict
-
fixIncomplete
-
fixReferences
Postprocess the dataset and fix all merged references to point to the actual data. -
deleteMarkedObjects
Deleted objects in objectsToDelete set and create conflicts for objects that cannot be deleted because they're referenced in the target dataset. -
mergeNodeList
Merges the node list of a source way onto its target way.- Parameters:
source- the source way- Throws:
IllegalStateException- if no target way can be found for the source wayIllegalStateException- if there isn't a target node for one of the nodes in the source way
-
mergeRelationMembers
Merges the relation members of a source relation onto the corresponding target relation.- Parameters:
source- the source relation- Throws:
IllegalStateException- if there is no corresponding target relationIllegalStateException- if there isn't a corresponding target object for one of the relation members in source
-
mergeById
Tries to merge a primitivesourceinto 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
sourceinto a target object; false, otherwise
-
merge
Runs the merge operation. Successfully mergedOsmPrimitives are ingetTargetDataSet().See
getConflicts()for a map of conflicts after the merge operation. -
merge
Runs the merge operation. Successfully mergedOsmPrimitives are ingetTargetDataSet().See
getConflicts()for a map of conflicts after the merge operation.- Parameters:
progressMonitor- The progress monitor
-
merge
Runs the merge operation. Successfully mergedOsmPrimitives are ingetTargetDataSet().See
getConflicts()for a map of conflicts after the merge operation.- Parameters:
progressMonitor- The progress monitormergeBounds- Whether or not to merge the bounds of the new DataSet to the existing DataSet- Since:
- 15127
-
getTargetDataSet
replies my dataset- Returns:
- the own (target) data set
-
getConflicts
replies the map of conflicts- Returns:
- the map of conflicts
-