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());
}
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());
}
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());
}
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());
}
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;
}
Aggregations