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());
}
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();
}
}
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;
}
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;
}
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;
}
Aggregations