- Timestamp:
- 2020-10-13T10:08:22+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r17157 r17183 589 589 EastNorth b = ws.getSecondNode().getEastNorth(); 590 590 n.setEastNorth(Geometry.closestPointToSegment(a, b, n.getEastNorth())); 591 List<Node> modnodes = ws.way.getNodes();592 modnodes.add(ws.lowerIndex+1, n);591 Way wnew = new Way(ws.way); 592 wnew.addNode(ws.lowerIndex+1, n); 593 593 DataSet ds = ws.way.getDataSet(); 594 594 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Add a new node to an existing way"), 595 new AddCommand(ds, n), new ChangeNodesCommand(ds, ws.way, modnodes))); 595 new AddCommand(ds, n), new ChangeNodesCommand(ds, ws.way, wnew.getNodes()))); 596 wnew.setNodes(null); // see #19855 597 596 598 } 597 599 } … … 637 639 // create extrusion 638 640 Collection<Command> cmds = new LinkedList<>(); 639 List<Node> modNodes = selectedSegment.way.getNodes();641 Way wnew = new Way(selectedSegment.way); 640 642 boolean wayWasModified = false; 641 boolean wayWasSingleSegment = modNodes.size() == 2;643 boolean wayWasSingleSegment = wnew.getNodesCount() == 2; 642 644 int insertionPoint = selectedSegment.lowerIndex + 1; 643 645 … … 659 661 Node n1Old = selectedSegment.getFirstNode(); 660 662 Node n1New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN1en)); 661 modNodes.add(insertionPoint, n1New);662 modNodes.remove(n1Old);663 wnew.addNode(insertionPoint, n1New); 664 wnew.removeNode(n1Old); 663 665 wayWasModified = true; 664 666 cmds.add(new AddCommand(ds, n1New)); … … 667 669 //introduce new node 668 670 Node n1New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN1en)); 669 modNodes.add(insertionPoint, n1New);671 wnew.addNode(insertionPoint, n1New); 670 672 wayWasModified = true; 671 673 insertionPoint++; … … 689 691 Node n2Old = selectedSegment.getSecondNode(); 690 692 Node n2New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN2en)); 691 modNodes.add(insertionPoint, n2New);692 modNodes.remove(n2Old);693 wnew.addNode(insertionPoint, n2New); 694 wnew.removeNode(n2Old); 693 695 wayWasModified = true; 694 696 cmds.add(new AddCommand(ds, n2New)); … … 697 699 //introduce new node 698 700 Node n2New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN2en)); 699 modNodes.add(insertionPoint, n2New);701 wnew.addNode(insertionPoint, n2New); 700 702 wayWasModified = true; 701 703 cmds.add(new AddCommand(ds, n2New)); … … 705 707 //the way was a single segment, close the way 706 708 if (wayWasSingleSegment) { 707 modNodes.add(modNodes.get(0));709 wnew.addNode(selectedSegment.getFirstNode()); 708 710 wayWasModified = true; 709 711 } 710 712 if (wayWasModified) { 711 713 // we only need to change the way if its node list was really modified 712 cmds.add(new ChangeNodesCommand(selectedSegment.way, modNodes)); 714 cmds.add(new ChangeNodesCommand(selectedSegment.way, wnew.getNodes())); 715 wnew.setNodes(null); // see #19855 713 716 } 714 717 Command c = new SequenceCommand(tr("Extrude Way"), cmds);
Note:
See TracChangeset
for help on using the changeset viewer.