Ticket #17616: projectionTests.2.patch
File projectionTests.2.patch, 5.3 KB (added by , 6 years ago) |
---|
-
test/unit/org/openstreetmap/josm/data/gpx/GpxDistanceTest.java
105 105 distance = GpxDistance.getDistanceEastNorth(en, waypoint); 106 106 /* 111319.49077 uses the WGS84/NAD38/GRS80 model for 107 107 * the distance between (0, 0) and (0, 1) */ 108 assertEquals(1 11319.49077, distance, 0.1);108 assertEquals(1, distance, 0.1); 109 109 } 110 110 111 111 -
test/unit/org/openstreetmap/josm/tools/GeometryTest.java
26 26 import org.openstreetmap.josm.data.osm.RelationMember; 27 27 import org.openstreetmap.josm.data.osm.Way; 28 28 import org.openstreetmap.josm.data.osm.search.SearchCompiler; 29 import org.openstreetmap.josm.data.projection.Projection; 30 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 31 import org.openstreetmap.josm.data.projection.Projections; 29 32 import org.openstreetmap.josm.io.OsmReader; 30 33 import org.openstreetmap.josm.testutils.JOSMTestRules; 31 34 … … 265 268 266 269 /** 267 270 * Test of {@link Geometry#getDistance} method. 271 * TODO Replace with @ParameterizedTest and @ValueSource when we switch to 272 * JUnit 5 268 273 */ 269 274 @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); 271 284 Node node1 = new Node(new LatLon(0, 0)); 272 285 Node node2 = new Node(new LatLon(0.1, 1)); 273 286 Node node3 = new Node(new LatLon(1.1, 0.1)); … … 316 329 317 330 /** 318 331 * Test of {@link Geometry#getClosestPrimitive} method 332 * TODO Replace with @ParameterizedTest and @ValueSource when we switch to 333 * JUnit 5 319 334 */ 320 335 @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); 322 345 Node node1 = new Node(new LatLon(0, 0)); 323 346 Node node2 = new Node(new LatLon(0.1, 1)); 324 347 Node node3 = new Node(new LatLon(1.1, 0.1)); … … 335 358 336 359 /** 337 360 * Test of {@link Geometry#getFurthestPrimitive} method 361 * TODO Replace with @ParameterizedTest and @ValueSource when we switch to 362 * JUnit 5 338 363 */ 339 364 @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); 341 374 Node node1 = new Node(new LatLon(0, 0)); 342 375 Node node2 = new Node(new LatLon(0, 1.1)); 343 376 Node node3 = new Node(new LatLon(1, 0.1)); … … 350 383 List<OsmPrimitive> primitives = new ArrayList<>(); 351 384 primitives.add(way1); 352 385 OsmPrimitive furthest = Geometry.getFurthestPrimitive(new Node(new LatLon(0, 0.75)), primitives); 386 353 387 assertEquals(way1, furthest); 354 388 primitives.add(way2); 355 389 primitives.add(way3); … … 378 412 379 413 /** 380 414 * Test of {@link Geometry#getDistanceSegmentSegment} method 415 * TODO Replace with @ParameterizedTest and @ValueSource when we switch to 416 * JUnit 5 381 417 */ 382 418 @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); 384 428 Node node1 = new Node(new LatLon(2.0, 2.0)); 385 429 Node node2 = new Node(new LatLon(2.0, 3.0)); 386 430 Node node3 = new Node(new LatLon(2.3, 2.5));