Ignore:
Timestamp:
2014-01-11T21:01:59+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #9565 - "create circle" creates enormous circles of ways with three nodes

File:
1 edited

Legend:

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

    r6380 r6672  
    2121import org.openstreetmap.josm.command.SequenceCommand;
    2222import org.openstreetmap.josm.data.coor.EastNorth;
     23import org.openstreetmap.josm.data.coor.LatLon;
    2324import org.openstreetmap.josm.data.osm.Node;
    2425import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    203204
    204205            if (sUnder == 0) {
    205                 new Notification(
    206                         tr("Those nodes are not in a circle. Aborting."))
    207                         .setIcon(JOptionPane.WARNING_MESSAGE)
    208                         .show();
     206                notifyNodesNotOnCircle();
    209207                return;
    210208            }
     
    246244                double x = xc + r*Math.cos(a);
    247245                double y = yc + r*Math.sin(a);
    248                 Node n = new Node(Main.getProjection().eastNorth2latlon(new EastNorth(x,y)));
     246                LatLon ll = Main.getProjection().eastNorth2latlon(new EastNorth(x,y));
     247                if (ll.isOutSideWorld()) {
     248                    notifyNodesNotOnCircle();
     249                    return;
     250                }
     251                Node n = new Node(ll);
    249252                wayToAdd.add(n);
    250253                cmds.add(new AddCommand(n));
     
    273276        Main.map.repaint();
    274277    }
     278   
     279    private static void notifyNodesNotOnCircle() {
     280        new Notification(
     281                tr("Those nodes are not in a circle. Aborting."))
     282                .setIcon(JOptionPane.WARNING_MESSAGE)
     283                .show();
     284    }
    275285
    276286    @Override
Note: See TracChangeset for help on using the changeset viewer.