Search in sources :

Example 56 with GeometryFactory

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);
    });
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Point(com.revolsys.geometry.model.Point)

Example 57 with GeometryFactory

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);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory)

Example 58 with GeometryFactory

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);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory)

Example 59 with GeometryFactory

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);
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LineString(com.revolsys.geometry.model.LineString) Test(org.junit.Test)

Example 60 with GeometryFactory

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);
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) Test(org.junit.Test)

Aggregations

GeometryFactory (com.revolsys.geometry.model.GeometryFactory)360 Point (com.revolsys.geometry.model.Point)142 Geometry (com.revolsys.geometry.model.Geometry)72 BoundingBox (com.revolsys.geometry.model.BoundingBox)70 LineString (com.revolsys.geometry.model.LineString)61 ArrayList (java.util.ArrayList)45 DataType (com.revolsys.datatype.DataType)25 FieldDefinition (com.revolsys.record.schema.FieldDefinition)24 Polygon (com.revolsys.geometry.model.Polygon)22 List (java.util.List)18 RecordDefinition (com.revolsys.record.schema.RecordDefinition)17 Test (org.junit.Test)16 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)15 Vertex (com.revolsys.geometry.model.vertex.Vertex)14 Record (com.revolsys.record.Record)14 IOException (java.io.IOException)13 PathName (com.revolsys.io.PathName)12 LinearRing (com.revolsys.geometry.model.LinearRing)10 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)10 QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)8