use of eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl in project hale by halestudio.
the class CurveGeometryTest method init.
// XXX different segments need different count of coordinates
// XXX missing Clothoid handler
@Override
public void init() {
super.init();
Coordinate[] coordinates = new Coordinate[] { new Coordinate(0.01, 3.2), new Coordinate(3.33, 3.33), new Coordinate(0.01, -3.2) };
lineStringReference = geomFactory.createLineString(coordinates);
lineStringChecker = combine(noCoordinatePairs(), referenceChecker(lineStringReference));
lineStringGridChecker = combine(referenceChecker(lineStringReference, InterpolationHelper.DEFAULT_MAX_POSITION_ERROR), gridConfig.geometryChecker());
ArcByCenterPoint cbp = new ArcByPointsImpl(new Coordinate(0.01, 3.2), new Coordinate(3.33, 3.33), new Coordinate(0.01, -3.2)).toArcByCenterPoint();
circleByPoints = new ArcByCenterPointImpl(cbp.getCenterPoint(), cbp.getRadius(), Angle.fromDegrees(0), Angle.fromDegrees(0), false);
}
use of eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl 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);
}
use of eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl 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);
}
use of eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl in project hale by halestudio.
the class GridInterpolationTest 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)));
gridInterpolationTest(new ArcStringImpl(arcs), 0.1, false);
}
use of eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl in project hale by halestudio.
the class GridInterpolationTest method testArcStringAllGrid.
@Test
public void testArcStringAllGrid() 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)));
gridInterpolationTest(new ArcStringImpl(arcs), 0.1, true);
}
Aggregations