Class SplitWayCommand

  • All Implemented Interfaces:
    PseudoCommand

    public class SplitWayCommand
    extends SequenceCommand
    Splits a way into multiple ways (all identical except for their node list). Ways are just split at the selected nodes. The nodes remain in their original order. Selected nodes at the end of a way are ignored.
    Since:
    12828 (SplitWayAction converted to a Command)
    • Constructor Detail

      • SplitWayCommand

        public SplitWayCommand​(String name,
                               Collection<Command> commandList,
                               List<? extends PrimitiveId> newSelection,
                               Way originalWay,
                               List<Way> newWays)
        Create a new SplitWayCommand.
        Parameters:
        name - The description text
        commandList - 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 getNewWays())
    • Method Detail

      • setWarningNotifier

        public static void setWarningNotifier​(Consumer<String> notifier)
        Sets the global warning notifier.
        Parameters:
        notifier - warning notifier in charge of displaying warning message, if any. Must not be null
      • getNewSelection

        public List<? extends PrimitiveIdgetNewSelection()
        Replies the new list of selected primitives ids
        Returns:
        The new list of selected primitives ids
      • getOriginalWay

        public Way getOriginalWay()
        Replies the original way being split
        Returns:
        The original way being split
      • getNewWays

        public List<WaygetNewWays()
        Replies the resulting new ways
        Returns:
        The resulting new ways
      • buildSplitChunks

        public static List<List<Node>> buildSplitChunks​(Way wayToSplit,
                                                        List<Node> splitPoints)
        Splits the nodes of 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.
        Parameters:
        wayToSplit - the way to split. Must not be null.
        splitPoints - the nodes where the way is split. Must not be null.
        Returns:
        the list of chunks
      • createNewWaysFromChunks

        public static List<WaycreateNewWaysFromChunks​(Way way,
                                                        Iterable<List<Node>> wayChunks)
        Creates new way objects for the way chunks and transfers the keys from the original way.
        Parameters:
        way - the original way whose keys are transferred
        wayChunks - the way chunks
        Returns:
        the new way objects
      • splitWay

        public static SplitWayCommand splitWay​(Way way,
                                               List<List<Node>> wayChunks,
                                               Collection<? extends OsmPrimitive> selection)
        Splits the way 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).
        Parameters:
        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 primitives
        Returns:
        the result from the split operation
      • splitWay

        public static SplitWayCommand splitWay​(Way way,
                                               List<List<Node>> wayChunks,
                                               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. The SplitWayCommand.Strategy is used to determine which way chunk should reuse the old id and its history.

        If the split way is part of relations, and the order of the new parts in these relations cannot be determined due to missing relation members, the user will be asked to consent to downloading these missing members.

        Note that changes are not applied to the data yet. You have to submit the command first, i.e. UndoRedoHandler.getInstance().add(result).

        Parameters:
        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 primitives
        splitStrategy - The strategy used to determine which way chunk should reuse the old id and its history
        Returns:
        the result from the split operation
      • splitWay

        public static Optional<SplitWayCommandsplitWay​(Way way,
                                                         List<List<Node>> wayChunks,
                                                         Collection<? extends OsmPrimitive> selection,
                                                         SplitWayCommand.Strategy splitStrategy,
                                                         SplitWayCommand.WhenRelationOrderUncertain whenRelationOrderUncertain)
        Splits the way 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).

        Parameters:
        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 primitives
        splitStrategy - The strategy used to determine which way chunk should reuse the old id and its history
        whenRelationOrderUncertain - What to do when the split way is part of relations, and the order of the new parts in the relation cannot be determined without downloading missing relation members.
        Returns:
        The result from the split operation, may be an empty Optional if the operation is aborted.
      • split

        public static SplitWayCommand split​(Way way,
                                            List<Node> atNodes,
                                            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. 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.
        Parameters:
        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 primitives
        Returns:
        the result from the split operation
      • addSpecialRelationType

        public static String addSpecialRelationType​(String relationType,
                                                    String treatAs)
        Add relations that are treated in a specific way.
        Parameters:
        relationType - The value in the type key
        treatAs - The type of relation to treat the relationType as. Currently only supports relations that can be handled like "restriction" relations.
        Returns:
        the previous value associated with relationType, or null if there was no mapping
        Since:
        15078
      • getSpecialRelationTypes

        public static Map<String,​StringgetSpecialRelationTypes()
        Get the types of relations that are treated differently
        Returns:
        Map<Relation Type, Type of Relation it is to be treated as>
        Since:
        15078