Ticket #13538: 13538-v2.patch
File 13538-v2.patch, 8.3 KB (added by , 6 years ago) |
---|
-
src/org/openstreetmap/josm/actions/CreateCircleAction.java
212 212 double alpha = angles[i].a + (j+1)*delta/(count[i]+1); 213 213 double x = center.east() + r*Math.cos(alpha); 214 214 double y = center.north() + r*Math.sin(alpha); 215 LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(new EastNorth(x, y)); 216 if (ll.isOutSideWorld()) { 215 if (new Node(new EastNorth(x, y)).isOutSideWorld()) { 217 216 notifyNodesNotOnCircle(); 218 217 return; 219 218 } 219 LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(new EastNorth(x, y)); 220 220 Node n = new Node(ll); 221 221 nodesToAdd.add(n); 222 222 cmds.add(new AddCommand(ds, n)); -
src/org/openstreetmap/josm/actions/MoveAction.java
151 151 } 152 152 153 153 for (Node n : affectedNodes) { 154 if (n.isLatLonKnown() && n.getCoor().isOutSideWorld()) { 155 // Revert move 156 ((MoveCommand) c).moveAgain(-distx, -disty); 154 if (n.isLatLonKnown() && n.isOutSideWorld()) { 155 // Undo move 157 156 JOptionPane.showMessageDialog( 158 157 MainApplication.getMainFrame(), 159 158 tr("Cannot move objects outside of the world."), … … 160 159 tr("Warning"), 161 160 JOptionPane.WARNING_MESSAGE 162 161 ); 162 UndoRedoHandler.getInstance().undo(1); 163 163 return; 164 164 } 165 165 } -
src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
529 529 List<Way> replacedWays = new ArrayList<>(); 530 530 531 531 if (newNode) { 532 if (n. getCoor().isOutSideWorld()) {532 if (n.isOutSideWorld()) { 533 533 JOptionPane.showMessageDialog( 534 534 MainApplication.getMainFrame(), 535 535 tr("Cannot add a node outside of the world."), -
src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyAction.java
415 415 } 416 416 } else if (state == State.IMPROVING) { 417 417 // Checking if the new coordinate is outside of the world 418 if (mv.getLatLon(mousePos.x, mousePos.y).isOutSideWorld()) { 418 Node test = new Node(mv.getEastNorth(mousePos.x, mousePos.y)); 419 if (test.isOutSideWorld()) { 419 420 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 420 421 tr("Cannot add a node outside of the world."), 421 422 tr("Warning"), JOptionPane.WARNING_MESSAGE); -
src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
31 31 import org.openstreetmap.josm.command.SequenceCommand; 32 32 import org.openstreetmap.josm.data.UndoRedoHandler; 33 33 import org.openstreetmap.josm.data.coor.EastNorth; 34 import org.openstreetmap.josm.data.coor.LatLon;35 34 import org.openstreetmap.josm.data.osm.DataSet; 36 35 import org.openstreetmap.josm.data.osm.Node; 37 36 import org.openstreetmap.josm.data.osm.OsmData; … … 722 721 UndoRedoHandler.getInstance().add(c); 723 722 } 724 723 for (Node n : affectedNodes) { 725 LatLon ll = n.getCoor(); 726 if (ll != null && ll.isOutSideWorld()) { 727 // Revert move 728 if (c instanceof MoveCommand) { 729 ((MoveCommand) c).resetToCheckpoint(); 730 } 724 if (n.isOutSideWorld()) { 731 725 // TODO: We might use a simple notification in the lower left corner. 732 726 JOptionPane.showMessageDialog( 733 727 MainApplication.getMainFrame(), … … 734 728 tr("Cannot move objects outside of the world."), 735 729 tr("Warning"), 736 730 JOptionPane.WARNING_MESSAGE); 731 // Undo move 732 if (c instanceof MoveCommand) { 733 UndoRedoHandler.getInstance().undo(1); 734 } 737 735 mv.setNewCursor(cursor, this); 738 736 return false; 739 737 } -
src/org/openstreetmap/josm/data/osm/Node.java
402 402 public List<Way> getParentWays() { 403 403 return referrers(Way.class).collect(Collectors.toList()); 404 404 } 405 406 /** 407 * Determines if this node is outside of the world. See also #13538. 408 * @return <code>true</code>, if the coordinate is outside the world, compared by using lat/lon and east/north 409 * @since xxx 410 */ 411 public boolean isOutSideWorld() { 412 LatLon ll = getCoor(); 413 if (ll != null) { 414 if (ll.isOutSideWorld()) 415 return true; 416 if (!new Node(ll).getEastNorth().equalsEpsilon(getEastNorth(), 1.0)) { 417 // we get here if a node was moved or created left from -180 or right from +180 418 return true; 419 } 420 } 421 return false; 422 } 405 423 } -
test/unit/org/openstreetmap/josm/data/osm/NodeTest.java
11 11 import org.junit.Test; 12 12 import org.openstreetmap.josm.data.Bounds; 13 13 import org.openstreetmap.josm.data.DataSource; 14 import org.openstreetmap.josm.data.coor.EastNorth; 14 15 import org.openstreetmap.josm.data.coor.LatLon; 15 16 import org.openstreetmap.josm.testutils.JOSMTestRules; 16 17 … … 26 27 */ 27 28 @Rule 28 29 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 29 public JOSMTestRules test = new JOSMTestRules() ;30 public JOSMTestRules test = new JOSMTestRules().projection(); 30 31 31 32 /** 32 33 * Non-regression test for ticket #12060. … … 103 104 public void testLoadIAE() { 104 105 new Node().load(new WayData()); 105 106 } 107 108 /** 109 * Test that {@link Node#isOutSideWorld} works as expected. 110 */ 111 @Test 112 public void testOutsideWorld() { 113 Node n = new Node(1, 1); 114 n.setCoor(LatLon.ZERO); 115 assertFalse(n.isOutSideWorld()); 116 n.setCoor(null); 117 assertFalse(n.isOutSideWorld()); 118 n.setCoor(LatLon.NORTH_POLE); 119 assertTrue(n.isOutSideWorld()); 120 n.setCoor(new LatLon(0, 180.0)); 121 assertFalse(n.isOutSideWorld()); 122 // simulate a small move east 123 n.setEastNorth(new EastNorth(n.getEastNorth().getX() + 0.1, n.getEastNorth().getY())); 124 assertTrue(n.isOutSideWorld()); 125 n.setCoor(new LatLon(0, -180.0)); 126 assertFalse(n.isOutSideWorld()); 127 // simulate a small move west 128 n.setEastNorth(new EastNorth(n.getEastNorth().getX() - 0.1, n.getEastNorth().getY())); 129 assertTrue(n.isOutSideWorld()); 130 } 131 106 132 }