Search in sources :

Example 26 with ArcByCenterPoint

use of eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint 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 27 with ArcByCenterPoint

use of eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint 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 28 with ArcByCenterPoint

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

the class SplitInterpolationTest method testOffsetCircle.

@Test
public void testOffsetCircle() throws IOException {
    ArcByCenterPoint arc = new ArcByCenterPointImpl(new Coordinate(2, 2), 5.0, Angle.fromDegrees(0), Angle.fromDegrees(0), true);
    splitInterpolationTest(arc, 0.1);
}
Also used : ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint) Coordinate(com.vividsolutions.jts.geom.Coordinate) ArcByCenterPointImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByCenterPointImpl) AbstractArcTest(eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest) Test(org.junit.Test)

Example 29 with ArcByCenterPoint

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

the class SplitInterpolationTest method testOffsetBig.

@Test
public void testOffsetBig() throws IOException {
    ArcByCenterPoint arc = new ArcByCenterPointImpl(new Coordinate(2, 2), 15.0, Angle.fromDegrees(45), Angle.fromDegrees(135), true);
    splitInterpolationTest(arc, 0.1);
}
Also used : ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint) Coordinate(com.vividsolutions.jts.geom.Coordinate) ArcByCenterPointImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByCenterPointImpl) AbstractArcTest(eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest) Test(org.junit.Test)

Example 30 with ArcByCenterPoint

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

the class InterpolationUtil method isStraightLine.

/**
 * Determines if the Arc is very close to a straight line.
 *
 * @param arc the arc to check
 * @return if the arc closely represents a straight line
 */
public static boolean isStraightLine(Arc arc) {
    if (arc.isCircle()) {
        return false;
    }
    if (arc instanceof ArcByCenterPoint && Double.isInfinite(((ArcByCenterPoint) arc).getRadius())) {
        // treat as straight line if the radius is infinite
        return true;
    }
    ArcByPoints a = arc.toArcByPoints();
    double yDelta_a = a.getMiddlePoint().y - a.getStartPoint().y;
    double xDelta_a = a.getMiddlePoint().x - a.getStartPoint().x;
    double yDelta_b = a.getEndPoint().y - a.getMiddlePoint().y;
    double xDelta_b = a.getEndPoint().x - a.getMiddlePoint().x;
    double aSlope = yDelta_a / xDelta_a;
    double bSlope = yDelta_b / xDelta_b;
    if (round(aSlope, SLOPE_SCALE) == round(bSlope, SLOPE_SCALE)) {
        return true;
    }
    return false;
}
Also used : ArcByPoints(eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints) ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint)

Aggregations

ArcByCenterPoint (eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint)34 Coordinate (com.vividsolutions.jts.geom.Coordinate)28 AbstractArcTest (eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest)25 Test (org.junit.Test)25 ArcByCenterPointImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByCenterPointImpl)18 ArcByPoints (eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints)15 Arc (eu.esdihumboldt.util.geometry.interpolation.model.Arc)6 Angle (eu.esdihumboldt.util.geometry.interpolation.model.Angle)4 ArcByPointsImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl)3 LineString (com.vividsolutions.jts.geom.LineString)1 DefaultGeometryProperty (eu.esdihumboldt.hale.common.instance.geometry.DefaultGeometryProperty)1 GeometryNotSupportedException (eu.esdihumboldt.hale.io.gml.geometry.GeometryNotSupportedException)1 InterpolationAlgorithm (eu.esdihumboldt.util.geometry.interpolation.InterpolationAlgorithm)1 Arc2D (java.awt.geom.Arc2D)1