use of eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint in project hale by halestudio.
the class CircleHandler method createGeometry.
@Override
public Object createGeometry(Instance instance, int srsDimension, IOProvider reader) throws GeometryNotSupportedException {
@SuppressWarnings("unchecked") DefaultGeometryProperty<LineString> lineStringGeomProperty = (DefaultGeometryProperty<LineString>) super.createGeometry(instance, srsDimension, reader);
// create Arc for circle
Coordinate[] coords = lineStringGeomProperty.getGeometry().getCoordinates();
if (coords.length != 3) {
throw new GeometryNotSupportedException("Arc must be defined by three points");
}
Arc arc = new ArcByPointsImpl(coords[0], coords[1], coords[2]);
ArcByCenterPoint byCenter = arc.toArcByCenterPoint();
ArcByCenterPoint circle = new ArcByCenterPointImpl(byCenter.getCenterPoint(), byCenter.getRadius(), byCenter.getStartAngle(), byCenter.getStartAngle(), byCenter.isClockwise());
// get interpolation algorithm
InterpolationAlgorithm interpol = InterpolationHelper.getInterpolation(reader, getGeometryFactory());
LineString interpolatedCircle = interpol.interpolateArc(circle);
if (interpolatedCircle == null) {
log.error("Circle could be not interpolated to Linestring");
return null;
}
return new DefaultGeometryProperty<LineString>(lineStringGeomProperty.getCRSDefinition(), interpolatedCircle);
}
use of eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint in project hale by halestudio.
the class AbstractArcTest method createArcShape.
/**
* Create an Arc AWT shape from a given arc.
*
* @param arc the arc
* @param paintSettings the paint settings for coordinate conversion
* @return the arc shape
*/
protected Arc2D createArcShape(Arc arc, PaintSettings paintSettings) {
ArcByCenterPoint a = arc.toArcByCenterPoint();
// FIXME probably not the right position
Coordinate center = paintSettings.convertPoint(a.getCenterPoint());
double radius = a.getRadius() * paintSettings.getScaleFactor();
double startAngle = a.getStartAngle().getDegrees();
double angleExtent = a.getAngleBetween().getDegrees();
Arc2D.Double arcShape = new Arc2D.Double();
arcShape.setArcByCenter(center.x, center.y, radius, startAngle, angleExtent, Arc2D.OPEN);
return arcShape;
}
use of eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint 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());
}
use of eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint in project hale by halestudio.
the class GridInterpolationTest method testHalfCircle.
@Test
public void testHalfCircle() throws IOException {
ArcByCenterPoint arc = new ArcByCenterPointImpl(new Coordinate(0, 0), 1.0, Angle.fromDegrees(0), Angle.fromDegrees(180), true);
gridInterpolationTest(arc, 0.1, false);
}
use of eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint in project hale by halestudio.
the class GridInterpolationTest method testByPointsToCenterAllGrid.
@Test
public void testByPointsToCenterAllGrid() throws IOException {
ArcByCenterPoint cbp = new ArcByPointsImpl(new Coordinate(0.01, 3.2), new Coordinate(3.33, 3.33), new Coordinate(0.01, -3.2)).toArcByCenterPoint();
Arc arc = new ArcByCenterPointImpl(cbp.getCenterPoint(), cbp.getRadius(), Angle.fromDegrees(0), Angle.fromDegrees(0), false);
gridInterpolationTest(arc, 0.1, true);
}
Aggregations