use of org.h2.api.Aggregate in project h2database by h2database.
the class TestSpatial method testAggregateWithGeometry.
private void testAggregateWithGeometry() throws SQLException {
deleteDb("spatialIndex");
try (Connection conn = getConnection("spatialIndex")) {
Statement st = conn.createStatement();
st.execute("CREATE AGGREGATE TABLE_ENVELOPE FOR \"" + TableEnvelope.class.getName() + "\"");
st.execute("CREATE TABLE test(the_geom GEOMETRY)");
st.execute("INSERT INTO test VALUES ('POINT(1 1)'), (null), (null), ('POINT(10 5)')");
ResultSet rs = st.executeQuery("select TABLE_ENVELOPE(the_geom) from test");
assertEquals("geometry", rs.getMetaData().getColumnTypeName(1).toLowerCase());
assertTrue(rs.next());
assertTrue(rs.getObject(1) instanceof Geometry);
assertTrue(new Envelope(1, 10, 1, 5).equals(((Geometry) rs.getObject(1)).getEnvelopeInternal()));
assertFalse(rs.next());
}
deleteDb("spatialIndex");
}
Aggregations