use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class TriangleFunctions method circumcentre.
public static Geometry circumcentre(final Geometry geometry) {
return geometry.applyGeometry((final Geometry part) -> {
final Point[] pts = trianglePts(part);
final Point cc = Triangles.circumcentre(pts[0], pts[1], pts[2]);
final GeometryFactory geomFact = FunctionsUtil.getFactoryOrDefault(part);
return geomFact.point(cc);
});
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class WKBTest method runWKBTestCoordinateArray.
private void runWKBTestCoordinateArray(final String wkt) throws IOException, ParseException {
final GeometryFactory geometryFactory = GeometryFactory.DEFAULT_3D;
final Geometry g = geometryFactory.geometry(wkt);
// CoordinateArrays support dimension 3, so test both dimensions
runWKBTest(g, 2, true);
runWKBTest(g, 2, false);
runWKBTest(g, 3, true);
runWKBTest(g, 3, false);
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class WKBTest method runWKBTestPackedCoordinate.
private void runWKBTestPackedCoordinate(final String wkt) throws IOException, ParseException {
final GeometryFactory geometryFactory = GeometryFactory.floating2d(0);
final Geometry g = geometryFactory.geometry(wkt);
// Since we are using a PCS of dim=2, only check 2-dimensional storage
runWKBTest(g, 2, true);
runWKBTest(g, 2, false);
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class LineStringTest method testMerge.
@Test
public void testMerge() {
final GeometryFactory geometryFactory = GeometryFactory.fixed3d(26910, 1.0, 1.0, 1.0);
// Last point is duplicated
final LineString line1 = geometryFactory.lineString(3, START_X, START_Y, 0, START_X + 100, START_Y + 100, 1, START_X + 200, START_Y + 200, 2, START_X + 300, START_Y + 300, 3, START_X + 300, START_Y + 300, 3);
final LineString line1Reverse = line1.reverse();
// Every point is duplicated
final LineString line2 = geometryFactory.lineString(3, START_X + 300, START_Y + 300, 3, START_X + 300, START_Y + 300, 3, START_X + 400, START_Y + 400, 4, START_X + 400, START_Y + 400, 4, START_X + 500, START_Y + 500, 5, START_X + 500, START_Y + 500, 5);
final LineString line2Reverse = line2.reverse();
// Line to make a loop
final LineString line3 = geometryFactory.lineString(3, START_X + 300, START_Y + 300, 3, START_X, START_Y, 0);
final LineString line3Reverse = line3.reverse();
// Forwards, Forwards
assertMerge(false, line1, line2, START_X + 300, START_Y + 300, START_X, START_Y, 0, START_X + 100, START_Y + 100, 1, START_X + 200, START_Y + 200, 2, START_X + 300, START_Y + 300, 3, START_X + 400, START_Y + 400, 4, START_X + 500, START_Y + 500, 5);
// Forwards, Reverse
assertMerge(false, line1, line2Reverse, START_X + 300, START_Y + 300, START_X, START_Y, 0, START_X + 100, START_Y + 100, 1, START_X + 200, START_Y + 200, 2, START_X + 300, START_Y + 300, 3, START_X + 400, START_Y + 400, 4, START_X + 500, START_Y + 500, 5);
// Reverse, Forwards
assertMerge(false, line1Reverse, line2, START_X + 300, START_Y + 300, START_X + 500, START_Y + 500, 5, START_X + 400, START_Y + 400, 4, START_X + 300, START_Y + 300, 3, START_X + 200, START_Y + 200, 2, START_X + 100, START_Y + 100, 1, START_X, START_Y, 0);
// Reverse, Reverse
assertMerge(false, line1Reverse, line2Reverse, START_X + 300, START_Y + 300, START_X + 500, START_Y + 500, 5, START_X + 400, START_Y + 400, 4, START_X + 300, START_Y + 300, 3, START_X + 200, START_Y + 200, 2, START_X + 100, START_Y + 100, 1, START_X, START_Y, 0);
// Loop Forwards, Forwards
assertMerge(true, line1, line3, START_X + 300, START_Y + 300, START_X, START_Y, 0, START_X + 100, START_Y + 100, 1, START_X + 200, START_Y + 200, 2, START_X + 300, START_Y + 300, 3, START_X, START_Y, 0);
// Loop Forwards, Reverse
assertMerge(true, line1, line3Reverse, START_X + 300, START_Y + 300, START_X, START_Y, 0, START_X + 100, START_Y + 100, 1, START_X + 200, START_Y + 200, 2, START_X + 300, START_Y + 300, 3, START_X, START_Y, 0);
// Loop Reverse, Forwards
assertMerge(true, line1Reverse, line3, START_X + 300, START_Y + 300, START_X, START_Y, 0, START_X + 300, START_Y + 300, 3, START_X + 200, START_Y + 200, 2, START_X + 100, START_Y + 100, 1, START_X, START_Y, 0);
// Loop Reverse, Reverse
assertMerge(true, line1Reverse, line3Reverse, START_X + 300, START_Y + 300, START_X, START_Y, 0, START_X + 300, START_Y + 300, 3, START_X + 200, START_Y + 200, 2, START_X + 100, START_Y + 100, 1, START_X, START_Y, 0);
}
use of com.revolsys.geometry.model.GeometryFactory in project com.revolsys.open by revolsys.
the class LineStringTest method testSplit.
@Test
public void testSplit() {
final GeometryFactory geometryFactory = GeometryFactory.fixed3d(26910, 1000.0, 1000.0, 1.0);
// Last point is duplicated
final LineString line = geometryFactory.lineString(3, START_X, START_Y, 0, START_X + 100, START_Y + 100, 1, START_X + 200, START_Y + 100, 2, START_X + 100, START_Y, 3);
// From vertex
assertSplit(true, line, geometryFactory.point(START_X, START_Y), line);
// To vertex
assertSplit(true, line, geometryFactory.point(START_X + 100, START_Y), line);
// Middle vertex
final LineString lineVertexMiddle1 = geometryFactory.lineString(3, START_X, START_Y, 0, START_X + 100, START_Y + 100, 1);
final LineString lineVertexMiddle2 = geometryFactory.lineString(3, START_X + 100, START_Y + 100, 1, START_X + 200, START_Y + 100, 2, START_X + 100, START_Y, 3);
final Point pointVertexMiddle2 = geometryFactory.point(START_X + 100, START_Y + 100);
assertSplit(true, line, pointVertexMiddle2, lineVertexMiddle1, lineVertexMiddle2);
// Middle vertex
final LineString lineVertexClose1 = geometryFactory.lineString(3, START_X, START_Y, 0, START_X + 100, START_Y + 100, 1, START_X + 99.999, START_Y + 100.001, 1);
final LineString lineVertexClose2 = geometryFactory.lineString(3, START_X + 99.999, START_Y + 100.001, 1, START_X + 100, START_Y + 100, 1, START_X + 200, START_Y + 100, 2, START_X + 100, START_Y, 3);
assertSplit(false, line, geometryFactory.point(START_X + 99.999, START_Y + 100.001, 1), lineVertexClose1, lineVertexClose2);
// Middle of first segment
for (final double offset : new double[] { 0.001, 50, 99.999 }) {
final double x = START_X + offset;
final double y = START_Y + offset;
final LineString lineSegmentFirst1 = geometryFactory.lineString(3, START_X, START_Y, 0, x, y, offset);
final LineString lineSegmentFirst2 = geometryFactory.lineString(3, x, y, offset, START_X + 100, START_Y + 100, 1, START_X + 200, START_Y + 100, 2, START_X + 100, START_Y, 3);
final Point splitPoint = geometryFactory.point(x, y, offset);
assertSplit(false, line, splitPoint, lineSegmentFirst1, lineSegmentFirst2);
}
}
Aggregations