Search in sources :

Example 1 with ArcByCenterPoint

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);
}
Also used : ArcByPointsImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl) ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint) Arc(eu.esdihumboldt.util.geometry.interpolation.model.Arc) DefaultGeometryProperty(eu.esdihumboldt.hale.common.instance.geometry.DefaultGeometryProperty) LineString(com.vividsolutions.jts.geom.LineString) Coordinate(com.vividsolutions.jts.geom.Coordinate) ArcByCenterPointImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByCenterPointImpl) GeometryNotSupportedException(eu.esdihumboldt.hale.io.gml.geometry.GeometryNotSupportedException) InterpolationAlgorithm(eu.esdihumboldt.util.geometry.interpolation.InterpolationAlgorithm)

Example 2 with ArcByCenterPoint

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;
}
Also used : ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint) Coordinate(com.vividsolutions.jts.geom.Coordinate) Arc2D(java.awt.geom.Arc2D)

Example 3 with ArcByCenterPoint

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());
}
Also used : ArcByPoints(eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints) ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint)

Example 4 with ArcByCenterPoint

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);
}
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 5 with ArcByCenterPoint

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);
}
Also used : ArcByPointsImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl) ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint) Arc(eu.esdihumboldt.util.geometry.interpolation.model.Arc) 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)

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