private void testIndexRealData(String source, double checkPeriod, DiskRTree tree) throws NoSuchTableException, DataSourceCreationException, DriverException, IOException, Exception { DataSource ds = dsf.getDataSource(source); String fieldName = "the_geom"; ds.open(); int fieldIndex = ds.getFieldIndexByName(fieldName); for (int i = 0; i < ds.getRowCount(); i++) { if (i / (int) checkPeriod == i / checkPeriod) { tree.checkTree(); tree.close(); tree.openIndex(indexFile); tree.checkTree(); checkLookUp(tree, ds, fieldIndex); } Envelope value = ds.getFieldValue(i, fieldIndex).getAsGeometry().getEnvelopeInternal(); tree.insert(value, i); } for (int i = 0; i < ds.getRowCount(); i++) { if (i / (int) checkPeriod == i / checkPeriod) { tree.checkTree(); tree.save(); tree.checkTree(); checkLookUp(tree, ds, fieldIndex); } Value value = ds.getFieldValue(i, fieldIndex); tree.delete(value.getAsGeometry().getEnvelopeInternal(), i); } ds.close(); }
private String associateString(Source source, String propertyName) throws Exception { DataSource ds = dsf.getDataSource(SOURCE); ds.open(); long rc = ds.getRowCount(); ds.close(); String rcStr = Long.toString(rc); source.putProperty(propertyName, rcStr); return rcStr; }
@Test public void testIndexVisitor() throws Exception { DiskRTree tree = new DiskRTree(16, 1024, false); tree.newIndex(indexFile); DataSource ds = dsf.getDataSource("points"); String fieldName = "the_geom"; ds.open(); int fieldIndex = ds.getFieldIndexByName(fieldName); for (int i = 0; i < ds.getRowCount(); i++) { Envelope value = ds.getFieldValue(i, fieldIndex).getAsGeometry().getEnvelopeInternal(); tree.insert(value, i); } Envelope e = ds.getGeometry((ds.getRowCount() - 1) / 2).getEnvelopeInternal(); IV iV = new IV(ds); tree.query(e, iV); assertTrue(iV.fired); }
private String associateFile(Source source, String propertyName) throws Exception { if (source.hasProperty(propertyName)) { source.deleteProperty(propertyName); } File stats = source.createFileProperty(propertyName); DataSource ds = dsf.getDataSource(source.getName()); ds.open(); long rc = ds.getRowCount(); ds.close(); FileOutputStream fis = new FileOutputStream(stats); String rcStr = Long.toString(rc); fis.write(rcStr.getBytes()); fis.close(); return rcStr; }
@Test public void testGetSetCRS() throws Exception { dsf.executeSQL("CREATE TABLE init AS SELECT * FROM ST_RandomGeometry('point', 10);"); DataSource ds = dsf.getDataSourceFromSQL("SELECT ST_CRS(the_geom) from init;"); ds.open(); assertTrue(ds.isNull(0, 0)); ds.close(); ds = dsf.getDataSourceFromSQL("SELECT ST_CRS(ST_SetCRS(the_geom, 'EPSG:27572')) from init;"); ds.open(); for (int i = 0; i < ds.getRowCount(); i++) { assertTrue(ds.getString(i, 0).contains("EPSG:27572")); } ds.close(); }