use of org.h2.tools.SimpleRowSource in project h2database by h2database.
the class TestSpatial method getRandomGeometryTable.
/**
* Generate a result set with random geometry data.
* Used as an ALIAS function.
*
* @param seed the random seed
* @param rowCount the number of rows
* @param minX the smallest x
* @param maxX the largest x
* @param minY the smallest y
* @param maxY the largest y
* @param maxLength the maximum length
* @return a result set
*/
public static ResultSet getRandomGeometryTable(final long seed, final long rowCount, final double minX, final double maxX, final double minY, final double maxY, final double maxLength) {
SimpleResultSet rs = new SimpleResultSet(new SimpleRowSource() {
private final Random random = new Random(seed);
private int currentRow;
@Override
public Object[] readRow() throws SQLException {
if (currentRow++ < rowCount) {
return new Object[] { getRandomGeometry(random, minX, maxX, minY, maxY, maxLength) };
}
return null;
}
@Override
public void close() {
// nothing to do
}
@Override
public void reset() throws SQLException {
random.setSeed(seed);
}
});
rs.addColumn("the_geom", Types.OTHER, "GEOMETRY", Integer.MAX_VALUE, 0);
return rs;
}
Aggregations