Changeset 9925 in josm for trunk/test/unit


Ignore:
Timestamp:
2016-03-05T10:22:33+01:00 (5 years ago)
Author:
simon04
Message:

see #6401 - Orthogonalize objects based on selected nodes

This is done by assembling a virtual way from the selected nodes. This is sensitive to the selection order.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/OrthogonalizeActionTest.java

    r9924 r9925  
    55
    66import java.io.FileInputStream;
     7import java.util.ArrayList;
     8import java.util.List;
    79
    810import org.junit.BeforeClass;
     
    1315import org.openstreetmap.josm.data.coor.LatLon;
    1416import org.openstreetmap.josm.data.osm.DataSet;
     17import org.openstreetmap.josm.data.osm.Node;
    1518import org.openstreetmap.josm.data.osm.Way;
    1619import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    6972    }
    7073
    71     DataSet performTest(String search) throws Exception {
     74    @Test
     75    public void testFourNodes() throws Exception {
     76        final DataSet ds = performTest(
     77                "name=NodeToRectify-01", "name=NodeToRectify-02", "name=NodeToRectify-03", "name=NodeToRectify-04");
     78        final List<Node> nodes = new ArrayList<>(ds.getSelectedNodes());
     79        assertEquals(new LatLon(8.532735415272217, 55.72986948949525), nodes.get(0).getCoor());
     80        assertEquals(new LatLon(8.533520827858515, 55.73043325105434), nodes.get(1).getCoor());
     81        assertEquals(new LatLon(8.532914283300173, 55.73129729115582), nodes.get(2).getCoor());
     82        assertEquals(new LatLon(8.532055019939826, 55.73068052126457), nodes.get(3).getCoor());
     83    }
     84
     85    DataSet performTest(String... search) throws Exception {
    7286        try (FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "orthogonalize.osm")) {
    7387            final DataSet ds = OsmReader.parseDataSet(in, null);
    74             ds.setSelected(Utils.filter(ds.allPrimitives(), SearchCompiler.compile(search)));
     88            for (String s : search) {
     89                ds.addSelected(Utils.filter(ds.allPrimitives(), SearchCompiler.compile(s)));
     90            }
    7591            OrthogonalizeAction.orthogonalize(ds.getSelected()).executeCommand();
    7692            return ds;
Note: See TracChangeset for help on using the changeset viewer.