Search in sources :

Example 26 with Punctual

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());
}
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 27 with Punctual

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

Example 28 with Punctual

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

Example 29 with Punctual

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

Example 30 with Punctual

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

Aggregations

Punctual (com.revolsys.geometry.model.Punctual)31 Point (com.revolsys.geometry.model.Point)17 LineString (com.revolsys.geometry.model.LineString)11 Lineal (com.revolsys.geometry.model.Lineal)11 Polygon (com.revolsys.geometry.model.Polygon)11 Polygonal (com.revolsys.geometry.model.Polygonal)9 Geometry (com.revolsys.geometry.model.Geometry)8 Test (org.junit.Test)7 BoundingBox (com.revolsys.geometry.model.BoundingBox)6 LinearRing (com.revolsys.geometry.model.LinearRing)6 PunctualEditor (com.revolsys.geometry.model.editor.PunctualEditor)6 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)4 ArrayList (java.util.ArrayList)2 DataType (com.revolsys.datatype.DataType)1 Edge (com.revolsys.geometry.graph.Edge)1 LineStringDouble (com.revolsys.geometry.model.impl.LineStringDouble)1 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)1 LineSegment (com.revolsys.geometry.model.segment.LineSegment)1 LineSegmentDoubleGF (com.revolsys.geometry.model.segment.LineSegmentDoubleGF)1 BaseCloseable (com.revolsys.io.BaseCloseable)1