Changeset 17183 in josm


Ignore:
Timestamp:
2020-10-13T10:08:22+02:00 (9 days ago)
Author:
GerdP
Message:

fix #19924: Extruder: Problem with common node extruding to the inside.

  • revert r17141
  • use wNew.getNodes() to create ChangeNodesCommand

Stupid me! Methods Way.addNode() and Way.removeNode() cannot simply be replaced by List.add() or List.remove(). Results can differ.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java

    r17157 r17183  
    589589            EastNorth b = ws.getSecondNode().getEastNorth();
    590590            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);
    593593            DataSet ds = ws.way.getDataSet();
    594594            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
    596598        }
    597599    }
     
    637639        // create extrusion
    638640        Collection<Command> cmds = new LinkedList<>();
    639         List<Node> modNodes = selectedSegment.way.getNodes();
     641        Way wnew = new Way(selectedSegment.way);
    640642        boolean wayWasModified = false;
    641         boolean wayWasSingleSegment = modNodes.size() == 2;
     643        boolean wayWasSingleSegment = wnew.getNodesCount() == 2;
    642644        int insertionPoint = selectedSegment.lowerIndex + 1;
    643645
     
    659661            Node n1Old = selectedSegment.getFirstNode();
    660662            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);
    663665            wayWasModified = true;
    664666            cmds.add(new AddCommand(ds, n1New));
     
    667669            //introduce new node
    668670            Node n1New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN1en));
    669             modNodes.add(insertionPoint, n1New);
     671            wnew.addNode(insertionPoint, n1New);
    670672            wayWasModified = true;
    671673            insertionPoint++;
     
    689691            Node n2Old = selectedSegment.getSecondNode();
    690692            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);
    693695            wayWasModified = true;
    694696            cmds.add(new AddCommand(ds, n2New));
     
    697699            //introduce new node
    698700            Node n2New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN2en));
    699             modNodes.add(insertionPoint, n2New);
     701            wnew.addNode(insertionPoint, n2New);
    700702            wayWasModified = true;
    701703            cmds.add(new AddCommand(ds, n2New));
     
    705707        //the way was a single segment, close the way
    706708        if (wayWasSingleSegment) {
    707             modNodes.add(modNodes.get(0));
     709            wnew.addNode(selectedSegment.getFirstNode());
    708710            wayWasModified = true;
    709711        }
    710712        if (wayWasModified) {
    711713            // 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
    713716        }
    714717        Command c = new SequenceCommand(tr("Extrude Way"), cmds);
Note: See TracChangeset for help on using the changeset viewer.