Changes between Version 14 and Version 15 of Help/Plugin/Scripting/Python


Ignore:
Timestamp:
2018-09-07T18:59:55+02:00 (8 years ago)
Author:
Polyglot
Comment:

formatting changes to remove horizontal scroll bar

Legend:

Unmodified
Added
Removed
Modified
  • Help/Plugin/Scripting/Python

    v14 v15  
    1818
    1919    if not(selected_ways) or len(selected_ways)>1:
    20         JOptionPane.showMessageDialog(MainApplication.parent, "Please select a single way that connects to a roundabout")
     20        JOptionPane.showMessageDialog(MainApplication.parent,
     21                                         "Please select a single way that connects to a roundabout")
    2122    else:
    2223        for way in selected_ways:
     
    3536                            for n in parentway.getNodes():
    3637                                if common_node:
    37                                     # found common node between selected way and roundabout way in previous iteration
     38                                    # found common node between selected way and
     39                                    # roundabout way in previous iteration
    3840                                    node_after = n
    3941                                    # we are done here
     
    4345                                    common_node = n
    4446                                    if not(node_before):
    45                                         # normally we encountered a node on the roundabout way before this one
    46                                         # but if the common node is the first node of an unsplit roundabout
    47                                         # we will need to take the last node of the roundabout instead
     47                                        # normally we encountered a node on the roundabout way
     48                                        # before this one, but if the common node is the first node
     49                                        # of an unsplit roundabout, we will need to take the last
     50                                        # node of the roundabout instead
    4851                                        node_before = parentway.getNodes()[-2]
    4952                                        node_after = parentway.getNodes()[1]
    5053                                        break
    51                                     # if not we go through the loop one more time to put the next node in node_after
     54                                    # if not we go through the loop one more time to put the next
     55                                    # node in node_after
    5256                                    continue
    5357                                node_before = n
    5458                        if common_node:
    55                             # if common_node is already defined at this point, it means it was the first node of the selected way
     59                            # if common_node is already defined at this point, it means it was
     60                            # the first node of the selected way,
    5661                            # so it will have to be replaced with node_before in the selected way
    5762                            common_node_becomes_node_before = True
     
    6267                            adjacent_node_to_split_on = way.getNodes()[-1]
    6368                if not(common_node) or common_node_becomes_node_before==None:
    64                     JOptionPane.showMessageDialog(MainApplication.parent, "Please select a way that connects to a roundabout")
     69                    JOptionPane.showMessageDialog(MainApplication.parent,
     70                                               "Please select a way that connects to a roundabout")
    6571                else:
    6672                    print common_node.get('name')
     
    7076                    commandsList = []
    7177                    if len(way.getNodes())>2:
    72                         commandsList.append(Command.SplitWayCommand.split(way, [adjacent_node_to_split_on], []))
    73                         MainApplication.undoRedo.add(Command.SequenceCommand("Split selected way", commandsList))
     78                        # split off last segment before roundabout if needed
     79                        commandsList.append(Command.SplitWayCommand.split(
     80                                    way, [adjacent_node_to_split_on], []))
     81                        MainApplication.undoRedo.add(Command.SequenceCommand(
     82                                    "Split selected way", commandsList))
    7483                        commandsList = []
     84                    # After splitting find the segment that connects to the roundabout again
    7585                    for waypartconnectedtoroundabout in adjacent_node_to_split_on.getParentWays():
    7686                        if common_node in waypartconnectedtoroundabout.getNodes():
     
    8696                    # replace its nodes, so it becomes a fork
    8797                    modified_way.setNodes([node_before, adjacent_node_to_split_on, node_after])
    88                     #
     98                    # add oneway tag
    8999                    modified_way.put('oneway', 'yes')
    90                     #
    91                     commandsList.append(Command.ChangeCommand(waypartconnectedtoroundabout, modified_way))
    92                     MainApplication.undoRedo.add(Command.SequenceCommand("Add oneway tag and create forked way", commandsList))
     100                    # apply the changes
     101                    commandsList.append(Command.ChangeCommand(
     102                                    waypartconnectedtoroundabout, modified_way))
     103                    MainApplication.undoRedo.add(Command.SequenceCommand(
     104                                    "Add oneway tag and create forked way", commandsList))
    93105                    commandsList = []
    94                     commandsList.append(Command.SplitWayCommand.split(waypartconnectedtoroundabout, [adjacent_node_to_split_on], []))
    95                     MainApplication.undoRedo.add(Command.SequenceCommand("Split fork into 2 ways", commandsList))
     106                    # split this way where it forks
     107                    commandsList.append(Command.SplitWayCommand.split(
     108                                    waypartconnectedtoroundabout, [adjacent_node_to_split_on], []))
     109                    MainApplication.undoRedo.add(Command.SequenceCommand(
     110                                    "Split fork into 2 ways", commandsList))
    96111                    commandsList = []
    97112