Search in sources :

Example 11 with ArcByPoints

use of eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints in project hale by halestudio.

the class ArcByPointsImplTest method testCircle.

@Test
public void testCircle() throws IOException {
    ArcByPoints arc = new ArcByPointsImpl(new Coordinate(-1, 0), new Coordinate(1, 0), new Coordinate(-1, 0));
    drawArcWithMarkers(arc);
    assertTrue(arc.isCircle());
    assertFalse(InterpolationUtil.isStraightLine(arc));
    ArcByCenterPoint converted = arc.toArcByCenterPoint();
    assertEqualsCoord(new Coordinate(0, 0), converted.getCenterPoint());
    assertEquals(1.0, converted.getRadius(), 1e-10);
    assertEquals(Angle.fromDegrees(180), converted.getStartAngle());
    assertEquals(Angle.fromDegrees(180), converted.getEndAngle());
    assertEquals(Angle.fromDegrees(-360), converted.getAngleBetween());
    assertTrue(converted.isClockwise());
}
Also used : ArcByPoints(eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints) ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint) Coordinate(com.vividsolutions.jts.geom.Coordinate) AbstractArcTest(eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest) Test(org.junit.Test)

Example 12 with ArcByPoints

use of eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints in project hale by halestudio.

the class ArcByPointsImplTest method testOrigin.

@Test
public void testOrigin() throws IOException {
    ArcByPoints arc = new ArcByPointsImpl(new Coordinate(-1, 0), new Coordinate(0, 1), new Coordinate(1, 0));
    drawArcWithMarkers(arc);
    assertFalse(arc.isCircle());
    assertFalse(InterpolationUtil.isStraightLine(arc));
    ArcByCenterPoint converted = arc.toArcByCenterPoint();
    assertEqualsCoord(new Coordinate(0, 0), converted.getCenterPoint());
    assertEquals(1.0, converted.getRadius(), 1e-10);
    assertEquals(Angle.fromDegrees(180), converted.getStartAngle());
    assertEquals(Angle.fromDegrees(0), converted.getEndAngle());
    assertEquals(Angle.fromDegrees(-180), converted.getAngleBetween());
    assertTrue(converted.isClockwise());
}
Also used : ArcByPoints(eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints) ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint) Coordinate(com.vividsolutions.jts.geom.Coordinate) AbstractArcTest(eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest) Test(org.junit.Test)

Example 13 with ArcByPoints

use of eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints in project hale by halestudio.

the class ArcByPointsImplTest method testCCW.

@Test
public void testCCW() throws IOException {
    ArcByPoints arc = new ArcByPointsImpl(new Coordinate(1, 0), new Coordinate(0, 1), new Coordinate(-1, 0));
    drawArcWithMarkers(arc);
    assertFalse(arc.isCircle());
    assertFalse(InterpolationUtil.isStraightLine(arc));
    ArcByCenterPoint converted = arc.toArcByCenterPoint();
    assertEqualsCoord(new Coordinate(0, 0), converted.getCenterPoint());
    assertEquals(1.0, converted.getRadius(), 1e-10);
    assertEquals(Angle.fromDegrees(0), converted.getStartAngle());
    assertEquals(Angle.fromDegrees(180), converted.getEndAngle());
    assertEquals(Angle.fromDegrees(180), converted.getAngleBetween());
    assertFalse(converted.isClockwise());
}
Also used : ArcByPoints(eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints) ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint) Coordinate(com.vividsolutions.jts.geom.Coordinate) AbstractArcTest(eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest) Test(org.junit.Test)

Example 14 with ArcByPoints

use of eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints in project hale by halestudio.

the class ArcByPointsImplTest method testStraight.

@Test
public void testStraight() throws IOException {
    ArcByPoints arc = new ArcByPointsImpl(new Coordinate(-10, 1), new Coordinate(0, 1.0001), new Coordinate(10, 1));
    drawArcWithMarkers(arc);
    assertFalse(arc.isCircle());
    assertTrue(InterpolationUtil.isStraightLine(arc));
    ArcByCenterPoint converted = arc.toArcByCenterPoint();
    assertTrue(converted.isClockwise());
}
Also used : ArcByPoints(eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints) ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint) Coordinate(com.vividsolutions.jts.geom.Coordinate) AbstractArcTest(eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest) Test(org.junit.Test)

Example 15 with ArcByPoints

use of eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints in project hale by halestudio.

the class SplitInterpolationTest method splitInterpolationTest.

private LineString splitInterpolationTest(Arc arc, double maxPositionalError) throws IOException {
    SplitInterpolation interpol = new SplitInterpolation();
    Map<String, String> properties = new HashMap<>();
    interpol.configure(new GeometryFactory(), maxPositionalError, properties);
    LineString result = interpol.interpolateArc(arc);
    drawInterpolatedArc(arc, result);
    // test interpolated geometry
    Coordinate[] coords = result.getCoordinates();
    if (coords.length > 1 && arc instanceof ArcByPoints) {
        // test start and end point
        assertEquals(arc.toArcByPoints().getStartPoint(), coords[0]);
        assertEquals(arc.toArcByPoints().getEndPoint(), coords[coords.length - 1]);
    }
    for (int i = 0; i < coords.length; i++) {
        Coordinate c = coords[i];
        // check if two coordinates are not the same
        if (i < coords.length - 1) {
            Coordinate c2 = coords[i + 1];
            assertNotEquals("Subsequent coordinates are equal", c, c2);
        }
        // check distance from center
        double distance = arc.toArcByCenterPoint().getCenterPoint().distance(c);
        double delta = Math.abs(distance - arc.toArcByCenterPoint().getRadius());
        assertTrue(delta <= maxPositionalError);
    }
    return result;
}
Also used : ArcByPoints(eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) HashMap(java.util.HashMap) LineString(com.vividsolutions.jts.geom.LineString) Coordinate(com.vividsolutions.jts.geom.Coordinate) LineString(com.vividsolutions.jts.geom.LineString) ArcString(eu.esdihumboldt.util.geometry.interpolation.model.ArcString) ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint)

Aggregations

ArcByCenterPoint (eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint)16 ArcByPoints (eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints)16 Coordinate (com.vividsolutions.jts.geom.Coordinate)14 AbstractArcTest (eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest)13 Test (org.junit.Test)13 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)1 LineString (com.vividsolutions.jts.geom.LineString)1 ArcString (eu.esdihumboldt.util.geometry.interpolation.model.ArcString)1 HashMap (java.util.HashMap)1