Ticket #17616: projectionTests.2.patch

File projectionTests.2.patch, 5.3 KB (added by taylor.smock, 6 years ago)

Correct GpxDistanceTest error

  • test/unit/org/openstreetmap/josm/data/gpx/GpxDistanceTest.java

     
    105105        distance = GpxDistance.getDistanceEastNorth(en, waypoint);
    106106        /* 111319.49077 uses the WGS84/NAD38/GRS80 model for
    107107         * the distance between (0, 0) and (0, 1) */
    108         assertEquals(111319.49077, distance, 0.1);
     108        assertEquals(1, distance, 0.1);
    109109    }
    110110
    111111
  • test/unit/org/openstreetmap/josm/tools/GeometryTest.java

     
    2626import org.openstreetmap.josm.data.osm.RelationMember;
    2727import org.openstreetmap.josm.data.osm.Way;
    2828import org.openstreetmap.josm.data.osm.search.SearchCompiler;
     29import org.openstreetmap.josm.data.projection.Projection;
     30import org.openstreetmap.josm.data.projection.ProjectionRegistry;
     31import org.openstreetmap.josm.data.projection.Projections;
    2932import org.openstreetmap.josm.io.OsmReader;
    3033import org.openstreetmap.josm.testutils.JOSMTestRules;
    3134
     
    265268
    266269    /**
    267270     * Test of {@link Geometry#getDistance} method.
     271     * TODO Replace with @ParameterizedTest and @ValueSource when we switch to
     272     * JUnit 5
    268273     */
    269274    @Test
    270     public void testGetDistance() {
     275    public void testGetDistanceProjection() {
     276        testGetDistance(ProjectionRegistry.getProjection());
     277        testGetDistance(Projections.getProjectionByCode("EPSG:3857"));
     278        testGetDistance(Projections.getProjectionByCode("EPSG:4326"));
     279        testGetClosestPrimitive(Projections.getProjectionByCode("EPSG:3395"));
     280    }
     281
     282    private void testGetDistance(Projection projection) throws AssertionError {
     283        ProjectionRegistry.setProjection(projection);
    271284        Node node1 = new Node(new LatLon(0, 0));
    272285        Node node2 = new Node(new LatLon(0.1, 1));
    273286        Node node3 = new Node(new LatLon(1.1, 0.1));
     
    316329
    317330    /**
    318331     * Test of {@link Geometry#getClosestPrimitive} method
     332     * TODO Replace with @ParameterizedTest and @ValueSource when we switch to
     333     * JUnit 5
    319334     */
    320335    @Test
    321     public void testGetClosestPrimitive() {
     336    public void testGetClosestPrimitiveProjections() {
     337        testGetClosestPrimitive(ProjectionRegistry.getProjection());
     338        testGetClosestPrimitive(Projections.getProjectionByCode("EPSG:3857"));
     339        testGetClosestPrimitive(Projections.getProjectionByCode("EPSG:4326"));
     340        testGetClosestPrimitive(Projections.getProjectionByCode("EPSG:3395"));
     341    }
     342
     343    private void testGetClosestPrimitive(Projection projection) throws AssertionError {
     344        ProjectionRegistry.setProjection(projection);
    322345        Node node1 = new Node(new LatLon(0, 0));
    323346        Node node2 = new Node(new LatLon(0.1, 1));
    324347        Node node3 = new Node(new LatLon(1.1, 0.1));
     
    335358
    336359    /**
    337360     * Test of {@link Geometry#getFurthestPrimitive} method
     361     * TODO Replace with @ParameterizedTest and @ValueSource when we switch to
     362     * JUnit 5
    338363     */
    339364    @Test
    340     public void testGetFurthestPrimitive() {
     365    public void testGetFurthestPrimitiveProjections() {
     366        testGetFurthestPrimitive(ProjectionRegistry.getProjection());
     367        testGetFurthestPrimitive(Projections.getProjectionByCode("EPSG:3857"));
     368        testGetFurthestPrimitive(Projections.getProjectionByCode("EPSG:4326"));
     369        testGetFurthestPrimitive(Projections.getProjectionByCode("EPSG:3395"));
     370    }
     371
     372    private void testGetFurthestPrimitive(Projection projection) throws AssertionError {
     373        ProjectionRegistry.setProjection(projection);
    341374        Node node1 = new Node(new LatLon(0, 0));
    342375        Node node2 = new Node(new LatLon(0, 1.1));
    343376        Node node3 = new Node(new LatLon(1, 0.1));
     
    350383        List<OsmPrimitive> primitives = new ArrayList<>();
    351384        primitives.add(way1);
    352385        OsmPrimitive furthest = Geometry.getFurthestPrimitive(new Node(new LatLon(0, 0.75)), primitives);
     386
    353387        assertEquals(way1, furthest);
    354388        primitives.add(way2);
    355389        primitives.add(way3);
     
    378412
    379413    /**
    380414     * Test of {@link Geometry#getDistanceSegmentSegment} method
     415     * TODO Replace with @ParameterizedTest and @ValueSource when we switch to
     416     * JUnit 5
    381417     */
    382418    @Test
    383     public void testGetDistanceSegmentSegment() {
     419    public void testGetDistanceSegmentSegmentProjections() {
     420        testGetDistanceSegmentSegment(ProjectionRegistry.getProjection());
     421        testGetDistanceSegmentSegment(Projections.getProjectionByCode("EPSG:3857"));
     422        testGetDistanceSegmentSegment(Projections.getProjectionByCode("EPSG:4326"));
     423        testGetDistanceSegmentSegment(Projections.getProjectionByCode("EPSG:3395"));
     424    }
     425
     426    private void testGetDistanceSegmentSegment(Projection projection) throws AssertionError {
     427        ProjectionRegistry.setProjection(projection);
    384428        Node node1 = new Node(new LatLon(2.0, 2.0));
    385429        Node node2 = new Node(new LatLon(2.0, 3.0));
    386430        Node node3 = new Node(new LatLon(2.3, 2.5));