Ignore:
Timestamp:
2019-01-17T15:57:36+01:00 (6 years ago)
Author:
gerdp
Message:

fix #9346: Circle arc wrongly deleting way

Add check to make sure that selected points are different, show message if the selection doesn't work

Location:
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/curves
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/curves/CircleArcMaker.java

    r34817 r34840  
    9191            }
    9292            // Fix #7341. Find the first way having all nodes in common to sort them in its nodes order
    93             List<Node> consideredNodes = Arrays.asList(new Node[]{n1, n2, n3});
     93            List<Node> consideredNodes = Arrays.asList(n1, n2, n3);
    9494            for (Way w : selectedWays) {
    9595                final List<Node> nodes = w.getNodes();
     
    116116        }
    117117
    118 
    119118        EastNorth p1 = n1.getEastNorth();
    120119        EastNorth p2 = n2.getEastNorth();
    121120        EastNorth p3 = n3.getEastNorth();
    122         // TODO: Check that the points are distinct
     121
     122        // make sure that points are different
     123        if (p1.equals(p2) || p1.equals(p3) || p2.equals(p3)) {
     124            return null;
     125        }
    123126
    124127        // // Calculate the new points in the arc
     
    249252        double startAngle = realA1;
    250253        // Transform the angles to get a consistent starting point
    251         //double a1 = 0;
    252254        double a2 = normalizeAngle(realA2 - startAngle);
    253255        double a3 = normalizeAngle(realA3 - startAngle);
     
    261263            // make the angles consistent with the direction.
    262264            a2 = (Math.PI * 2 - a2);
    263             a3 = (Math.PI * 2 - a3);
    264265        }
    265266        int numberOfNodesInArc = Math.max((int) Math.ceil((radialLength / Math.PI) * 180 / angleSeparation)+1,
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/curves/CurveAction.java

    r34454 r34840  
    1111import java.util.List;
    1212
     13import javax.swing.JOptionPane;
     14
    1315import org.openstreetmap.josm.actions.JosmAction;
    1416import org.openstreetmap.josm.command.Command;
     
    1820import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1921import org.openstreetmap.josm.data.osm.Way;
     22import org.openstreetmap.josm.gui.Notification;
    2023import org.openstreetmap.josm.spi.preferences.Config;
    2124import org.openstreetmap.josm.tools.Shortcut;
     
    6164
    6265        Collection<Command> cmds = CircleArcMaker.doCircleArc(selectedNodes, selectedWays, angleSeparation);
    63         if (cmds != null)
     66        if (cmds == null || cmds.isEmpty()) {
     67            new Notification(tr("Could not use selection to create a curve")).setIcon(JOptionPane.WARNING_MESSAGE).show();
     68
     69        } else {
    6470            UndoRedoHandler.getInstance().add(new SequenceCommand("Create a curve", cmds));
     71        }
    6572    }
    6673
Note: See TracChangeset for help on using the changeset viewer.