Ignore:
Timestamp:
2019-04-04T11:34:48+02:00 (6 years ago)
Author:
GerdP
Message:

see #13538:

  • Add new method isOutSideWorld() to class Node and use the method where LatLon.isOutSideWorld() was used before
  • Add a check in MoveNodeAction to make sure that rounding errors near 180 longitude don't move the node from east to west or vice versa

(I've removed the changes to reactions implemented in 13538-v2.patch, they would be too confusing.)

TODO: Plugins should use the new method in Node

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/osm/NodeTest.java

    r11630 r14960  
    1212import org.openstreetmap.josm.data.Bounds;
    1313import org.openstreetmap.josm.data.DataSource;
     14import org.openstreetmap.josm.data.coor.EastNorth;
    1415import org.openstreetmap.josm.data.coor.LatLon;
    1516import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    2728    @Rule
    2829    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    29     public JOSMTestRules test = new JOSMTestRules();
     30    public JOSMTestRules test = new JOSMTestRules().projection();
    3031
    3132    /**
     
    104105        new Node().load(new WayData());
    105106    }
     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
    106132}
Note: See TracChangeset for help on using the changeset viewer.