Search in sources :

Example 31 with Polygonal

use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.

the class OracleSdoGeometryJdbcFieldDefinition method toSdoGeometry.

private Struct toSdoGeometry(final Connection connection, final Object object, final int axisCount) throws SQLException {
    if (object instanceof Geometry) {
        Geometry geometry = (Geometry) object;
        geometry = geometry.newGeometry(this.geometryFactory);
        if (object instanceof Polygon) {
            final Polygon polygon = (Polygon) geometry;
            return toSdoPolygon(connection, polygon, axisCount);
        } else if (object instanceof LineString) {
            final LineString lineString = (LineString) geometry;
            return toSdoLineString(connection, lineString, axisCount);
        } else if (object instanceof Point) {
            final Point point = (Point) geometry;
            return toSdoPoint(connection, point, axisCount);
        } else if (object instanceof Punctual) {
            final Punctual punctual = (Punctual) geometry;
            return toSdoMultiPoint(connection, punctual, axisCount);
        } else if (object instanceof Lineal) {
            final Lineal lineal = (Lineal) geometry;
            return toSdoMultiLineString(connection, lineal, axisCount);
        } else if (object instanceof Polygonal) {
            final Polygonal polygonal = (Polygonal) geometry;
            return toSdoMultiPolygon(connection, polygonal, axisCount);
        }
    } else if (object instanceof BoundingBox) {
        BoundingBox boundingBox = (BoundingBox) object;
        boundingBox = boundingBox.convert(this.geometryFactory, 2);
        final double minX = boundingBox.getMinX();
        final double minY = boundingBox.getMinY();
        final double maxX = boundingBox.getMaxX();
        final double maxY = boundingBox.getMaxY();
        return toSdoGeometry(connection, 3, null, RECTANGLE_ELEM_INFO, minX, minY, maxX, maxY);
    }
    throw new IllegalArgumentException("Unable to convert to SDO_GEOMETRY " + object.getClass());
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Punctual(com.revolsys.geometry.model.Punctual) Lineal(com.revolsys.geometry.model.Lineal) LineString(com.revolsys.geometry.model.LineString) Polygonal(com.revolsys.geometry.model.Polygonal) BoundingBox(com.revolsys.geometry.model.BoundingBox) Point(com.revolsys.geometry.model.Point) Polygon(com.revolsys.geometry.model.Polygon)

Example 32 with Polygonal

use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.

the class GeometryTest method doWriteTest.

private void doWriteTest(final DataType geometryType, final int axisCount, final int partCount, final int ringCount) {
    final GeometryFactory sourceGeometryFactory = GeometryFactory.floating(3857, axisCount);
    String typeName = geometryType.getName().toUpperCase();
    typeName = typeName.replace("MULTI", "MULTI_");
    final PathName typePath = PathName.newPathName("/ORACLE_TEST/" + typeName + axisCount);
    Geometry geometry = GeometryTestUtil.geometry(sourceGeometryFactory, geometryType, axisCount, partCount, ringCount);
    if (geometry instanceof Polygonal) {
        geometry = geometry.toCounterClockwise();
    }
    try (Transaction transaction = this.recordStore.newTransaction(Propagation.REQUIRES_NEW)) {
        final RecordDefinition recordDefinition = this.recordStore.getRecordDefinition(typePath);
        final Record record = this.recordStore.newRecord(typePath, Collections.singletonMap("GEOMETRY", geometry));
        try (Writer<Record> writer = this.recordStore.newRecordWriter()) {
            writer.write(record);
        }
        final Identifier identifier = record.getIdentifier();
        final Record savedRecord = this.recordStore.getRecord(typePath, identifier);
        Assert.assertNotNull("Saved record", savedRecord);
        final Geometry savedGeometry = savedRecord.getGeometry();
        final GeometryFactory tableGeometryFactory = recordDefinition.getGeometryFactory();
        final Geometry expectedGeometry = geometry.convertGeometry(tableGeometryFactory);
        com.revolsys.geometry.util.Assert.equals("Saved geometry", savedGeometry.equalsExact(expectedGeometry), expectedGeometry, savedGeometry);
        transaction.setRollbackOnly();
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Identifier(com.revolsys.identifier.Identifier) Transaction(com.revolsys.transaction.Transaction) Polygonal(com.revolsys.geometry.model.Polygonal) Record(com.revolsys.record.Record) PathName(com.revolsys.io.PathName) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 33 with Polygonal

use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.

the class TriangulationFunctions method delaunayTrianglesWithToleranceNoError.

public static Polygonal delaunayTrianglesWithToleranceNoError(final Geometry geom, final double tolerance) {
    GeometryFactory geometryFactory = geom.getGeometryFactory();
    geometryFactory = geometryFactory.convertScales(tolerance, tolerance, tolerance);
    final QuadEdgeDelaunayTinBuilder builder = new QuadEdgeDelaunayTinBuilder(geometryFactory);
    builder.insertVertices(geom);
    try {
        final Polygonal triangles = builder.getTrianglesPolygonal();
        return triangles;
    } catch (final LocateFailureException ex) {
        System.out.println(ex);
    // ignore this exception and drop thru
    }
    /**
     * Get the triangles created up until the error
     */
    final Polygonal triangles = builder.getSubdivision().getTrianglesPolygonal(geom.getGeometryFactory());
    return triangles;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Polygonal(com.revolsys.geometry.model.Polygonal) LocateFailureException(com.revolsys.elevation.tin.quadedge.LocateFailureException) QuadEdgeDelaunayTinBuilder(com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)

Example 34 with Polygonal

use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.

the class TriangulationFunctions method delaunayTriangles.

public static Polygonal delaunayTriangles(final Geometry geometry) {
    final GeometryFactory geometryFactory = geometry.getGeometryFactory();
    final QuadEdgeDelaunayTinBuilder builder = new QuadEdgeDelaunayTinBuilder(geometryFactory);
    builder.insertVertices(geometry);
    final Polygonal triangles = builder.getTrianglesPolygonal();
    return triangles;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Polygonal(com.revolsys.geometry.model.Polygonal) QuadEdgeDelaunayTinBuilder(com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)

Example 35 with Polygonal

use of com.revolsys.geometry.model.Polygonal in project com.revolsys.open by revolsys.

the class TriangulationFunctions method conformingDelaunayTrianglesWithTolerance.

public static Polygonal conformingDelaunayTrianglesWithTolerance(final Geometry sites, final Geometry constraints, final double tol) {
    final QuadEdgeConformingDelaunayTinBuilder builder = new QuadEdgeConformingDelaunayTinBuilder();
    builder.setSites(sites);
    builder.setConstraints(constraints);
    builder.setTolerance(tol);
    final GeometryFactory geomFact = sites != null ? sites.getGeometryFactory() : constraints.getGeometryFactory();
    final Polygonal triangles = builder.getTrianglesPolygonal(geomFact);
    return triangles;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) QuadEdgeConformingDelaunayTinBuilder(com.revolsys.elevation.tin.quadedge.QuadEdgeConformingDelaunayTinBuilder) Polygonal(com.revolsys.geometry.model.Polygonal)

Aggregations

Polygonal (com.revolsys.geometry.model.Polygonal)41 Polygon (com.revolsys.geometry.model.Polygon)17 LinearRing (com.revolsys.geometry.model.LinearRing)12 Point (com.revolsys.geometry.model.Point)12 LineString (com.revolsys.geometry.model.LineString)9 Lineal (com.revolsys.geometry.model.Lineal)9 Punctual (com.revolsys.geometry.model.Punctual)9 Geometry (com.revolsys.geometry.model.Geometry)8 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)7 PolygonalEditor (com.revolsys.geometry.model.editor.PolygonalEditor)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)4 QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)3 BoundingBox (com.revolsys.geometry.model.BoundingBox)2 PathName (com.revolsys.io.PathName)2 Record (com.revolsys.record.Record)2 NoSuchElementException (java.util.NoSuchElementException)2 LocateFailureException (com.revolsys.elevation.tin.quadedge.LocateFailureException)1 QuadEdgeConformingDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeConformingDelaunayTinBuilder)1 IndexedPointInAreaLocator (com.revolsys.geometry.algorithm.locate.IndexedPointInAreaLocator)1