Search in sources :

Example 1 with AffineTransformation

use of org.locationtech.jts.geom.util.AffineTransformation in project h2database by h2database.

the class TestSpatial method testInPlaceUpdate.

/**
 * If the user mutate the geometry of the object, the object cache must not
 * be updated.
 */
private void testInPlaceUpdate() throws SQLException {
    try (Connection conn = getConnection(URL)) {
        ResultSet rs = conn.createStatement().executeQuery("SELECT 'POINT(1 1)'::geometry");
        assertTrue(rs.next());
        // Mutate the geometry
        ((Geometry) rs.getObject(1)).apply(new AffineTransformation(1, 0, 1, 1, 0, 1));
        rs.close();
        rs = conn.createStatement().executeQuery("SELECT 'POINT(1 1)'::geometry");
        assertTrue(rs.next());
        // Check if the geometry is the one requested
        assertEquals(1, ((Point) rs.getObject(1)).getX());
        assertEquals(1, ((Point) rs.getObject(1)).getY());
        rs.close();
    }
}
Also used : ValueGeometry(org.h2.value.ValueGeometry) Geometry(org.locationtech.jts.geom.Geometry) Connection(java.sql.Connection) SimpleResultSet(org.h2.tools.SimpleResultSet) ResultSet(java.sql.ResultSet) AffineTransformation(org.locationtech.jts.geom.util.AffineTransformation)

Aggregations

Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 SimpleResultSet (org.h2.tools.SimpleResultSet)1 ValueGeometry (org.h2.value.ValueGeometry)1 Geometry (org.locationtech.jts.geom.Geometry)1 AffineTransformation (org.locationtech.jts.geom.util.AffineTransformation)1