public class SplitWayCommand extends SequenceCommand
SplitWayAction
converted to a Command
)Modifier and Type | Class and Description |
---|---|
private static class |
SplitWayCommand.RelationInformation |
static interface |
SplitWayCommand.Strategy
Determines which way chunk should reuse the old id and its history
|
Command.OldNodeState
Modifier and Type | Field and Description |
---|---|
private java.util.List<? extends PrimitiveId> |
newSelection |
private java.util.List<Way> |
newWays |
private Way |
originalWay |
private static java.util.Map<java.lang.String,java.lang.String> |
relationSpecialTypes
Map<Restriction type, type to treat it as>
|
private static java.util.function.Consumer<java.lang.String> |
warningNotifier |
continueOnError
IS_INCOMPLETE, IS_OK, IS_OUTSIDE
Constructor and Description |
---|
SplitWayCommand(java.lang.String name,
java.util.Collection<Command> commandList,
java.util.List<? extends PrimitiveId> newSelection,
Way originalWay,
java.util.List<Way> newWays)
Create a new
SplitWayCommand . |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
addSpecialRelationType(java.lang.String relationType,
java.lang.String treatAs)
Add relations that are treated in a specific way.
|
static java.util.List<java.util.List<Node>> |
buildSplitChunks(Way wayToSplit,
java.util.List<Node> splitPoints)
Splits the nodes of
wayToSplit into a list of node sequences
which are separated at the nodes in splitPoints . |
static java.util.List<Way> |
createNewWaysFromChunks(Way way,
java.lang.Iterable<java.util.List<Node>> wayChunks)
Creates new way objects for the way chunks and transfers the keys from the original way.
|
static SplitWayCommand |
doSplitWay(Way way,
Way wayToKeep,
java.util.List<Way> newWays,
java.util.List<OsmPrimitive> newSelection)
Effectively constructs the
SplitWayCommand . |
(package private) static java.util.List<? extends OsmPrimitive> |
findVias(Relation r,
java.lang.String type) |
java.util.List<? extends PrimitiveId> |
getNewSelection()
Replies the new list of selected primitives ids
|
java.util.List<Way> |
getNewWays()
Replies the resulting new ways
|
Way |
getOriginalWay()
Replies the original way being split
|
static java.util.Map<java.lang.String,java.lang.String> |
getSpecialRelationTypes()
Get the types of relations that are treated differently
|
static void |
setWarningNotifier(java.util.function.Consumer<java.lang.String> notifier)
Sets the global warning notifier.
|
static SplitWayCommand |
split(Way way,
java.util.List<Node> atNodes,
java.util.Collection<? extends OsmPrimitive> selection)
Splits the way
way at the nodes in atNodes and replies
the result of this process in an instance of SplitWayCommand . |
static SplitWayCommand |
splitWay(Way way,
java.util.List<java.util.List<Node>> wayChunks,
java.util.Collection<? extends OsmPrimitive> selection)
Splits the way
way into chunks of wayChunks and replies
the result of this process in an instance of SplitWayCommand . |
static SplitWayCommand |
splitWay(Way way,
java.util.List<java.util.List<Node>> wayChunks,
java.util.Collection<? extends OsmPrimitive> selection,
SplitWayCommand.Strategy splitStrategy)
Splits the way
way into chunks of wayChunks and replies
the result of this process in an instance of SplitWayCommand . |
private static SplitWayCommand.RelationInformation |
treatAsRestriction(Relation r,
RelationMember rm,
Relation c,
java.util.Collection<Way> newWays,
Way way,
Way changedWay) |
equals, executeCommand, fillModifiedData, getChildren, getDescriptionIcon, getDescriptionText, getLastCommand, getName, getParticipatingPrimitives, hashCode, setSequence, setSequenceComplete, undoCommand, undoCommands
checkOutlyingOrIncompleteOperation, ensurePrimitivesAreInDataset, getAffectedDataSet, getOrig
private static volatile java.util.function.Consumer<java.lang.String> warningNotifier
private final java.util.List<? extends PrimitiveId> newSelection
private final Way originalWay
private static final java.util.Map<java.lang.String,java.lang.String> relationSpecialTypes
public SplitWayCommand(java.lang.String name, java.util.Collection<Command> commandList, java.util.List<? extends PrimitiveId> newSelection, Way originalWay, java.util.List<Way> newWays)
SplitWayCommand
.name
- The description textcommandList
- The sequence of commands that should be executed.newSelection
- The new list of selected primitives ids (which is saved for later retrieval with getNewSelection()
)originalWay
- The original way being split (which is saved for later retrieval with getOriginalWay()
)newWays
- The resulting new ways (which is saved for later retrieval with getOriginalWay()
)public static void setWarningNotifier(java.util.function.Consumer<java.lang.String> notifier)
notifier
- warning notifier in charge of displaying warning message, if any. Must not be nullpublic java.util.List<? extends PrimitiveId> getNewSelection()
public Way getOriginalWay()
public java.util.List<Way> getNewWays()
public static java.util.List<java.util.List<Node>> buildSplitChunks(Way wayToSplit, java.util.List<Node> splitPoints)
wayToSplit
into a list of node sequences
which are separated at the nodes in splitPoints
.
This method displays warning messages if wayToSplit
and/or
splitPoints
aren't consistent.
Returns null, if building the split chunks fails.wayToSplit
- the way to split. Must not be null.splitPoints
- the nodes where the way is split. Must not be null.public static java.util.List<Way> createNewWaysFromChunks(Way way, java.lang.Iterable<java.util.List<Node>> wayChunks)
way
- the original way whose keys are transferredwayChunks
- the way chunkspublic static SplitWayCommand splitWay(Way way, java.util.List<java.util.List<Node>> wayChunks, java.util.Collection<? extends OsmPrimitive> selection)
way
into chunks of wayChunks
and replies
the result of this process in an instance of SplitWayCommand
.
Note that changes are not applied to the data yet. You have to
submit the command first, i.e. UndoRedoHandler.getInstance().add(result)
.way
- the way to split. Must not be null.wayChunks
- the list of way chunks into the way is split. Must not be null.selection
- The list of currently selected primitivespublic static SplitWayCommand splitWay(Way way, java.util.List<java.util.List<Node>> wayChunks, java.util.Collection<? extends OsmPrimitive> selection, SplitWayCommand.Strategy splitStrategy)
way
into chunks of wayChunks
and replies
the result of this process in an instance of SplitWayCommand
.
The SplitWayCommand.Strategy
is used to determine which
way chunk should reuse the old id and its history.
Note that changes are not applied to the data yet. You have to
submit the command first, i.e. UndoRedoHandler.getInstance().add(result)
.way
- the way to split. Must not be null.wayChunks
- the list of way chunks into the way is split. Must not be null.selection
- The list of currently selected primitivessplitStrategy
- The strategy used to determine which way chunk should reuse the old id and its historypublic static SplitWayCommand doSplitWay(Way way, Way wayToKeep, java.util.List<Way> newWays, java.util.List<OsmPrimitive> newSelection)
SplitWayCommand
.
This method is only public for SplitWayAction
.way
- the way to split. Must not be null.wayToKeep
- way chunk which should reuse the old id and its historynewWays
- potential new waysnewSelection
- new selection list to update (optional: can be null)SplitWayCommand
private static SplitWayCommand.RelationInformation treatAsRestriction(Relation r, RelationMember rm, Relation c, java.util.Collection<Way> newWays, Way way, Way changedWay)
static java.util.List<? extends OsmPrimitive> findVias(Relation r, java.lang.String type)
public static SplitWayCommand split(Way way, java.util.List<Node> atNodes, java.util.Collection<? extends OsmPrimitive> selection)
way
at the nodes in atNodes
and replies
the result of this process in an instance of SplitWayCommand
.
Note that changes are not applied to the data yet. You have to
submit the command first, i.e. UndoRedoHandler.getInstance().add(result)
.
Replies null if the way couldn't be split at the given nodes.way
- the way to split. Must not be null.atNodes
- the list of nodes where the way is split. Must not be null.selection
- The list of currently selected primitivespublic static java.lang.String addSpecialRelationType(java.lang.String relationType, java.lang.String treatAs)
relationType
- The value in the type
keytreatAs
- The type of relation to treat the relationType
as.
Currently only supports relations that can be handled like "restriction"
relations.public static java.util.Map<java.lang.String,java.lang.String> getSpecialRelationTypes()
Map<Relation Type, Type of Relation it is to be treated as>