Changeset 14960 in josm
- Timestamp:
- 2019-04-04T11:34:48+02:00 (6 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java
r14659 r14960 214 214 double y = center.north() + r*Math.sin(alpha); 215 215 LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(new EastNorth(x, y)); 216 if ( ll.isOutSideWorld()) {216 if (new Node(new EastNorth(x, y)).isOutSideWorld()) { 217 217 notifyNodesNotOnCircle(); 218 218 return; -
trunk/src/org/openstreetmap/josm/actions/MoveAction.java
r14397 r14960 152 152 153 153 for (Node n : affectedNodes) { 154 if (n.isLatLonKnown() && n. getCoor().isOutSideWorld()) {154 if (n.isLatLonKnown() && n.isOutSideWorld()) { 155 155 // Revert move 156 156 ((MoveCommand) c).moveAgain(-distx, -disty); -
trunk/src/org/openstreetmap/josm/actions/MoveNodeAction.java
r14397 r14960 52 52 // move the node 53 53 UndoRedoHandler.getInstance().add(new MoveCommand(n, coordinates)); 54 if (n.getCoor().distance(coordinates) > 1) { 55 // see #13538: Avoid rounding error near 180 longitude which moves nodes too far 56 if (coordinates.lon() >= 180.0) { 57 coordinates = new LatLon(coordinates.lat(), Math.nextDown(180.0)); 58 } else if (coordinates.lon() <= -180.0) { 59 coordinates = new LatLon(coordinates.lat(), Math.nextUp(-180.0)); 60 } 61 UndoRedoHandler.getInstance().undo(1); 62 UndoRedoHandler.getInstance().add(new MoveCommand(n, coordinates)); 63 } 54 64 MainApplication.getMap().mapView.repaint(); 55 65 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r14654 r14960 530 530 531 531 if (newNode) { 532 if (n. getCoor().isOutSideWorld()) {532 if (n.isOutSideWorld()) { 533 533 JOptionPane.showMessageDialog( 534 534 MainApplication.getMainFrame(), -
trunk/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyAction.java
r14670 r14960 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 if (new Node(mv.getEastNorth(mousePos.x, mousePos.y)).isOutSideWorld()) { 419 419 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 420 420 tr("Cannot add a node outside of the world."), -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r14654 r14960 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; … … 723 722 } 724 723 for (Node n : affectedNodes) { 725 LatLon ll = n.getCoor(); 726 if (ll != null && ll.isOutSideWorld()) { 724 if (n.isOutSideWorld()) { 727 725 // Revert move 728 726 if (c instanceof MoveCommand) { -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r14654 r14960 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 14960 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 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/NodeTest.java
r11630 r14960 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; … … 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 /** … … 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 }
Note:
See TracChangeset
for help on using the changeset viewer.