Search in sources :

Example 1 with ArcByPointsImpl

use of eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl 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 ArcByPointsImpl

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

the class GridInterpolationTest method testByPoints1.

@Test
public void testByPoints1() throws IOException {
    Arc arc = new ArcByPointsImpl(new Coordinate(-3, 2), new Coordinate(-2, 4), new Coordinate(0, 4));
    gridInterpolationTest(arc, 0.1, false);
}
Also used : ArcByPointsImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl) Arc(eu.esdihumboldt.util.geometry.interpolation.model.Arc) Coordinate(com.vividsolutions.jts.geom.Coordinate) AbstractArcTest(eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest) Test(org.junit.Test)

Example 3 with ArcByPointsImpl

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

the class GridInterpolationTest method testByPoints1AllGrid.

@Test
public void testByPoints1AllGrid() throws IOException {
    Arc arc = new ArcByPointsImpl(new Coordinate(-3, 2), new Coordinate(-2, 4), new Coordinate(0, 4));
    gridInterpolationTest(arc, 0.1, true);
}
Also used : ArcByPointsImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl) Arc(eu.esdihumboldt.util.geometry.interpolation.model.Arc) Coordinate(com.vividsolutions.jts.geom.Coordinate) AbstractArcTest(eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest) Test(org.junit.Test)

Example 4 with ArcByPointsImpl

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

the class GridInterpolationTest method testByPoints2.

@Test
public void testByPoints2() throws IOException {
    Arc arc = new ArcByPointsImpl(new Coordinate(0, 4), new Coordinate(2, 3), new Coordinate(4, 4));
    gridInterpolationTest(arc, 0.1, false);
}
Also used : ArcByPointsImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl) Arc(eu.esdihumboldt.util.geometry.interpolation.model.Arc) Coordinate(com.vividsolutions.jts.geom.Coordinate) AbstractArcTest(eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest) Test(org.junit.Test)

Example 5 with ArcByPointsImpl

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

the class GridInterpolationTest method testByPoints2AllGrid.

@Test
public void testByPoints2AllGrid() throws IOException {
    Arc arc = new ArcByPointsImpl(new Coordinate(0, 4), new Coordinate(2, 3), new Coordinate(4, 4));
    gridInterpolationTest(arc, 0.1, true);
}
Also used : ArcByPointsImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl) Arc(eu.esdihumboldt.util.geometry.interpolation.model.Arc) Coordinate(com.vividsolutions.jts.geom.Coordinate) AbstractArcTest(eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest) Test(org.junit.Test)

Aggregations

Coordinate (com.vividsolutions.jts.geom.Coordinate)17 ArcByPointsImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl)17 Arc (eu.esdihumboldt.util.geometry.interpolation.model.Arc)16 AbstractArcTest (eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest)13 Test (org.junit.Test)13 ArcStringImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcStringImpl)4 ArrayList (java.util.ArrayList)4 LineString (com.vividsolutions.jts.geom.LineString)3 DefaultGeometryProperty (eu.esdihumboldt.hale.common.instance.geometry.DefaultGeometryProperty)3 GeometryNotSupportedException (eu.esdihumboldt.hale.io.gml.geometry.GeometryNotSupportedException)3 InterpolationAlgorithm (eu.esdihumboldt.util.geometry.interpolation.InterpolationAlgorithm)3 ArcByCenterPoint (eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint)3 ArcByCenterPointImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByCenterPointImpl)3 TypeConstraint (eu.esdihumboldt.hale.common.schema.model.TypeConstraint)1 ArcString (eu.esdihumboldt.util.geometry.interpolation.model.ArcString)1