Changeset 13670 in josm for trunk/test/unit


Ignore:
Timestamp:
2018-04-23T23:13:03+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #16189 - Add "almost square check" for buildings (patch by marxin, modified)

File:
1 edited

Legend:

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

    r12656 r13670  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.tools;
     3
     4import static org.junit.Assert.assertEquals;
    35
    46import java.io.FileInputStream;
     
    1012import org.openstreetmap.josm.TestUtils;
    1113import org.openstreetmap.josm.data.coor.EastNorth;
     14import org.openstreetmap.josm.data.coor.LatLon;
    1215import org.openstreetmap.josm.data.osm.DataSet;
     16import org.openstreetmap.josm.data.osm.Node;
    1317import org.openstreetmap.josm.data.osm.Relation;
    1418import org.openstreetmap.josm.data.osm.Way;
     
    109113        }
    110114    }
     115
     116    /**
     117     * Test of {@link Geometry#getNormalizedAngleInDegrees(double)} method.
     118     */
     119    @Test
     120    public void testRightAngle() {
     121        Node n1 = new Node(1);
     122        Node n2 = new Node(2);
     123        Node n3 = new Node(3);
     124        n1.setCoor(new LatLon(10.22873540462851, 6.169719398316592));
     125        n2.setCoor(new LatLon(10.229332494162811, 6.16978130985785));
     126        n3.setCoor(new LatLon(10.22924937004949, 6.17060908367496));
     127
     128        double angle = Geometry.getNormalizedAngleInDegrees(Geometry.getCornerAngle(n1.getEastNorth(),
     129                n2.getEastNorth(), n3.getEastNorth()));
     130        assertEquals(90, angle, 1e-8);
     131        angle = Geometry.getNormalizedAngleInDegrees(Geometry.getCornerAngle(n1.getEastNorth(),
     132                n2.getEastNorth(), n1.getEastNorth()));
     133        assertEquals(0, angle, 1e-8);
     134
     135        n1.setCoor(new LatLon(10.2295011, 6.1693106));
     136        n2.setCoor(new LatLon(10.2294958, 6.16930635));
     137        n3.setCoor(new LatLon(10.2294895, 6.1693039));
     138
     139        angle = Geometry.getNormalizedAngleInDegrees(Geometry.getCornerAngle(n1.getEastNorth(),
     140                n2.getEastNorth(), n3.getEastNorth()));
     141        assertEquals(162.66381817961337, angle, 1e-5);
     142
     143        angle = Geometry.getNormalizedAngleInDegrees(Geometry.getCornerAngle(n3.getEastNorth(),
     144                n2.getEastNorth(), n1.getEastNorth()));
     145        assertEquals(162.66381817961337, angle, 1e-5);
     146    }
    111147}
Note: See TracChangeset for help on using the changeset viewer.