use of com.revolsys.geometry.model.Punctual 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.Punctual in project com.revolsys.open by revolsys.
the class MultiPointEditorTest method testSetM.
@Test
public void testSetM() {
final PunctualEditor editor = PUNCTUAL.newGeometryEditor(4);
editor.setM(0, 10);
final Punctual newMultiPoint = editor.newGeometry();
Assert.assertNotSame(PUNCTUAL, newMultiPoint);
Assert.assertEquals(10.0, newMultiPoint.getM(0), 0.0);
}
use of com.revolsys.geometry.model.Punctual in project com.revolsys.open by revolsys.
the class MultiPointImplTest method testGetGeometryN.
/**
* @todo Enable when #isSimple implemented
*/
// public void testIsSimple2() throws Exception {
// MultiPoint m = (MultiPoint)
// reader.read("MULTIPOINT(1.111 2.222, 3.333 4.444, 3.333 4.444)");
// assertTrue(! m.isSimple());
// }
public void testGetGeometryN() throws Exception {
final Punctual m = (Punctual) this.geometryFactory.geometry("MULTIPOINT((1.111 2.222), (3.333 4.444), (3.333 4.444))");
final Geometry g = m.getGeometry(1);
assertTrue(g instanceof Point);
final Point p = (Point) g;
final Point internal = p.getPoint();
final Point externalCoordinate = new PointDoubleXY(internal.getX(), internal.getY());
assertEquals(3.333, externalCoordinate.getX(), 1E-10);
assertEquals(4.444, externalCoordinate.getY(), 1E-10);
}
use of com.revolsys.geometry.model.Punctual in project com.revolsys.open by revolsys.
the class MultiPointImplTest method testGetEnvelope.
public void testGetEnvelope() throws Exception {
final Punctual m = (Punctual) this.geometryFactory.geometry("MULTIPOINT((1.111 2.222), (3.333 4.444), (3.333 4.444))");
final BoundingBox e = m.getBoundingBox();
assertEquals(1.111, e.getMinX(), 1E-10);
assertEquals(3.333, e.getMaxX(), 1E-10);
assertEquals(2.222, e.getMinY(), 1E-10);
assertEquals(4.444, e.getMaxY(), 1E-10);
}
use of com.revolsys.geometry.model.Punctual in project com.revolsys.open by revolsys.
the class NormalizeTest method testNormalizeMultiPoint.
public void testNormalizeMultiPoint() throws Exception {
Geometry m = this.geometryFactory.geometry("MULTIPOINT((30 20),(10 10),(20 20),(30 30),(20 10))");
m = m.normalize();
final Punctual expectedValue = (Punctual) this.geometryFactory.geometry("MULTIPOINT((10 10),(20 10),(20 20),(30 20),(30 30))");
assertEqualsExact(expectedValue, m);
final Punctual unexpectedValue = (Punctual) this.geometryFactory.geometry("MULTIPOINT((20 10),(20 20),(30 20),(30 30),(10 10))");
assertTrue(!m.equals(2, unexpectedValue));
}
Aggregations