Changeset 9878 in josm for trunk/test/unit/org
- Timestamp:
- 2016-02-24T23:24:31+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/tools/GeometryTest.java
r8876 r9878 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.tools; 3 4 import java.io.FileInputStream; 5 import java.util.List; 3 6 4 7 import org.junit.Assert; … … 6 9 import org.junit.Test; 7 10 import org.openstreetmap.josm.JOSMFixture; 11 import org.openstreetmap.josm.TestUtils; 12 import org.openstreetmap.josm.actions.search.SearchCompiler; 8 13 import org.openstreetmap.josm.data.coor.EastNorth; 14 import org.openstreetmap.josm.data.osm.DataSet; 15 import org.openstreetmap.josm.data.osm.Way; 16 import org.openstreetmap.josm.io.OsmReader; 9 17 10 18 /** … … 52 60 Math.abs(scalarProduct/len1/len2) < 1e-10); 53 61 } 62 63 /** 64 * Test of {@link Geometry#closedWayArea(org.openstreetmap.josm.data.osm.Way)} method. 65 * 66 * @throws Exception if an error occurs 67 */ 68 @Test 69 public void testClosedWayArea() throws Exception { 70 try (FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm")) { 71 DataSet ds = OsmReader.parseDataSet(in, null); 72 Way closedWay = (Way) Utils.filter(ds.allPrimitives(), SearchCompiler.compile("landuse=forest")).iterator().next(); 73 Assert.assertEquals(5721923.660644531, Geometry.closedWayArea(closedWay), 1e-3); 74 } 75 } 76 77 /** 78 * Test of {@link Geometry#getAreaAndPerimeter(List)} method. 79 * 80 * @throws Exception if an error occurs 81 */ 82 @Test 83 public void testAreaAndPerimeter() throws Exception { 84 try (FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "create_multipolygon.osm")) { 85 DataSet ds = OsmReader.parseDataSet(in, null); 86 Way closedWay = (Way) Utils.filter(ds.allPrimitives(), SearchCompiler.compile("landuse=forest")).iterator().next(); 87 Geometry.AreaAndPerimeter areaAndPerimeter = Geometry.getAreaAndPerimeter(closedWay.getNodes()); 88 Assert.assertEquals(12495000., areaAndPerimeter.getArea(), 1e-3); 89 Assert.assertEquals(15093.201209424187, areaAndPerimeter.getPerimeter(), 1e-3); 90 } 91 } 54 92 }
Note:
See TracChangeset
for help on using the changeset viewer.