Changeset 9952 in josm for trunk/test/unit


Ignore:
Timestamp:
2016-03-07T23:29:30+01:00 (5 years ago)
Author:
simon04
Message:

see #11516 - Compute multipolygon area, include in MapCSS, JOSM search

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/tools/GeometryTest.java

    r9951 r9952  
    1313import org.openstreetmap.josm.data.coor.EastNorth;
    1414import org.openstreetmap.josm.data.osm.DataSet;
     15import org.openstreetmap.josm.data.osm.Relation;
    1516import org.openstreetmap.josm.data.osm.Way;
    1617import org.openstreetmap.josm.io.OsmReader;
     
    7273            Way closedWay = (Way) Utils.filter(ds.allPrimitives(), SearchCompiler.compile("landuse=forest")).iterator().next();
    7374            Assert.assertEquals(5760015.7353515625, Geometry.closedWayArea(closedWay), 1e-3);
     75            Assert.assertEquals(5760015.7353515625, Geometry.computeArea(closedWay), 1e-3);
     76        }
     77    }
     78
     79    /**
     80     * Test of {@link Geometry#multipolygonArea(Relation)}} method.
     81     *
     82     * @throws Exception if an error occurs
     83     */
     84    @Test
     85    public void testMultipolygonArea() throws Exception {
     86        try (FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "multipolygon.osm")) {
     87            DataSet ds = OsmReader.parseDataSet(in, null);
     88            final Relation r = ds.getRelations().iterator().next();
     89            Assert.assertEquals(4401735.20703125, Geometry.multipolygonArea(r), 1e-3);
     90            Assert.assertEquals(4401735.20703125, Geometry.computeArea(r), 1e-3);
    7491        }
    7592    }
Note: See TracChangeset for help on using the changeset viewer.