Search in sources :

Example 11 with Arc

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

the class SplitInterpolationTest method testArcString.

@Test
public void testArcString() throws IOException {
    List<Arc> arcs = new ArrayList<>();
    arcs.add(new ArcByPointsImpl(new Coordinate(-3, 2), new Coordinate(-2, 4), new Coordinate(0, 4)));
    arcs.add(new ArcByPointsImpl(new Coordinate(0, 4), new Coordinate(2, 3), new Coordinate(4, 4)));
    arcs.add(new ArcByPointsImpl(new Coordinate(4, 4), new Coordinate(4, 6), new Coordinate(2, 6)));
    splitInterpolationTest(new ArcStringImpl(arcs), 0.1);
}
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) ArrayList(java.util.ArrayList) ArcStringImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcStringImpl) AbstractArcTest(eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest) Test(org.junit.Test)

Example 12 with Arc

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

the class SplitInterpolationTest method testByPoints1.

@Test
public void testByPoints1() throws IOException {
    Arc arc = new ArcByPointsImpl(new Coordinate(-3, 2), new Coordinate(-2, 4), new Coordinate(0, 4));
    splitInterpolationTest(arc, 0.1);
}
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 13 with Arc

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

the class SplitInterpolationTest method testByPoints2.

@Test
public void testByPoints2() throws IOException {
    Arc arc = new ArcByPointsImpl(new Coordinate(0, 4), new Coordinate(2, 3), new Coordinate(4, 4));
    splitInterpolationTest(arc, 0.1);
}
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 14 with Arc

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

the class ArcHandler method createGeometry.

@Override
public Object createGeometry(Instance instance, int srsDimension, IOProvider reader) throws GeometryNotSupportedException {
    // read arc to LineString
    @SuppressWarnings("unchecked") DefaultGeometryProperty<LineString> lineStringGeomProperty = (DefaultGeometryProperty<LineString>) super.createGeometry(instance, srsDimension, reader);
    // create Arc
    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]);
    // get interpolation algorithm
    InterpolationAlgorithm interpol = InterpolationHelper.getInterpolation(reader, getGeometryFactory());
    LineString interpolatedArc = interpol.interpolateArc(arc);
    if (interpolatedArc == null) {
        log.error("Arc could be not interpolated to Linestring");
        return null;
    }
    return new DefaultGeometryProperty<LineString>(lineStringGeomProperty.getCRSDefinition(), interpolatedArc);
}
Also used : ArcByPointsImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl) 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) GeometryNotSupportedException(eu.esdihumboldt.hale.io.gml.geometry.GeometryNotSupportedException) InterpolationAlgorithm(eu.esdihumboldt.util.geometry.interpolation.InterpolationAlgorithm)

Example 15 with Arc

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

the class ArcStringHandler 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
    Coordinate[] coords = lineStringGeomProperty.getGeometry().getCoordinates();
    if (coords.length < 3) {
        throw new GeometryNotSupportedException("Arc string must be defined by at least three points");
    }
    List<Arc> arcs = new ArrayList<>();
    for (int i = 0; i < coords.length - 2; i += 3) {
        Arc arc = new ArcByPointsImpl(coords[i], coords[i + 1], coords[i + 2]);
        arcs.add(arc);
    }
    ArcString arcString = new ArcStringImpl(arcs);
    // get interpolation algorithm
    InterpolationAlgorithm interpol = InterpolationHelper.getInterpolation(reader, getGeometryFactory());
    LineString interpolatedArcString = interpol.interpolateArcString(arcString);
    if (interpolatedArcString == null) {
        log.error("ArcString could be not interpolated to Linestring");
        return null;
    }
    return new DefaultGeometryProperty<LineString>(lineStringGeomProperty.getCRSDefinition(), interpolatedArcString);
}
Also used : GeometryNotSupportedException(eu.esdihumboldt.hale.io.gml.geometry.GeometryNotSupportedException) ArrayList(java.util.ArrayList) ArcString(eu.esdihumboldt.util.geometry.interpolation.model.ArcString) InterpolationAlgorithm(eu.esdihumboldt.util.geometry.interpolation.InterpolationAlgorithm) TypeConstraint(eu.esdihumboldt.hale.common.schema.model.TypeConstraint) ArcByPointsImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl) 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) ArcStringImpl(eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcStringImpl)

Aggregations

Arc (eu.esdihumboldt.util.geometry.interpolation.model.Arc)26 Coordinate (com.vividsolutions.jts.geom.Coordinate)20 ArcByPointsImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl)16 AbstractArcTest (eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest)13 Test (org.junit.Test)13 ArcByCenterPointImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByCenterPointImpl)8 ArrayList (java.util.ArrayList)7 LineString (com.vividsolutions.jts.geom.LineString)6 ArcByCenterPoint (eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint)6 DefaultGeometryProperty (eu.esdihumboldt.hale.common.instance.geometry.DefaultGeometryProperty)5 GeometryNotSupportedException (eu.esdihumboldt.hale.io.gml.geometry.GeometryNotSupportedException)5 InterpolationAlgorithm (eu.esdihumboldt.util.geometry.interpolation.InterpolationAlgorithm)5 Angle (eu.esdihumboldt.util.geometry.interpolation.model.Angle)4 ArcStringImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcStringImpl)4 Point (com.vividsolutions.jts.geom.Point)2 Instance (eu.esdihumboldt.hale.common.instance.model.Instance)2 CRSDefinition (eu.esdihumboldt.hale.common.schema.geometry.CRSDefinition)2 ParseException (java.text.ParseException)2 Envelope (com.vividsolutions.jts.geom.Envelope)1 TypeConstraint (eu.esdihumboldt.hale.common.schema.model.TypeConstraint)1