Changeset 9924 in josm for trunk/test/unit
- Timestamp:
- 2016-03-04T21:52:59+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/OrthogonalizeActionTest.java
r9923 r9924 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.actions; 3 4 import static junit.framework.Assert.assertEquals; 3 5 4 6 import java.io.FileInputStream; … … 9 11 import org.openstreetmap.josm.TestUtils; 10 12 import org.openstreetmap.josm.actions.search.SearchCompiler; 13 import org.openstreetmap.josm.data.coor.LatLon; 11 14 import org.openstreetmap.josm.data.osm.DataSet; 15 import org.openstreetmap.josm.data.osm.Way; 12 16 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 13 17 import org.openstreetmap.josm.io.OsmReader; 18 import org.openstreetmap.josm.tools.Geometry; 14 19 import org.openstreetmap.josm.tools.Utils; 15 20 … … 34 39 @Test 35 40 public void testClosedWay() throws Exception { 36 performTest("name=ClosedWay"); 41 final DataSet ds = performTest("name=ClosedWay"); 42 final Way way = ds.getSelectedWays().iterator().next(); 43 assertEquals(new LatLon(8.538808176881814, 55.72978898396922), way.getNode(0).getCoor()); 44 assertEquals(new LatLon(8.539618224318104, 55.73039799489563), way.getNode(1).getCoor()); 45 assertEquals(new LatLon(8.538993302766201, 55.73124794515577), way.getNode(2).getCoor()); 46 assertEquals(new LatLon(8.538183254003354, 55.730638934229376), way.getNode(3).getCoor()); 47 verifyRectangleClockwise(way); 37 48 } 38 49 … … 49 60 @Test 50 61 public void testClosedWayWithReferenceNodes() throws Exception { 51 performTest("name=ClosedWayWithReferenceNodes"); 62 final DataSet ds = performTest("name=ClosedWayWithReferenceNodes"); 63 final Way way = ds.getSelectedWays().iterator().next(); 64 assertEquals(new LatLon(8.534711427, 55.73000670312), way.getNode(0).getCoor()); 65 assertEquals(new LatLon(8.53547720918594, 55.73067141759374), way.getNode(1).getCoor()); 66 assertEquals(new LatLon(8.534835495633061, 55.73142735279376), way.getNode(2).getCoor()); 67 assertEquals(new LatLon(8.53406971216, 55.73076263832), way.getNode(3).getCoor()); 68 verifyRectangleClockwise(way); 52 69 } 53 70 54 voidperformTest(String search) throws Exception {71 DataSet performTest(String search) throws Exception { 55 72 try (FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "orthogonalize.osm")) { 56 73 final DataSet ds = OsmReader.parseDataSet(in, null); 57 74 ds.setSelected(Utils.filter(ds.allPrimitives(), SearchCompiler.compile(search))); 58 OrthogonalizeAction.orthogonalize(ds.getSelected()); 75 OrthogonalizeAction.orthogonalize(ds.getSelected()).executeCommand(); 76 return ds; 77 } 78 } 79 80 void verifyRectangleClockwise(final Way way) { 81 for (int i = 1; i < way.getNodesCount() - 1; i++) { 82 assertEquals(-Math.PI / 2, Geometry.getCornerAngle( 83 way.getNode(i - 1).getEastNorth(), way.getNode(i).getEastNorth(), way.getNode(i + 1).getEastNorth()), 1e-6); 59 84 } 60 85 }
Note:
See TracChangeset
for help on using the changeset viewer.