Search in sources :

Example 1 with ArcByPoints

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

the class AbstractArcTest method drawArcWithMarkers.

/**
 * Draw an arc with markers for the points defining the arc.
 *
 * @param painter the SVG painter
 * @param arc the arc to draw
 */
protected void drawArcWithMarkers(SVGPainter painter, Arc arc) {
    painter.setColor(Color.DARK_GRAY);
    painter.setStroke(2.0f);
    drawArc(painter, arc);
    if (arc instanceof ArcByPoints) {
        painter.setColor(Color.GREEN);
    } else {
        painter.setColor(Color.BLUE);
    }
    ArcByPoints bp = arc.toArcByPoints();
    painter.drawPoint(bp.getStartPoint());
    painter.drawPoint(bp.getEndPoint());
    painter.setColor(Color.RED);
    painter.drawPoint(bp.getMiddlePoint());
    if (arc instanceof ArcByCenterPoint) {
        painter.setColor(Color.GREEN);
    } else {
        painter.setColor(Color.BLUE);
    }
    ArcByCenterPoint bc = arc.toArcByCenterPoint();
    painter.drawPoint(bc.getCenterPoint());
}
Also used : ArcByPoints(eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints) ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint)

Example 2 with ArcByPoints

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

the class ArcByCenterPointImplTest method testCW1.

@Test
public void testCW1() throws IOException {
    ArcByCenterPoint arc = new ArcByCenterPointImpl(new Coordinate(0, 0), 1.0, Angle.fromDegrees(0), Angle.fromDegrees(180), true);
    drawArcWithMarkers(arc);
    assertEquals(-180.0, arc.getAngleBetween().getDegrees(), 1e-10);
    assertFalse(arc.isCircle());
    assertFalse(InterpolationUtil.isStraightLine(arc));
    ArcByPoints converted = arc.toArcByPoints();
    assertEqualsCoord(new Coordinate(1, 0), converted.getStartPoint());
    assertEqualsCoord(new Coordinate(0, -1), converted.getMiddlePoint());
    assertEqualsCoord(new Coordinate(-1, 0), converted.getEndPoint());
}
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 3 with ArcByPoints

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

the class ArcByCenterPointImplTest method testCircle1.

@Test
public void testCircle1() throws IOException {
    ArcByCenterPoint arc = new ArcByCenterPointImpl(new Coordinate(0, 0), 1.0, Angle.fromDegrees(0), Angle.fromDegrees(0), false);
    drawArcWithMarkers(arc);
    assertEquals(360.0, arc.getAngleBetween().getDegrees(), 1e-10);
    assertTrue(arc.isCircle());
    assertFalse(InterpolationUtil.isStraightLine(arc));
    ArcByPoints converted = arc.toArcByPoints();
    assertEqualsCoord(new Coordinate(1, 0), converted.getStartPoint());
    assertEqualsCoord(new Coordinate(-1, 0), converted.getMiddlePoint());
    assertEqualsCoord(new Coordinate(1, 0), converted.getEndPoint());
}
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 4 with ArcByPoints

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

the class ArcByCenterPointImplTest method testCircle2.

@Test
public void testCircle2() throws IOException {
    ArcByCenterPoint arc = new ArcByCenterPointImpl(new Coordinate(0, 0), 1.0, Angle.fromDegrees(0), Angle.fromDegrees(360), false);
    drawArcWithMarkers(arc);
    assertEquals(360.0, arc.getAngleBetween().getDegrees(), 1e-10);
    assertTrue(arc.isCircle());
    assertFalse(InterpolationUtil.isStraightLine(arc));
    ArcByPoints converted = arc.toArcByPoints();
    assertEqualsCoord(new Coordinate(1, 0), converted.getStartPoint());
    assertEqualsCoord(new Coordinate(-1, 0), converted.getMiddlePoint());
    assertEqualsCoord(new Coordinate(1, 0), converted.getEndPoint());
}
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 5 with ArcByPoints

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

the class ArcByCenterPointImplTest method testCW3.

@Test
public void testCW3() throws IOException {
    ArcByCenterPoint arc = new ArcByCenterPointImpl(new Coordinate(1, 1), Math.sqrt(2.0), Angle.fromDegrees(135), Angle.fromDegrees(45), true);
    drawArcWithMarkers(arc);
    assertEquals(-90.0, arc.getAngleBetween().getDegrees(), 1e-10);
    assertFalse(arc.isCircle());
    assertFalse(InterpolationUtil.isStraightLine(arc));
    ArcByPoints converted = arc.toArcByPoints();
    assertEqualsCoord(new Coordinate(0, 2), converted.getStartPoint());
    assertEqualsCoord(new Coordinate(1, 1 + Math.sqrt(2.0)), converted.getMiddlePoint());
    assertEqualsCoord(new Coordinate(2, 2), converted.getEndPoint());
}
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)

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